From ArchWiki
Revision as of 21:01, 18 March 2010 by Brain0 (Talk | contribs) (Autowifi deprecation: Fix message (oops))

Jump to: navigation, search


Autowifi is a daemon that configures your wireless network automatically depending on the ESSID. Once configured, no user interaction is necessary and no GUI tools are required.

The idea

wpa_supplicant is a very powerful tool. It scans for wireless networks automatically and associates with the network that has the best quality and security settings (note: despite its name, it works with WPA, WEP, and open networks). However, wpa_supplicant doesn't automatically configure the interface parameters once it has associated, requiring user interaction everytime.

The idea of autowifi is to fill that gap: It connects to a running wpa_supplicant and takes care of interface configuration with dhcp, static ip addresses or custom post-up and post-down scripts.

Requirements and installation

To use autowifi, you need

  • a wifi driver that is supported by wpa_supplicant (like the ipw* drivers, madwifi, rt2x00 or even ndiswrapper)
  • wpa_supplicant
  • dhclient (if you want to use dhcp)

The above are available easily via pacman.

You can install autowifi by getting a package from and installing it with pacman.


Configuring wpa_supplicant

For autowifi to work, you have to configure wpa_supplicant.

These options should be present in /etc/wpa_supplicant.conf

# general options
# Don't change this path to something else:
# Give everyone in the group "users" access to the control interface
# required if you want to dynamically configure the network via wpa_cli or wpa_gui without being root

For certain drivers, you may need to instead use ap_scan=0 to get wpa_supplicant to work properly, the default configuration file includes some information on that topic.

Now, you need to add a network block for each network you usually use. You can add a priority= option to each of them if you prefer one network over another.

An open network:


Connect to any open network in range (this does not work with every driver):


A WEP-encrypted network:

  # Add this option for "shared" wep mode

A WPA-secured network (prefer WPA2 over WPA if possible):

  proto=RSN WPA
  # ASCII passphrase.
  psk="very secure passphrase"
  # If you have a 64 digit hex passphrase, specify it like this:

This is just a short overview; a more complete description of all options and possibilities can be found in the wpa_supplicant default configuration file.

Configuring autowifi

Now autowifi has to be configured. First we set the startup parameters in /etc/conf.d/autowifi:


Then, we configure the autowifi profiles. We begin with the default profile in /etc/autowifi/networks/default:

# This is the default profile
# It is used when no other profile is matched
# For a description, see the "example" profile

This is a pretty good setting, as most people will have dhcp enabled. Most users won't have to configure anything else.

Advanced configuration

In the file /etc/autowifi/regexp you can use regular expressions to map several ESSIDs to the same profile name:

# This file contains lines of the format
#   profile regex
# If the current SSID matches "regex", then the
# profile "profile" is used.
# Empty lines and lines starting with # are ignored.

mynet somenetregexp[0-9] .*

The above setting means that every ESSID that matches the regular expression "somenetregexp[0-9] .*" will use the profile name mynet.

The profile name is determined like this:

  • If the ESSID matches one or more regular expressions in the regexp file, the profile name of the first matched expression is used.
  • If the ESSID doesn't match any of the regular expressions, the ESSID itself is used as the profile name.

If the file /etc/autowifi/networks/profilename exists, it is used, otherwise /etc/autowifi/networks/default is used. Here are some examples for autowifi profiles:

Static IP address:


Use dhcp and a custom post-up script:


autowifi_connect() {
autowifi_disconnect() {
  killall something_cool

If NETWORK="custom" is specified, only the autowifi_connect() and autowifi_disconnect() scripts are executed, no further configuration is done.

Running autowifi

To start autowifi, run

/etc/rc.d/autowifi start

If you want to start it at boot, add it to rc.conf.

You can add more networks dynamically while wpa_supplicant is running using the wpa_gui (package wpa_supplicant_gui) or wpa_cli tools. If you change the wpa_supplicant.conf file while wpa_supplicant is running, run wpa_cli reconfigure for the new configuration to take effect.