Quickly setup multiple wifi connections on your raspberry pi through the command line
Step by step guide showing you how to setup your wireless connection if you only have access to the terminal and not the desktop. Setting it up using just the /etc/network/interfaces files can work but you will run into issues when you need multiple connections or if you ever do access the desktop environment. Setting it up using wpa supplicant will be more reliable in the long run.
Step 1. You can find compatible WiFi adapters http://elinux.org/RPi_USB_Wi-Fi_Adapters, not all USB adapters will work reliably, and a separate powered USB hub is usually recommended.
Step 2. Login to the pi (Login: pi Pass: raspberry)
Step 3. View the file /etc/network/interfaces
cat /etc/network/interfaces
Confirm you have the following lines added in that file (you may other interface information listed as well which can be ignored for now)
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
Step 4. If you do not have those lines, open up an editor and add them in
sudo nano /etc/network/interfaces
Step 5. Edit the file /etc/wpa_supplicant/wpa_supplicant.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
and add the following code (by default this file should be empty, if you have previously added a connection you can choose to delete it as well)
ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 update_config=1
# Example Open
network = { ssid = "linksys"
scan_ssid=1 key_mgmt = NONE }
# Example WEP network={ ssid="linksys"
scan_ssid=1 key_mgmt=NONE wep_key0="LINKSYSWEPKEY" } # Example WPA network={ ssid="linksys"
scan_ssid=1 key_mgmt=WPA-PSK psk="LINKSYSWPAKEY" } # Example WPA2 network={ ssid="linksys"
scan_ssid=1 proto=RSN key_mgmt=WPA-PSK psk="LINKSYS_RSN_KEY" }
Step 6. Change the above values to match you wireless network, the fields are further explained below.
Step 7. Reload the Wifi interface to connect to your network (You may need to reboot without the ethernet cable connected in order for the wifi have internet access)
sudo ifdown wlan0
sudo ifup wlan0
You can add as many networks as you want (network={ }) or delete networks. The above settings should work for your standard home or public guest networks, there are more advanced items you can add for corporate environments using certificates etc. You can find more information here http://hostap.epitest.fi/cgit/hostap/plain/wpa_supplicant/README or issue the command inside the terminal man wpa_supplicant
Here are the basic items that can be included inside of network={}
Variable | Definition | Example |
ssid | The name of your wifi network | ssid="2wire098" or ssid="linksys" |
scan_ssid | Set to 1 for hidden SSIDs or 0 if they broadcast the SSID. | scan_ssid=1 |
key_mgmt | WPA-PSK (Standard WPA for home networks) or NONE for open or WEP networks | key_mgmt=WPA-PSK |
psk | WPA passphrase, leave out for open or WEP networks | psk="MyWPAWifiPass" |
proto | WPA or WPA2 protocal, only needed for WPA2 networks as it defaults to WPA if not included. | proto=RSN |
wep_key0..3 | Static WEP key (ASCII in double quotation, e.g. "abcde" or hex without quotation, e.g., 0102030405) | wep_key0="MYWIFIPASS" |
Comments
browsing your blog posts. After all I'll be subscribing for your rss feed and I am hoping you write again very soon!
Also visit my web-site - กระเป๋ากล้อง: http://www.inc-camera.com
http://www.cnetsys.com/michigan-it-services-and-computer-repair-shop-contact-us/it-and-computer-repair-service-areas/lapeer-computer-repair-network-server-and-it-support-services/
RSS feed for comments to this post