Last active
October 28, 2025 19:10
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
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
What if our wifi has no password?