Setup wifi on RPI based on linux systemd distribution

Posted by Pierre Verkest on September 24, 2016

You can find a documentation to setup wifi on however I much prefer the one from debian wiki

First connect to a freshly installed RPI linux console I’m writting this blog post right after setup Hypriot on my RPI 3 I expect that works on systemd linux based operating system.

Note: You can also setting up this configuration while the sdcard is on your computer, detect your operating system mount point using lsblk:

pverkest@petrus-v:~$ lsblk 
sda      8:0    0 953,9G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 797,1G  0 part /
└─sda3   8:3    0 156,3G  0 part [SWAP]
sdb      8:16   1  14,9G  0 disk 
├─sdb1   8:17   1    64M  0 part /media/usb0
└─sdb2   8:18   1  14,8G  0 part /media/usb1

WARNING: In that case the following explaination you should edit the file in /media/usb1/etc/network/interfaces.d/wlan0 instead /etc/network/interfaces.d/wlan0 otherwise you will change setting on your computer instead setting up the OS on the sdcard!

  • Generate encrypted wpa configuration
$ wpa_passphrase myssid Your_wifi_password

You should get something that looks like that:

  • Setup the wlan0 interface adding or editing this file /etc/network/interfaces.d/wlan0:
auto wlan0
iface wlan0 inet dhcp
    wpa-ssid The_ESSID
    wpa-psk encrypted_Your_wifi_password
  • auto: start the interface at startup
  • iface wlan0 inet dhcp: tell that the wlan0 interface should use dhcp
  • wpa-ssid: SSID of your box
  • wpa-psk: encrypted password generated by wpa_passphrase

if you want to manage a static address this should looks like:

auto wlan0

iface wlan0 inet static
    wpa-ssid The_ESSID
    wpa-psk encrypted_Your_wifi_password
  • Then start the interface or reboot:
$ sudo ifup wlan0
# or reboot
$ sudo reboot
  • You can check the current configuratoin:
$ ip a s wlan0
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:ee:13:cb brd ff:ff:ff:ff:ff:ff
    inet brd scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:feee:13cb/64 scope link 
       valid_lft forever preferred_lft forever

Note: If you manage to get multiple RPI on the same network you may want to change RPI hostname. Hypriot set the hostname at boot time using /boot/device-init.yaml config file.