Sunday, April 29, 2007

Getting Feisty With the Network

When we last left our installation of Ubuntu 7.04 (Feisty Fawn) on Hal's Evil Twin, we had everything in place — except wireless networking, a rather important omission since Spouse refuses to let me string an umbilical cord through the house. (It's only 20 feet!)

Now the Fawn has what is supposed to be excellent support for out-of-the box wireless, through something called Network-Manager, which is supposed to “effortlessly switch networks.” Well that's all right, even though HsET is permanently (I hope) connected to one network, all of the time.

And the initial results were encouraging. On installation, Feisty immediately found my DLink DWL-G510 wireless card, and told me it was going to use a Restricted (meaning third-party binary) driver to talk to it, if that was OK with me. Having no other choice to get on the Internet with HsET, I said yes, offering a silent prayer to RMS for, if not forgiveness, at least understanding.

I entered the network information: SSID, WPA-PSK (or Personal) security, passphrase, and click OK. A little arrow started chasing its tail, and eventually stopped. I opened Firefox, and headed off to GoogleTM.

Nothing. Open a terminal window, enter:

No response.

Obviously nothing's working.

So I went online with the Mac, which does do wireless out of the box, and started searching Ubuntu Forums. It immediately became apparent that Network-Manager didn't handle WPA, in particular WPA-PSK mode, security all that well.

So I a sulked for awhile, and then went hunting for a solution. I found it in bits and pieces all over the forum, mostly written for previous versions of Ubuntu, but still useful. The best help was from the Ubuntu Forum and the Ubuntu Guide, some of which was originally written for static IP addresses, but with information about DHCP connections as well. I'll write out the steps I used here, but for further reference you should really go back to the original thread.

  1. First, get rid of network-manager and network-manager-gnome. I used synaptic, but you should also be able to do it with
    $ sudo dpkg -r network-manager network-manager-gnome
    This shouldn't be necessary, but I found no way to just turn off network-manager, even from within Gnome. There must be a way, since that's standard Unix/Linux practice, but I couldn't find it, so I just chucked the software out the window.
  2. Install the wpasupplicant package:
    $ sudo apt-get install wpasupplicant
  3. Open up a terminal window. Just about everything from now on will be done in this terminal window.
  4. Get your WPA identity string. Suppose your Networks SSID is "Our_House," and your pass phrase is "Two cats in the yard." Then run
    $ wpa_passphrase "Our_House" "Two cats in the yard." network={
    #psk="Two cats in the yard."

    Note that psk is the actual WPA password for your router. Save this output somewhere for the moment.
  5. Create the file /etc/wpa_supplicant.conf. I use
    $ sudo vi /etc/wpa_supplicant.conf
    but you can use whatever editor you wish, as long as you run it with sudo. Your final file should look like this:
            proto=WPA RSN
            pairwise=CCMP TKIP
            group=CCMP TKIP

    where obviously you replace Our_House and the psk string with the appropriate values for your network.
  6. Now we need to edit (again with sudo) the file /etc/network/interfaces to tell it about the card. Looking around the web, I find that the DWL-G510 uses the Atheros chip-set and the madwifi driver. So edit /etc/network/interfaces so that it reads the lines near the string auto ath0 read:
    auto ath0
    iface ath0 inet dhcp
    pre-up wpa_supplicant -Bw -Dmadwifi -iath0 -c/etc/wpa_supplicant.conf
    post-down killall -q wpa_supplicant
    (no, that last line doesn't have a “-9,” it is, indeed “-q”)
  7. Now we want this to run at startup. Note that you do not want to do this with a laptop, because you don't necessarily know which network you are going to connect to. Create a file /etc/init.d/ with the following content:
    #! /bin/sh
    echo "* [WiFi]: Enabling WPA Supplicant ..."
    if [ -x /sbin/wpa_supplicant ]; then
    /sbin/wpa_supplicant -B -Dmadwifi -iath0 -c/etc/wpa_supplicant.conf -w
    exit 0
  8. Make sure the files you create are world readable, and that the last one is executable:
    $ sudo chmod +r /etc/wpa_supplicant.conf
    $ sudo chmod +rx /etc/initd/
  9. To get to start during the boot requires us to get it into the list of files in /etc/rcS.d. If you list the directory:
    $ ls -1 /etc/rcS.d/
    the scripts will execute in the order they appear on the screen. We want WiFi to start just before the networking file S40networking, and this command pretty much guarantees it:
    sudo ln -s /etc/init.d/ /etc/rcS.d/S40netwifiwpa
    Your mileage may vary, in which case you might have to change the name "S40netwifiwpa" to make it appear just before "S40networking."
  10. Reboot, and log on. Your internet connection should be established, e.g.:
    $ ping
    PING ( 56(84) bytes of data.
    64 bytes from ( icmp_seq=1 ttl=243 time=11.4 ms
    64 bytes from ( icmp_seq=2 ttl=243 time=13.4 ms
    64 bytes from ( icmp_seq=3 ttl=243 time=14.3 ms
  11. You should be able to get the network running again with stop and start commands, but I haven't tried to find the appropriate sequence.

So far (three hours, two reboots) the network has been just fine, but there may be problems ahead. If so, I'll report them. I'd also appreciate any feedback from those who've tried this themselves.


Anonymous said...

My Friend, thanks for the help this provides. I'd bought an Atheros based card thinking that was half the battle and then ran into the WPA issue. Now works like a charm! Many thanks!!