Adrian
Courrèges

Ubuntu Dapper, WPA and static IP

If you want to use WPA encryption for your wireless network and connect to it using Ubuntu, there is no particular problem and Network-Manager can be really helpful. No problem… as long as your network is configured to use DHCP! Network-Manager cannot handle (yet?) static IP, and the default networking tool in Dapper just does not understand WPA.

Fortunately WPA-Supplicant can solve this issue. :)

The Network-Manager documentation on Ubuntu website is kind of messy and is likely to repel any beginner. However the configuration is really quick to do and this tutorial should help you set up your connection in less than 2 minutes.

From now on I consider your wireless card is recognized by the system and that you are able to get a wireless connection on a open or WEP-encrypted network.
I am using the following devices: a laptop running Dapper with an Intel IPW2200 wireless card and a WRT54G router.

During the tweaking only 2 configuration files are going to be modified:
/etc/network/interfaces
/etc/wpa_supplicant/wpa_supplicant.conf
But only one will have to be edited manually.

Installation

By default WPA-Supplicant is already installed in Dapper. If you don’t have it you can install it by:

$ sudo apt-get install wpasupplicant

(Universe repositories must be enabled.)

Configuration

Open the default networking tool of Ubuntu (with Gnome: System –> Administration –> Network).

Network tool



Input an SSID and a fake WEP key, and input correct data for all the other fields (static IP, Mask, Gateway address).

Remember also the name of your network interface (here “eth1”) this will be useful for the connection. Apply the settings and close the window.

The file `/etc/network/interfaces` should have been automatically edited. You can check with this command:

$ more /etc/network/interfaces

There should be a section looking like this:

iface eth1 inet static
wireless-essid some_network_name 
wireless-key some_fake_key 
address 192.168.1.107 
netmask 255.255.255.0 
gateway 192.168.1.1

Now we have to edit the WPA-Supplicant configuration file.

$ sudo gedit /etc/wpa_supplicant/wpa_supplicant.conf

Replace its content by:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1
fast_reauth=1

network={ 
    ssid="my_wpa_network_ssid"
    proto=WPA RSN
    key_mgmt=WPA-PSK 
    psk="my_secret_wpa_key" 
} 

With of course the name of your network and the WPA key in clear text.

Connexion

To enable the connection, type the following command:

$ sudo wpa_supplicant -w -D wext -i eth1 -c /etc/wpa_supplicant/wpa_supplicant.conf

(It might be necessary to adapt “eth1” to your interface.)
If you get something like this:

Trying to associate with 00:13:10:**:**:** (SSID='My Network' freq=0 MHz) 
Associated with 00:13:10:**:**:** 
WPA: Key negotiation completed with 00:13:10:**:**:** [PTK=TKIP GTK=TKIP] 
CTRL-EVENT-CONNECTED - Connection to 00:13:10:**:**:** completed (auth)

Then you should be done, congratulations! You can try to ping the router as a test (and probably add the addresses of some DNS servers if the name resolution fails).

So here I tried to present a simple and quick method to connect to a WPA network using static IP. It worked really great but I cannot guarantee it will also be fine for you. I would like to remind that all the tweaking has been done with Dapper, the more recent versions like Feisty already have Network-Manager installed by default as well as Avahi-Daemon that might interfere with WPA-Supplicant. (You can try to disable them if you encounter any problem.)

This method is useful if you really need static IP mode with old routers. Nowadays most of the routers are able to provide a static IP to an host in DHCP mode (the host is recognized based on its MAC address).

Comments