Skip to content

Instantly share code, notes, and snippets.

@rampfox
Last active June 16, 2022 13:16
Show Gist options
  • Save rampfox/d32dea321ce41fc3916e0b14f6d5fb2d to your computer and use it in GitHub Desktop.
Save rampfox/d32dea321ce41fc3916e0b14f6d5fb2d to your computer and use it in GitHub Desktop.
Setting up preferred network a Raspberry Pi headless

Setting up preferred network a Raspberry Pi headless

This method is suitable if you don't have access to the graphical user interface normally used to set up WiFi on the Raspberry Pi.

Note also that no additional software is required; everything you need is already included on the Raspberry Pi.

Setting up wireless networking

You will need to define a wpa_supplicant.conf
Put this file in the boot Volumes

cd /Volumes/boot

then create file

touch wpa_supplicant.conf

and edit the file

sudo nano wpa_supplicant.conf

country=<Insert country code here>
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
 ssid="<Name of your WiFi>"
 scan_ssid=1
 psk="<Password for your WiFi>"
}

example

country=ID
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
 ssid="FIFI LT_3"
 psk="F1F1*12345"
}

example with multiple network priority

country=ID
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
 ssid="FIFI LT_3"
 psk="F1F1*12345"
}

network={
 ssid="wakwaw"
 psk="abcdabcd"
}

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