For this howto we will be using the TP-LINK line of USB wireless cards. More precisely the 54Mbps TL-WN321G and the 300M TL-WN821N adapters otherwise known for running the Atheros Communications, Inc. Atheros eXtended Range™ technology. This is an important note because this is how this card will appear under Linux.
I find these adapters at least much cheaper and apparently more reliable to their DLINK counterparts – they just work out of the box with Linux without any install CD's. No drivers necessary as, presumably, the controller chip is registered as Atheros AR9170, for which drivers appear readily available on Linux systems.
For this post, we will assume you have a router and configuration similar to the one described on our page here at Linux / Windows Networking: Configuring and securing a router for Wireless and Wired Networks. In case you run into issues, further reading on resolving them is available from our Windows Networking: The network is not present or not started WIKI or the Linux Networking: device eth0 does not seem to be present, delaying initialization counterpart.
As per the above links, we will be using WPA2-PSK with the AES encryption algorithm. Here are the steps assuming a configuration similar to the above router configuration link:
Check if you have the correct packages installed.
To find out the version of packages under your system type:
# rpm -aq|grep wpa_supplicant
At the time of this writing, the most recent RPM packages available for the Fedora 13 distribution are:
WPA Supplicant is needed for WPA2 wireless keys we will need to use. (WPA2 + AES are the protocols and algorithms we will use.) ifconfig typically comes preinstalled on most Linux systems.
If the packages are not installed, use yum search wpa_supplicant to find the latest package for your distribution. Ubuntu users can use apt-get instead.
|2||Plug in your USB Wireless stick.||
Plug in the USB Wireless stick and use the following command to check if your device has registered with the Kernel/OS:
Record the information. The output will be lengthy.
|3||Identify the properties for your wireless USBstick.||
Before you do so, you may need to run:
# service network restart
Checking /var/log/messages for new USB devices that were recently plugged in is also a good idea. Typically I run:
# tail -f /var/log/messages
to see the changes as I plug in the USB Wireless device. The output can look messy and is similar to this:
Jun 27 14:02:02 localhost kernel: usb 1-2: new high speed USB device using ehci_hcd and address 5
Now run the following to see what name the system has provided the USB Wireless stick:
# ifconfig -a
# ifconfig wlan1 (More often it will be wlan0)
for more details. If the USB Wireless stick is seen, we can proceed to the next step. The next item to do is to run:
# iwlist scanning
to list all available networks in your area (At least one should be listed – yours). Note, some will not have an SSID and if you have followed our router configuration above and prevented SSID broadcasts, the network name will be blank. This is confirmation that your Wireless USB Stick is not only working correctly but also can see other networks in the area.
|4||Create a configuration file for the WAN USB Wireless adapter you identified in STEP 3.||
Create a file for the card with information similar to the following. If your device is named wlan1 use that in the file name ifcfg-<CARD NAME>. (ie ifcfg-wlan0 if your device name is wlan0)
# vi /etc/sysconfig/network-scripts/ifcfg-wlan1
Note also that your IP may be different and you if you prefer to use DHCP, you could set BOOTPROTO=DHCP instead of specifying the rest of the information. The DNS and GATEWAY would be the IP address of your router.
|5||Restart the network service.||
# service network restart
The network device should now be configured with the general settings but you should still not be able to connect wirelessly to your router. For this we will need to setup proper WPA2-PSK + AES authentication below.
|6||Configure WPA Supplicant conf[iguration] file if you don't already have one.||
Next, we will configure the WPA Supplicant config file, if you don't already have one:
# cat /etc/wpa_supplicant/wpa_supplicant.conf
In case you already have the conf file, you should add the items in green to it. This represents the definitions and your credentials for the network you wish to connect with using your Wireless USB Stick.
PSK is the key you choose when configuring your wireless router. It should be private and known by you only.
SSID is the wireless network name under which connections will be made.
IMPORTANT: The above file should have the following permissions (ie accessible to the superuser user ID root):
If you are not already root, you may need to perform the above command through sudo. You can get more information on sudo through man sudo.
|7||Bind WPA Supplicant to the interfaces you will use.||
Next configure WPA Supplicant for the interfaces on which you wish to apply the WPA2 keys and credentials on:
# cat /etc/sysconfig/wpa_supplicant
# Use the flag "-D" before each driver, like so:
# Other arguments
Save the file.
|8||Restart the WPA Supplicant tool.||
Restart the wpa_supplicant service in this manner:
# service wpa_supplicant restart
|9||Ping your router and some external sites to verify that your network is working.||
The command to use is:
# ping 192.168.10.1 (Or what the IP of your router is)
If you ping your router you may receive Destination Host Unreachable messages for a while. After that the ping will work but pinging outside domain names may not work for a few more moments. This is normal, as this delay is often seen early on when the Wireless USB Stick is initialized and connect to a wireless network.
There is a Linux utility called NetworkManager that aims to automate this but unfortunately in my experience this utility left me disconnected far more times then it got me connected even on entirely clean and freshly installed systems. (The utility is not yet fully WPA2 ready as of this writing though presumably success stories do exist.) With my Wireless USB Stick setup to my router configuration, it was something gratifying indeed to watch the FIFA World Cup 2010 Games on my Linux HTPC center.
An alternative to the above that I haven't tried yet is Wicd. Though I haven't tried this utility, presumably it does come recommended.
If you run into issues, the previous article Linux Networking: device eth0 does not seem to be present, delaying initialization has some additional debugging techniques you can use that also apply to WLAN cards.