Enabling wpa_supplicant without NetworkManager

If you're like me, and you just roam between a few WPA-secured wireless networks, and you want your laptop to connect to the local wireless networks on boot, then here is a simple recipe.

Note that you can use NetworkManager for this, however it doesn't by default connect to a network on boot -- it requires a user to log in and give NetworkManager access to the keyring so that it can retrieve its WPA keys.

This is a recipe for using wpa_supplicant without NetworkManager, and making it connect on boot. It does require editing configuration files so if you're not comfortable with that then you may want to consider NetworkManager instead.

Edit /etc/wpa_supplicant/wpa_supplicant.conf

Most of your networks will require a single entry in wpa_supplicant.conf that looks like this:

network={
        ssid="MYNETWORKSSID"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="MYNETWORKPSK"
}

Obviously you'll want to replace MYNETWORKSSID and MYNETWORKPSK with the SSID and PSK of the network you connect to.

Edit /etc/sysconfig/network-scripts/ifup-wireless

Add the following lines to the end of this file:

if [ "$WPA" = "yes" -a -x /etc/init.d/wpa_supplicant ]; then
    /sbin/service wpa_supplicant start
fi

Edit /etc/sysconfig/network-scripts/ifcfg-*

There will be a number of files in /etc/sysconfig/network-scripts which describe a network, such as ifcfg-eth0 (probably your ethernet network) and one called something like ifcfg-wlan0 or ifcfg-eth1 which describes your wireless.

The one that describes your wireless network will contain the following line:

TYPE=Wireless

Add the following line to the end of this file:

WPA=yes

Edit /etc/rc.d/rc.local

We have now configured wpa_supplicant to start when our wireless network interface starts. Unfortunately the order of script startup with CentOS is incorrect -- it tries to bring up the wireless networks (and hence wpa_supplicant) before DBUS is started, and wpa_supplicant requires DBUS to be running.

The quick and easy solution to this is to add the following line to the end of /etc/rc.d/rc.local, which will start your wireless interface last:

/sbin/ifup eth1

(or /sbin/ifup wlan0 if your wireless interface is wlan0).

This will bring up the wireless interface and also wpa_supplicant at the end of the boot process, after the necessary pre-requisite programs are running.

Disable interface and wpa_supplicant on boot

Because we're starting wpa_supplicant directly in the ifup script of the appropriate network interface there is no need to start it on boot from init. Disable it using:

chkconfig wpa_supplicant off

You can also disable the automatic starting of the wireless network interface (eth1 or wlan0) on boot using the Network Device Control application because we're now starting it manually with the change that we made to rc.local.

HowTos/Laptops/WpaSupplicant (last edited 2009-07-31 04:21:42 by TimothyLee)