Configuring a Linux WiFi client is not always as easy as with Windows or MAC OS X. In this first post I will show you how to configure your Linux client to associate with an access point. For this example, I use Ubuntu version 8.x. This procedure may vary from one Linux variant to another. The SSID I want to connect to is APN and my WiFi interface is wlan1. Here are the steps for WPA/WPA2 PSK (commands are in boldface):
1. Generate your WPA/WPA2 passphrase
wpa_passphrase APN
# reading passphrase from stdin
yoursecretkey
network={
ssid="APN"
#psk="yoursecretkey"
psk=9ae7a5f631ecc688db8dcc6bbf317b4a551b39e9ee9c20effb5393e342bd954b
}
2. Copy your wpa_passphrase output to /etc/wpa_supplicant/wpa_supplicant.conf
From the above step, it starts with "Network={" and ends with a closing curly brace "}". You may want delete the comment "#psk=yoursecretkey"
3. Enable your wireless interface
ifconfig wlan1 up
4. Scan for existing WLANs or SSIDs
iwlist wlan1 scanning | grep -i essid
ESSID:"BELL078"
ESSID:"APN"
ESSID:"2mix"
You now have a confirmation your target SSID APN is detected.
5. Configure your wireless interface for your specific SSID
iwconfig wlan1 essid APN
6. Start WPA/WPA2 authentication
wpa_supplicant -iwlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf
ioctl[SIOCGIWSCAN]: Resource temporarily unavailable
CTRL-EVENT-SCAN-RESULTS
Trying to associate with 00:25:4b:0a:a3:f5 (SSID='APNSmallBang' freq=2437 MHz)
CTRL-EVENT-SCAN-RESULTS
Associated with 00:25:4b:0a:a3:f5
WPA: Key negotiation completed with 00:25:4b:0a:a3:f5 [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED - Connection to 00:25:4b:0a:a3:f5 completed (auth) [id=0 id_str=]
7. Assign IP address via DHCP
Open a new shell to type the following command:
dhclient wlan1
Internet Systems Consortium DHCP Client V3.1.1
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Listening on LPF/wlan1/00:c0:ca:2f:94:0d
Sending on LPF/wlan1/00:c0:ca:2f:94:0d
Sending on Socket/fallback
DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 3
DHCPOFFER of 172.16.22.5 from 172.16.22.1
DHCPREQUEST of 172.16.22.5 on wlan1 to 255.255.255.255 port 67
DHCPACK of 172.16.22.5 from 172.16.22.1
bound to 172.16.22.5 -- renewal in 33064 seconds.
8. Check if IP address assigned correctly
ifconfig wlan1
wlan1 Link encap:Ethernet HWaddr 00:c0:ca:2f:94:0d
inet addr:172.16.22.5 Bcast:172.16.22.255 Mask:255.255.255.0
inet6 addr: fe80::2c0:caff:fe2f:940d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1092 (1.0 KB) TX bytes:1580 (1.5 KB)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>>>>>>At this point, you should be connected to your AP<<<<<<
>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
In a next post, I will show you how to automate these commands.
Steve,
I always knew there really was a lot going on in the background when I just 'clicked' to join a wireless network. This was good to remind me of all the real things that have to happen in the background.
Also reminded me of why I don't do Linux any more... that is just ridiculous.
Looking forward to the easy version next.
Posted by: KeithRParsons | 2010.03.05 at 17:30
Hi Keith,
Thanks for commenting. Lots of stuff in Linux is not easy. And there are so many distributions, take a look at DistroWatch http://distrowatch.com/. In comparison with MAC OS X by Apple and a few variants of Windows by Microsoft, it is difficult for Linux to be just "Linux". My favorite distro is Ubuntu, which I have been running for 5 years, mainly for security pentests and its excellent syslog-ng service. I am a *nix user since 1992... So it's part of my DNA so to speak.
In all my consulting career, I never came across an enterprise who uses Linux as client platform. I've seen many running Linux as a server platform. The majority of companies use Windows and some will use MACs. To me Linux is more a tool in my arsenal. I like to use the best of both worlds of Linux and Windows. This is why most of my PCs dual boot Win and Lin and sometimes triple boot. Besides, I run VMs both in Win and Lin. Whenever I do lab work and my PC booted in Linux, it's quicker for me to establish a WLAN connection using the directives from my post than rebooting in Windows and click the WLAN tray icon.
Fun fact is that ever since I started in the WiFi business, I noticed that all interesting WiFi commercial products only run in Windows, nothing is available in Linux (idem for MAC OS X). I am referring to AirMagnet and Cisco products. I need these products to do my job, so I need to stay more and more in Windows.
In my next post I will unveil how Ubuntu 9.10 equates Windows as far as establishing a WLAN connection.
Posted by: Steve Williams | 2010.03.05 at 23:12
Hey Steve
If you want an easy linux client, check Linux Mint. I even installed it on my parents laptop and they don't miss windows. Enuff said :)
http://www.linuxmint.com/
Posted by: Mehdi | 2010.03.18 at 08:50
Hi Mehdi,
Thanks for sharing. I never tried Linux Mint before, but I am glad to find out another Linux distribution bundles an easy WiFi client. Ubuntu 9.10 does this as well (plse see part 2 of my post).
However, if you *have to* use a Linux distro that does not offer a Mom & Pop WiFi client, you can rely on the command line, as described herein.
Posted by: Steve Williams | 2010.03.18 at 09:30