Thursday, October 10, 2013

Configuring WiFi Dongle on Raspberry Pi via the console



With the WiFi dongle not connected, connect directly to your Raspberry Pi and log in.
  • At the prompt, enter the following command:
sudo vi /etc/network/interfaces
  • You’ll see something like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp

  • Add the following lines at the end:
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
  • Save the file, exit and enter the following command:
sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
  • Add the network section as per below:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
   ssid="YOURSSID"
   psk="YOURPASSWORD"
   # Protocol type can be: RSN (for WP2) and WPA (for WPA1)
   proto=RSN
   # Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
   key_mgmt=WPA-PSK
   # Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
   pairwise=CCMP
   #Authorization option should be OPEN for both WPA1/WPA2
   auth_alg=OPEN

}
  • The password can be encrypted by doing the following:
$ wpa_passphrase myssid password
network={
   ssid="myssid"
   #psk="password"
   psk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}

I came across a particular problem in my case because I used 'raspi-config' to change the hostname of my Pi.  If you do that, you need to make sure that the hostname and the contents of /etc/hosts is consistent.

Edit /etc/hosts and make sure that the line with your hostname is included, that the hostname matches what you see when you type 'hostname' and that it is associated to your localhost IP.

$ sudo cat /etc/hosts
127.0.0.1       localhost
127.0.0.1       RPiB

$ hostname
RPiB
  • Reboot the Pi
sudo reboot


Check out my YouTube channel:  www.youtube.com/KedarWarriner

No comments:

Post a Comment