Connecting to the internet using the WIFI config tool
Connecting to the Internet using WPA_Supplicant
sudo nano /etc/network/interfaces
In my interface configuration I have given the Raspberry PI a static network address so that I can connect to it using SSH and I will know that the address will be the same every time. That however is for a different article that will come later on.
The lines you are interested in are really the last 4. So make sure your file has the following lines in it.
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet manual
iface default inet dhcp
So what does it all mean?
Well the two sections you are really interested in are the ones starting allow-hotplug eth0 and allow-hotplug wlan0.
The allow-hotplug eth0 will detect when an ethernet cable is plugged into the Raspberry PI and connected to the router. When this happens the iface etho0 inet dhcp will use DHCP to connect to the network. In its simplest form the internet connection will be created via the ethernet cable.
The allow-hotplug wlan0 will detect a wireless interface and will use wpa-roam with the configuration file in /etc/wpa_supplicant/wpa_supplicant.conf.
Using this information you will hopefully realise that you need to add some more settings to the file /etc/wpa_supplicant/wpa_supplicant.conf.
Press Ctrl and O to save the /etc/network/interfaces file and press CTRL and X to exit nano. (Nano is the editor)
Now type sudo nano /etc/wpa_supplicant/wpa_supplicant.conf into the terminal.
You will need to enter the lines of code from the image above into your terminal window.
It isn't a simple copy and paste though as you will need to replace the ssid with the name of your network and the psk with the security key used to connect to the internet.
Proto will be one of RSN or WPA. The key_mgmt will be set to either WPA_PSK or WPA_EAP and depends on your router. Pairwise will be set to CCMP or TKIP. Finally auth_alg can be either OPEN, SHARED or LEAP. This is the same information as highlighted in the GUI section of this article earlier.
If you followed the first part of this tutorial to set up the wireless using the WIFI config tool it is highly likely that most of the information is already entered into this file (if not all of it). Just keep a copy of this file safe and if you choose to install a different version of LINUX to connect to the same internet connection you can just copy the file into the /etc/wpa_supplicant folder.
Now press CTRL and O to save the file and then CTRL and X to exit the file.
Close the terminal and reboot your Raspberry PI. Your internet connection will start automatically every time.