Setup: The Network

Connecting to your wifi for the first time is easy as Pi on most computers and mobile devices.  On the Raspberry Pi my first reaction to the GUI was a confused one.  Since most everything can be done on the command line, and it’s much more cooler – let’s set it up that way.

To do this we will edit the wpa_supplicant.conf  file in the /etc directory that stores network configuration information.  We will use nano to edit the file and add the router name and password.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add your wifi information in the following format to the bottom of the file.

ssid=”router name”

Save and close the file by pressing Ctrl x, then y to confirm to save the modifications, then press Enter to save it to the same file name and overwrite the file.

Let’s restart the wifi on the Raspberry Pi and check to see if the settings are working.  Turn off the wifi and turn it back on.

sudo ifdown wlan0

sudo ifup wlan0

Then check your wifi network interface is up and running using ifconfig.  The wifi interface is called wlan0 (wireless LAN 0).

ifconfig wlan0

You will see a block of information about wlan0 like the MAC address, IP addresses and other networking information.

To find out what your IP address is look for “inet addr:” in the second line.  You can show just this line with the following command.

ifconfig wlan0 | grep “inet addr”

You will see your IP, broadcast and mask like this.

inet addr:  Bcast:  Mask: