Thursday, October 22, 2009

Don't need KDE4 Network Manager now

How I configured wpa_supplicant for my home network. The router is a Linksys, the wireless security is configured for WPA Personal using the TKIP algorithm. I'm running Ubuntu 9.04 on an IBM Thinkpad T60p. This entry is not about how to configure the wireless card, so I won't describe the hardware any further.

First, see if wpa_supplicant is already running. If it's running with the -u option, then get rid of that daemon because it will interfere with running wpa_supplicant manually. I mucked around /etc and modified or renamed the following files or directories until wpa_supplicant no longer started up after a reboot:
  • /etc/wpa_supplicant (renamed it)
  • /etc/rc*.d/*wpa_ifupdown (renamed them)
  • /etc/dbus-1/system.d/wpa_supplicant.conf (renamed it)
  • /etc/readahead/boot (remove the wpa_supplicant entry)
I don't have the time to go back and figure out exactly which one of those did the trick, so if you have any more information feel free to share it in the comments.

Next, create /etc/wpa_supplicant.conf. Here is mine, without the secret information:
ctrl_interface=/var/run/wpa_supplicant

network={
ssid="home_network_ssid"
scan_ssid=0
key_mgmt=WPA-PSK
pairwise=TKIP
psk=secret_psk_code_from_wpa_passphrase
# or: psk="home_network_psk_secret"
}
Use wpa_passphrase to generate the psk code. There are many other ways to configure wpa_supplicant, this is just what worked for me. Make sure the configuration file can only be read by root.

Once the configuration file has been created, run wpa_supplicant:
sudo wpa_supplicant -c /etc/wpa_supplicant.conf -i wlan0
Add -B to run it in the background.

At this point, iwconfig wlan0 should show sensible values for the ESSID and access point
wlan0     IEEE 802.11abg  ESSID:"home_network_ssid"
Mode:Managed Frequency:2.437 GHz Access Point: 00:1E:E5:85:F8:23
Bit Rate=54 Mb/s Tx-Power=15 dBm
Retry min limit:7 RTS thr:off Fragment thr=2352 B
Power Management:off
Link Quality=88/100 Signal level:-44 dBm Noise level=-86 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
If not, you need to reconfigure /etc/wpa_supplicant.conf and restart wpa_supplicant. If the output of iwconfig shows that wlan0 is now associated with the network, then use dhclient to get an IP address (assuming you are using DHCP):
sudo dhclient -1 wlan0
Note that's a "1" (number one) and not a "l" (letter el). If that is successful then ifconfig wlan0 should show an ip address:
wlan0 Link encap:Ethernet HWaddr 00:13:02:20:31:a7
inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::213:2ff:fe20:31a7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16236 errors:0 dropped:0 overruns:0 frame:0
TX packets:12213 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9357389 (9.3 MB) TX bytes:2011051 (2.0 MB)
and "route -n" should show something like this:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0

No comments: