Sunday, December 9, 2007

Starting a wireless interface properly

I added WPA-PSK to my router recently (the wireless connection has been open up to now) and that immediately caused problems because my Linux laptop (running FC6) didn't want to play nice. My shiny new MacBook had no problems (no surprise there).

After some rummaging around, I found that I needed to start wpa_supplicant so I tried that using the init script but had no success. After some more poking, I edited
  1. /etc/wpa_supplicant/wpa_supplicant.conf (to set the passphrase generated by wpa_passphrase)
  2. /etc/sysconfig/wpa_supplicant (to change the default driver from ndiswrapper to wext
and created ifup-pre-local and ifdown-pre-local to start and stop wpa_supplicant respectively. These get called from /sbin/ifup and /sbin/ifdown and can be contain anything you want run before bringing up the wireless connection. Mine look like this:

#!/bin/bash

. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. ./network-functions

. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. ./network-functions

CONFIG=`echo ${1} | cut -d- -f2`

need_config ${CONFIG}

source_config

if [ "${TYPE}" = "Wireless" ]
then
/etc/init.d/wpa_supplicant restart
fi

Presto! My wireless interface now comes up just like it should!
Now I have to figure how to setup wpa-supplicant for when I am away from my home network..

No comments: