2009-11-29

WL54USB on Ubuntu Server

Got wireless network running on Ubuntu 9.10 Server, it was even easier than I thought. Here's a small how-to:

Biggest problem was to find a proper wireless adapter. I didn't want deal with `ndiswrapper` or compile any drivers manually, so I had to find something supported by kernel that would work out of the box. Nice place to start from is wireless.kernel.org. Considering driver information there and stuff that is currently available in stores I've finally got an USB-dongle with Atheros chip, namely A-LINK WL54USB.

System I am running is Ubuntu 9.10 Server, minimal install plus OpenSSH. So the first step is to plug in the WiFi stick and check if that is recognized. And -- nothing interesting here, it just works without any setup.

Secondly, wireless interface needs to be configured. If static address is to be used, add the following to `/etc/network/interfaces`:

auto wlan0
iface wlan0 inet static
address 192.168.1.99
netmask 255.255.255.0
gateway 192.168.1.1


Instead, if you plan to use DHCP with wireless interface, use this:

auto wlan0
iface wlan0 inet dhcp


Basic setup completed. Restart networking and test it with some unsecured network:

sudo /etc/init.d/networking restart

# Check if interface is configured properly
sudo ifconfig wlan0

# Search for available networks
sudo iwlist wlan0 scan

# Connect to network
sudo iwconfig wlan0 essid "MyUnsecuredNetworkId"

ping google.com


And now the most interesting part -- getting wireless adapter working with WPA (WPA2 with TKIP/AES in my case). WPA supplicant is nice (if not only) tool to use, and luckily it is already installed by default. If this in not your case, you can install it by clicking here.

There is nice tutorial for ArchLinux, have a look at it first.

It would be a good idea to encode network SSID and password at once, so that WPA supplicant won't do it any time it would connect to a network. In order not to store the password in shell history, run `wpa_passphrase` without the 'password'-argument. You will then be prompted for password:

wpa_passphrase "MySecuredNetworkId"


Then, create a proper `wpa_supplicant.conf` file from output of previous command. Common practice is to use `/etc/wpa_supplicant.conf`, but I prefer keeping it in `/etc/wpa_supplicant/wpa_supplicant.conf`:

network={
ssid="MySecuredNetworkId"
key_mgmt=WPA-PSK
#psk="your secret passphrase"
psk=########
}


Another good idea is to protect WPA supplicant configuration file from being read by anyone except root user:

sudo chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf


Now it is time to test if it's working:

wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf


If `nl80211` driver is not working by some reason, try generic `wext` instead:

wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf


If everything goes fine, stop WPA supplicant with Ctrl+С and modify the interface configuration in `/etc/network/interfaces`:

auto wlan0
# your DHCP or static IP conf described above
wpa-driver nl80211
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf


Restart networking or reboot, and secure wireless connection should be established automagically.

2 comments:

aktivnyjblogger said...

Всем похуй !!1!1

Juri Hudolejev said...

Аццкое SEO. Только по этой фразе псто наверняка поднимется в гуглорезультатах на пару позиций (: