1.2 WiFi

Handy WiFi commands

  • Scan for nearby wifi: iwlist wlan0 scan
  • Turn WiFi on/off: ifup wlan0 and ifdown wlan0
  • Or restart WiFi (after changing configuration options, e.g.) using sudo service network-manager restart or sudo service networking restart (depending on your Raspbian version).

Set-up WiFi

Raspberries with built-in WiFi and Raspbian Stretch or newer

This is easy-peasy: just set up your WiFi through the raspi-config tool.

Continue reading if you have other hardware or an older OS.

The old-fashioned way

The following is written for Raspberry Pi's that don't have built-in WiFi, and assumes that you've plugged in a compatible USB dongle. For the RPi 3, most of the following is already in place.

  1. Insert the following into /etc/network/interfaces:

     # Enable wlan on boot:
     auto wlan0
     # Other options instead of 'manual' are 'static' and 'dhcp'.
     # 'manual' tells it to use the following config file
     iface wlan0 inet manual
     # Using this config file:
     wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
     # wlan0 will loop back to this default
     iface default inet dhcp
    
  2. And in /etc/wpa_supplicant/wpa_supplicant.conf (change ssid and password to your own):

     ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
     update_config=1
     network={
         ssid="not telling"
         psk="not telling"
         # RSN == WPA2
         proto=RSN
         key_mgmt=WPA-PSK
         # CCMP == AES
         pairwise=CCMP
         # Required for WPA and WPA2:
         auth_alg=OPEN
         # Optional, to replace 'default' in previous file:
         # id_str="home" # or whatever
     }
    

If the WiFi password is so precious that other people using the computer may not know it:

chmod 0600 /etc/network/interfaces

Set-up WiFi with static ip

Note that instead of setting a static ip in de Raspberry, it would be a better solution to NOT use a static ip and let the router always set the same ip to the RPi, to avoid ip-clashes. See this post by user jb1000.

Anyway, edit /etc/network/interfaces and replace the last line (iface default inet dhcp) with this:

iface default inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1

Where 192.168.1.10 should be replaced by the desired static ip.

Change nameservers

Just in case you want this, you can choose e.g. the Google DNS servers (or OpenDNS or other) over your ISP's servers, by adding them right after the gateway part, e.g.:

dns-nameservers 8.8.8.8 8.8.4.4

Disable WiFi sleep

For permament SSH access from the outside, the WiFi adapter should not go to sleep. The following explanation only works for dongles with Realtek 8192cu chip.

Check if power management is enabled:

cat /sys/module/8192cu/parameters/rtw_power_mgnt

If it returns 0 power management is disabled, 1 means minimal power management, 2 means maximum power management. To disable it, create a file at sudo nano /etc/modprobe.d/8192cu.conf and insert:

# Disable power management
options 8192cu rtw_power_mgnt=0

Reboot the Raspberry to activate: sudo reboot.

Enable WiFi channels 12 and 13 on the RPi 3

A.k.a. "My Raspberry Pi 3 sees all the networks in the neighbourhood except mine!"

(source)

The RPi 3 with its built-in WiFi doesn't automatically pick up on all WiFi networks. For starters it doesn't support 5Ghz networks, but it also doesn't support channel 12 and 13 on 2.4Ghz networks. This latter issue can be fixed by updating the firmware:

First, make sure your system is all up-to-date:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Then update the firmware as well:

sudo rpi-update

You might have to run sudo apt-get install rpi-update for this as it was not included in earlier versions of Raspbian. After this, your WiFi network will show up in the desktop GUI thing and when running iwilist scan.

results matching ""

    No results matching ""