User Tools

Site Tools


setup_wifi_from_command_line_console

Setup WiFi from Command Line Console

Jan 2017




Setting up WiFi from the GUI of Raspbian is easy, just click the wifi button on the top right, select your SSID, enter your details and away you go.

If however you don't want to use the GUI, or you are using say Raspbian Jessie Light, where there is no GUI, you need to do this from the command line. Don't worry, it's just as easy, you just need a couple of commands.


Before you start


First we need to scan for wireless networks. Before you do this you need to consider two things.

  1. This may not be useful if your SSID is hidden (not tried it to be honest)
  2. If are using MAC Filtering on your router, you need to add the MAC of the wireless dongle to your router configuration first.



If you are using MAC filtering, from the command line enter:

  ifconfig


You will see an output as follows:

wlan0     Link encap:Ethernet HWaddr d5:6b:b0:99:46:86
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1826 errors:0 dropped:1183 overruns:0 frame:0
          TX packets:183 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:216207 (211.1 KiB)  TX bytes:24862 (24.2 KiB)


Enter HWaddr (d5:6b:b0:99:46:86 in this example) in to your router.


Find your Wireless Network


To scan for wireless networks, use the following command:

  sudo iwlist wlan0 scan


If you have more than one SSID close by, then you could get quite a list. so you can use the following to work out what information you need.

  sudo iwlist wlan0 scan |more
  
  This will allow you to scroll through the pages of information you might get


Or

  sudo iwlist wlan0 scan |grep SSID
  
  This will show just the SSIDs from the scan, meaning you can spot your SSDI more easily, for example:
  
  ESSID:"Work"
  ESSID:"Home"
  ESSID:"Public"
  ESSID:"Guests"
  ESSID:"Samsung-Printer"




Add WiFi details to Raspbian


To add your details to Raspbian, use the following:

  sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


You will see a fairly empty file (assuming no one has edited this before)

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


At the end of this file, add the following lines.

network={
    ssid="The_ESSID_from_earlier"
    psk="Your_wifi_password"
}

So I might add:

network={
    ssid="Home"
    psk="0123456789"


Save the file, reboot the Pi and Voila!

Ifconfig

wlan0     Link encap:Ethernet  HWaddr d5:6b:b0:99:46:86
          inet addr:137.58.50.53  Bcast:137.58.50.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7846 errors:0 dropped:5265 overruns:0 frame:0
          TX packets:744 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:928708 (906.9 KiB)  TX bytes:76256 (74.4 KiB)



setup_wifi_from_command_line_console.txt · Last modified: 2017/02/28 18:00 (external edit)