splitbrain.org

electronic brain surgery since 2001

Setting up WPA encryption on Arch Linux

Setup wpa_supplicant

Arch Wiki page

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

network={
	ssid="mynetwork"
	#psk="secret passphrase"
	psk=079d2fae6076188a16502cb87dbe30ad893549ca52c0a837c02bb272bfdccb5f
}

Creating an init script

#!/bin/bash
 
WPA_IF='wlan0'
WPA_ESSID='none'
WPA_IFCFG=''
 
. /etc/rc.conf
. /etc/rc.d/functions
 
case "$1" in
    start)
        if ! ck_daemon network-wpa; then
            echo "WPA Network is already running.  Try 'network restart'"
            exit
        fi
        stat_busy "Starting WPA Network"
 
        # setup wireless interface
        if ! /usr/sbin/iwconfig $WPA_IF essid "$WPA_ESSID" mode Managed; then
            stat_fail
            exit
        fi
 
        # wait for associacion
        /bin/sleep 10
 
        # run wpa_supplicant
        if ! /usr/sbin/wpa_supplicant -B -Dwext -i $WPA_IF -c /etc/wpa_supplicant.conf; then
            stat_fail
            exit
        fi
 
        # bring up interface
        if [ -z "$WPA_IFCFG" ]; then
            if ! /sbin/dhcpcd $WPA_IF; then
                stat_fail
                exit
            fi
        else
            if ! /sbin/ifconfig $WPA_IF $WPA_IFCFG; then
                stat_fail
                exit
            fi
        fi
 
        add_daemon network-wpa
        stat_done
        ;;
    stop)
        stat_busy "Stopping WPA Network"
        killall wpa_supplicant
        /bin/sleep 1
        ifconfig $WPA_IF down
        rm_daemon network-wpa
        stat_done
        ;;
    restart)
        $0 stop
        /bin/sleep 2
        $0 start
        ;;
    hotplug_ifup|ifup|ifdown|iflist|rtup|rtdown|rtlist)
        $1 $2
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"
        echo "       $0 {ifup|ifdown|iflist|rtup|rtdown|rtlist}"
esac

Setup rc.conf

# configure WPA encryption for wireless network
WPA_IF="ath0"
WPA_ESSID="mynetwork"
WPA_IFCFG="192.168.1.15 netmask 255.255.255.0 broadcast 192.168.1.255"
 
# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.1.1"
ROUTES=(gateway)
 
DAEMONS=(syslog-ng hal fam network-wpa network netfs ...)

ifconfig1)

Tags:
arch, linux, wpa, wlan, wifi, wireless
Similar posts:

Comments