wpa-supplicant-service

Eloi Primaux eloi at bliscat.org
Thu Mar 16 13:54:54 PST 2006


AUTHOR: Eloi Primaux eloi AT bliscat dot org

DATE: 2006-02-19

LICENSE: GNU Free Documentation License Version 2

SYNOPSIS: A way to set wifi interface up with wpa_supplicant
during boot time

DESCRIPTION:
This hint follow the way of how network lfs's services are built to
create an wpa-supplicant network service
which is able to read wpa_supplicant.conf file format to set wifi
interface up during system boot process


ATTACHMENTS:
http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-supplicant-service/wpa-supplicant.service
http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-supplicant-service/wpa-supplicant.configfile
http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-supplicant-service/wpa-supplicant.initscript
http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-supplicant-service/wpa-supplicant.configfile

not needed but could be useful for debugging
http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-supplicant-service/wpa-supplicant-old.service

PREREQUISITES:
You will need a fully well configured LFS-6.1 (at least) system
you will also need to read this hint:
http://www.linuxfromscratch.org/hints/downloads/files/wireless.txt
Thus you need :
        1 ==> The driver(s) of your wireless interface
(http://madwifi.org/wiki
for Atheros chipsets (some NETGEAR use it))
        2 ==> The "wireless tools" (needed sometimes if not released
with your
driver(s))
        3 ==> The "wpa_supplicant" program (which is a daemon plus an
ui)
version 0.4.8 required (0.4.7 hangs up too much time)

note those three requested programs/drivers can easily be installed
using their README files and wikis
please read the documentation of wpa_supplicant to know how to define a
network

HINT:
This hint is the second release and it should be used instead of
"Setting a wireless network with WPA and dhcpcd"
which is obsolete and completely bugged (thanks to myself...)

First of all, create the following files

The wpa_supplicant boot-script (attached file wpa-supplicant.initscript,
rename it to wpa-supplicant)

        cpy it to /etc/rc.d/init.d
        make it executable chmod 755 /etc/rc.d/init.d/wpa_supplicant
        link it to your desired init level
        example :
        ln
-s /etc/rc.d/init.d/wpa_supplicant /etc/rc.d/rc3.d/S15wpa_supplicant
(network is K20)
        ln
-s /etc/rc.d/init.d/wpa_supplicant /etc/rc.d/rc5.d/S15wpa_supplicant
(network is K20)
        ln
-s /etc/rc.d/init.d/wpa_supplicant /etc/rc.d/rc0.d/K75wpa_supplicant
(network is K80 for me)
        ln
-s /etc/rc.d/init.d/wpa_supplicant /etc/rc.d/rc6.d/K65wpa_supplicant
(network is K60 for me)



The wpa_supplicant service file (attached file wpa-supplicant.service,
rename it to wpa-supplicant)

        copy it to /etc/sysconfig/network-devices/services
        make it executable chmod
755 /etc/sysconfig/network-devices/services/wpa_supplicant


And now the network config file: named wpa_supplicant

        in /etc/sysconfig/network-devices/ifconfig.DEVICE where DEVICE
is your
device name (like ath0,eth1,wlan1,2..)

example : /etc/sysconfig/network-devices/ifconfig.ath0/wpa_supplicant


And then, the wpa_supplicant file: 

        according to the file created above it should be in the
$WPA_CONFIG_DIR
        and named $WPA_CONFIG_FILE

        example /etc/sysconfig/wpa_supplicant/wpa_supplicant.conf


Since i've been asked on, i written a method to help to configure this
file:

launch the wpa-supplicant daemon :

/etc/rc.d/init.d/wpa_supplicant start
source /etc/sysconfig/network-device/eth0/wpa-supplicant
$WPA_CLIENT_NAME -g$WPA_GLOBAL_FILE interface_add eth0 "" $WPA_DRIVER \
$WPA_GLOBAL_DIR

this will create your interface
and now you will use wpa_cli to scan your network
do :
wpa_cli -ieth0

you will be in the wpa_cli program
then type
scan
and after some seconds type
scan_result


here is my ouput:

root at bliscat:/home/eloi# wpa_cli
wpa_cli v0.4.8
Copyright (c) 2004-2005, Jouni Malinen <jkmaline at cc.hut.fi> and
contributors

This program is free software. You can distribute it and/or modify it
under the terms of the GNU General Public License version 2.

Alternatively, this software may be distributed under the terms of the
BSD license. See README and COPYING for more details.


Selected interface 'ath0'

Interactive mode

> scan
OK
> scan_result
bssid / frequency / signal level / flags / ssid
00:0f:b5:ee:af:8f       2437    212     [WPA2-PSK-CCMP-preauth] MY_net
00:10:c6:eb:95:11       2457    205     [WEP]   Wanadoo_5441


you can see that my network 'My_net' use WPA2 PSK CCMP which is WPA-PSK
with CCMP as group and pair

type exit to quit wpa_cli



# Begin wpa_supplicant configuration file
# it's just an example but all information are in wpa_supplicant README,
read it please
network={
        ctrl_interface=/var/run/wpa_supplicant
        ssid='"ESSID"' # please quote '""' when you have a space
character
        scan_ssid=1
        key_mgmt=WPA-PSK
        proto=WPA2
        pairwise=CCMP
        group=CCMP
        psk='"Your password"' # please quote '""' when you have a space
character
}
# End of wpa_supplicant configuration file




Because you read all these lines, i'm gonna give you the "little bugged"
debug version
but it is fully usable (I've set my network with it)



ACKNOWLEDGMENTS:
 the wireless hint (very well written compare to mine)
 wpa_supplicant http://hostap.epitest.fi/wpa_supplicant
 madwifi wiki http://madwifi.org/
 and more and more
        thanks to everyone i read to set up my wireless network


CHANGELOG:
2006 03 10 Second release, first send to lfshint
2006 03 16 added some words to help wpa-supplicant.conf writing
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wpa_supplicant.initscript
Type: application/x-shellscript
Size: 1922 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hints/attachments/20060316/c29f49a2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wpa_supplicant.service
Type: application/x-shellscript
Size: 3473 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hints/attachments/20060316/c29f49a2/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wpa_supplicant-old.service
Type: application/x-shellscript
Size: 4500 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hints/attachments/20060316/c29f49a2/attachment-0002.bin>
-------------- next part --------------
ONBOOT="yes"
SERVICE="wpa_supplicant"

# the ip settings (note: only the debug version will print something)
        IP_SERVICE_NAME="dhcpcd" # or ipv4-static ... copy their conf
here
        DHCP_START="-d "
        DHCP_STOP="-k "
        # Set PRINTIP="yes" to have the script print
        # the DHCP assigned IP address
        PRINTIP="no"
        # Set PRINTALL="yes" to print the DHCP assigned values for
        # IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
        PRINTALL="no"

# The wpa settings

        #the name of the wpa_supplicant client if it changes
        WPA_CLIENT_NAME="wpa_cli"
        # here is the directory where wpa_supplicant.conf should be
        WPA_CONFIG_DIR="/etc/sysconfig/wpa_supplicant"
        # here is the name of your wpa_supplicant.conf file
        WPA_CONFIG_FILE="wpa_supplicant.conf"

# Here you have to define which wpa driver wpa_supplicant will use for
this interface
        WPA_DRIVER="madwifi"

# To avoid boot freezing on this service (truly true with the debug
version)
# one cycle each 5 seconds
        WPA_MAXCYCLE=10


More information about the hints mailing list