Skip to content

Instantly share code, notes, and snippets.

@StrixROX
Last active October 28, 2025 19:10
Show Gist options
  • Select an option

  • Save StrixROX/acf66418d29756e2965d2bb4ebbad1ba to your computer and use it in GitHub Desktop.

Select an option

Save StrixROX/acf66418d29756e2965d2bb4ebbad1ba to your computer and use it in GitHub Desktop.
Cloud-Init configuration files for connecting Wi-Fi and ethernet to Raspberrypi 4B
# /etc/netplan/50-cloud-init.yaml
# Indent size = 2 spaces. No tabspaces allowed.
#
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: <------- {{ PAY ATTENTION TO THIS PART. This may be different for you; follow your version }}
# network: {config: disabled}
network:
version: 2
ethernets:
eth0:
addresses: [192.168.100.30/24] # whatever address you want the device to have
gateway4: 192.168.100.255 # this has to be same on both the connected devices
wifis:
renderer: networkd
wlan0:
access-points:
YOUR_WIFI_NAME:
password: YOUR_WIFI_PASSWORD
dhcp4: true
optional: true
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
# First, disable the cloud-init network configuration by
# creating this file in the location specified above
network: {config: disabled}
# After disabling the cloud-init network configuration
# and editing /etc/netplan/50-cloud-init.yaml
# run these commands in your Raspberrypi 4B terminal
sudo netplan --debug generate # check your file for errors
sudo netplan apply && sudo reboot # apply the new network settings and reboot
@pGovm

pGovm commented Oct 21, 2025

Copy link
Copy Markdown

What if our wifi has no password?

@StrixROX

StrixROX commented Oct 28, 2025

Copy link
Copy Markdown
Author

As per my knowledge cloud-init only supports password protected networks. I personally have not tried connecting it to an open network yet so I can't give more information on that, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment