Because FLOSS is handy, isn’t it?

WiFi with WPA under Ubuntu/Debian

Posted by isilanes on January 28, 2007

Blog moved to: handyfloss.net

Entry available at: http://handyfloss.net/2007.01/wifi-with-wpa-under-ubuntudebian/

I finally made my new laptop connect with WPA encryption to my WiFi router!!

I could already connect it to WiFi networks with WEP encryption (or no encription at all), but WPA proved harder.

Mini HowTo

1) My setup is the following:

WiFi router: SMC Barricade WBR14-G2
WiFi card in laptop: Intel PRO/Wireles 3945
OS: Ubuntu 6.06 LTS (Dapper Drake)

2) The router settings:

Wireless encryption: WPA/WPA2 Only
Cipher suit: TKIP+AES (WPA/WPA2)
Authentication: Pre-shared Key (yes, I know 802.1X would be more secure… sue me)
Pre-shared key type: Passphrase (8~63 characters)

3) The package one needs to install:

# aptitude install wpasupplicant

4) Making WPA supplicant run:

First, create a config file, by the name /etc/wpa_supplicant.conf, and inside it, write:


  proto=WPA RSN
  pairwise=TKIP CCMP
  group=TKIP CCMP

At that point, you should make sure that the WiFi is turned on, and that the correct driver is loaded. In my case:

# modprobe ipw3945

Then, to test the WPA supplicant, run:

# wpa_supplicant -Dwext -ieth1 -c /etc/wpa_supplicant.conf

Recall I have used the wext device, instead of the ipw one, that would seem the appropriate one. Well, I read somewhere, that with 2.6.16 kernels and newer, this should be the case. Now I recall that my kernel is 2.6.15… nevermind, it works that way, and not the other (with -Dipw).

Recall also that my wireless device is eth1. Your mileage may vary (but each wireless card model gives rise to a precise device name, don’t worry).

If everything went fine, the output for the above command should be something like:

# wpa_supplicant -Dwext -ieth1 -c /etc/wpa_supplicant.conf
Trying to associate with xx:xx:xx:xx:xx:xx (SSID='xxxxxxxx' freq=0 MHz)
CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys
Authentication with 00:00:00:00:00:00 timed out.
Associated with xx:xx:xx:xx:xx:xx
WPA: Key negotiation completed with xx:xx:xx:xx:xx:xx [PTK=CCMP GTK=TKIP]
CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx:xx completed (auth)

If you see that “negotiation completed”, it worked (Ctr-C to exit the above).

5) Automating the WPA connection when bringing wireless interface up

Next, I’ll explain the small changes one has to make to /etc/network/interfaces to correctly bring up the interface. As I said, my wireless interface is eth1, so, I added the lines below to the aforementioned config file:

iface eth1 inet dhcp
wireless-essid my_wireless_essid
pre-up wpa_supplicant -Bw -Dwext -ieth1 -c /etc/wpa_supplicant.conf
post-down killall -q wpa_supplicant

And that’s all! Whenever you ifup eth1, you’ll bring up the wireless interface, with WPA encryption working.


6 Responses to “WiFi with WPA under Ubuntu/Debian”

  1. Iñaki Silanes said

    “[…]ifup eth2
    dosn’t work …. ADDRCONF (NETDEV_UP) link is not ready .
    NO DHCPOFFERS received !”

    Is the router leasing IPs correctly? Does it have DHCP correctly set up and running? The error sounds like the channel your WiFi card is listening to does not give IPs via DHCP. This could happen for various reasons: the router is not properly set up, the card is not listening to the proper channel/SSID, the card is banned from the router (because of encryption, MAC filter…), or the device you are using (eth2) is not the one the card is on.

    Are you sure eth2 is the correct device? In my case, eth0 is the ethernet device, and eth1 the WiFi card. If your card is not Intel, it may appear under another device name (Google for it, plus read output of dmesg in your machine).

    Moreover, can you connect when no encryption is set in your router? Try putting down all security measures in your wireless router. Can you connect like that?

    Try using the commands iwlist, ifconfig and iwconfig. They should tell you about the SSIDs that your computer can “see”, and also about the device your OS assigns to the WiFi card.

    Hope that helps, and sorry if I’m telling you something you already know.

  2. Anonymous said

    Thanks for your answer ……………….
    It works now !


  3. Anonymous said


    I’m having the same problem which I couldn’t solve yet. I tried calling wpa_supplicant, providing the settings in the /etc/networking/interfaces file.
    In 1 out of 10 test I succeed, but I can’t say what I did to make it succeed. I see the message “eth1 link is not ready” and sometimes it says “eth1 link becomes ready”. Could you tell me what you did?

    Thanks in advance,


  4. […] Update: Read a more recent article: WPA under Ubuntu/Debian. […]

  5. Anonymous said

    thank you so much, you saved me hours of trying to figure it out myself. I have wireless with my new router now!

  6. Hi there! Someone in my Facebook group shared this website with us so I came to give it a
    look. I’m definitely loving the information. I’m book-marking and will be tweeting
    this to my followers! Superb blog and excellent style and design.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: