2014年10月8日 星期三

Raspberry Pi Wifi Configuration With Hidden SSID

Raspberry Pi Wifi Configuration With Hidden SSID

This guide aims to communicate what configuration files have been used to setup WiFi on a Raspberry Pi using a Virgin Media router with a hidden SSID, along with instructions on how to use them.
Why post your Raspberry Pi WiFi configuration?
I spent over an hour using trial and error to get WiFi working on a Raspberry Pi. I used multiple blogs, forums, guides and a few guesses to finally arrive at a working configuration. This post is intended to try and help others facing similar frustration.
What hardware and setup are you using?
I have a Raspberry Pi Model B with a Edimax WiFi USB dongle. I have also tested this with a Dynamode WiFi USB dongle and it works fine on both. The router is a Virgin Media Super Hub model VMDG480. The default SSID and password have been changed and the SSID has been set to hidden.
Configuration files
There are two files to edit.
/etc/network/interfaces
/etc/wpa_supplicant/wpa_supplicant.conf
The first file contains general network settings. The second file contains the specific WiFi settings.
To edit the first file type the below into a console:
sudo nano /etc/network/interfaces
The entire file should look like the below. It's important that the indent is a tab and not spaces. The line that starts with "pre-up wpa_supplicant" and ends with "-B" is a single line that has been indented. The code below may appear on multiple lines, but please make sure that this line is a single line in the configuration file without any carriage returns.
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0

iface wlan0 inet dhcp
        pre-up wpa_supplicant -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
Next we need to enter the specific WiFi settings. To edit the second file type the below into a console:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
The entire file should look like the below. It's important that the indent is a tab and not spaces. Be sure to replace YOUR-SSID-GOES-HERE with your WiFi SSID, and YOUR-PASSWORD-GOES-HERE with your WiFi password.
ctrl_interface=/var/run/wpa_supplicant
update_config=1
ap_scan=2
eapol_version=1
network={
        ssid="YOUR-SSID-GOES-HERE"
        scan_ssid=1
        mode=0
        proto=WPA2
        pairwise=TKIP
        group=TKIP
        key_mgmt=WPA-PSK
        psk="YOUR-PASSWORD-GOES-HERE"
}
Once the two files have been saved, shut down the raspberry pi and unplug any ethernet cables (if connected). To shutdown type the below into a console:
sudo shutdown -h now
Plug in your WiFi USB dongle of choice, and power up the Raspberry Pi. If you have a monitor attached, you will see the attempts made to connect to a WiFi network. Mine usually connects after about 3 or 4 attempts. The IP address that is assigned is shown during boot up. If you can't see an IP address, log into the Raspberry Pi and type the below to get your IP address:
sudo ifconfig wlan0
To test if you have a connection see if you can ping one of google's servers by typing the below into a console:
ping -c 3 google.com
If it has worked you will have a WiFi connection and will be able to SSH in without a monitor/keyboard/mouse/ethernet cable attached.

沒有留言:

張貼留言