1 AUTHOR: Eloi Primaux eloi AT bliscat dot org
5 LICENSE: GNU Free Documentation License Version 2
7 SYNOPSIS: Setting up a wifi interface using wpa_supplicant and LFS IP
11 http://www.bliscat.org/bliscat/hints/wpa-service/wpa-service-0.24.1.tar.bz2
14 This hint explains how to set a network service using wpa_supplicant
17 http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/wpa-service/wpa-service-0.24.1.tar.bz2
21 - A working LFS-6.2 system or newer with wireless capabilities
22 - Almost two networks services like ipv4-static/dhcpcd installed
23 - wpa_supplicant (>=0.5.7) and wireless drivers
27 0) Requirement and Optional tools
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 0.a) wpa_supplicant 'The core'
31 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 This is NOT an usual step if you omit something here you won't be able to attach
33 your device to any access point
35 Please use the 0.5.7 version or newer, available at:
36 link: http://hostap.epitest.fi/wpa_supplicant
38 Again, i strongly recommend you to read its README before doing anything.
39 wpa_supplicant may need the source of your drivers then edit the .config file
40 as described in the README and set all constants according to your system.
41 Also when ready install it by executing :
49 "wpa-service is a back-end lfs-like service using the front-end wpa_cli of
50 (breath here) the back-end componment wpa_supplicant on lfs based systems"
51 but this, nobody cares...
55 1.1) Install Files and Directories (this is only a proposal)
56 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57 Extract wpa-service-0.24.tar.bz2 and in the extracted directory and run the
62 install -dv -m 700 /etc/sysconfig/network.d
63 install -dv /etc/sysconfig/wpa-service
64 install -dv /etc/sysconfig/network-devices/services
65 install -dv /usr/share/doc/wpa-service
67 touch /etc/sysconfig/network.d/netkey
68 chmod -v 600 /etc/sysconfig/wpa-service/netkey
69 install -v -m644 wpa-service-conf /etc/sysconfig/wpa-service/wpa-service.conf
70 install -v -m754 wpa-action-script /etc/sysconfig/wpa-service/wpa-actions
71 install -v -m644 wpa-service.txt /usr/share/doc/wpa-service
72 install -v -m644 wpa-service-iface /usr/share/doc/wpa-service
73 install -v -m755 wpa-service /etc/sysconfig/network-devices/services
75 install -m755 wpa-service-rcscript /etc/rc.d/init.d/wpa-service
76 ln -nsf /etc/rc.d/init.d/wpa-service /etc/rc.d/rc3.d/S15wpa-service
77 ln -nsf /etc/rc.d/init.d/wpa-service /etc/rc.d/rc5.d/S15wpa-service
78 ln -nsf /etc/rc.d/init.d/wpa-service /etc/rc.d/rc6.d/K85wpa-service
79 ln -nsf /etc/rc.d/init.d/wpa-service /etc/rc.d/rc0.d/K85wpa-service
81 install -d /etc/sysconfig/network-devices/ifconfig.<IFACE>
82 install -v -m644 wpa-service-iface \
83 /etc/sysconfig/network-devices/ifconfig.<IFACE>/wpa-service
85 where <IFACE> is your interface
87 OPTION 2: same as above but in a script
93 Network configuration go in the wpa-service-iface
94 which is located at /etc/sysconfig/network-device/ifconfig.<IFACE>/wpa-service
96 WPA/WEP keys go in netkey
97 which is located at /etc/sysconfig/network.d/netkey
100 2.1) Network configurations (IP):
101 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103 wpa-service can set up your network according to it's SSID, this means
104 that if the SSID "DHCP network" manage ip via a dhcp server, wpa-service will
105 use the SSID file descriptor to set up you network when connecting to the SSID
108 Those ssid descriptors are named with the name of the SSID they describe,
109 and took place in the /etc/sysconfig/network.d directory.
111 The "AzErTy" SSID descriptor will be /etc/sysconfig/network.d/AzeRtY
113 2.1.1) SSID descriptor syntax:
114 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116 An SSID descriptor is a regular network configuration file as used in LFS BOOK.
117 it means that if SSID "IPV4" use ipv4-static, the the descriptor "IPV4" will be
119 cat > /etc/sysconfig/network.d/IPV4 << "EOF"
125 BROADCAST=192.168.1.255
128 and if the "DHCP" SSID use dhcp :
130 cat > /etc/sysconfig/network.d/DHCP << "EOF"
135 # the '-o' prevent your interface being destroyed by dhcpcd
137 # Set PRINTIP="yes" to have the script print
138 # the DHCP assigned IP address
141 # Set PRINTALL="yes" to print the DHCP assigned values for
142 # IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
146 for convenience, wpa_actions fall back to /etc/sysconfig/network.d/AUTO when
147 no SSID descriptor is available.
149 Then install a common/automatic network configuration:
152 cat > /etc/sysconfig/network.d/AUTO << "EOF"
157 # the '-o' prevent your interface being destroyed by dhcpcd
159 # Set PRINTIP="yes" to have the script print
160 # the DHCP assigned IP address
163 # Set PRINTALL="yes" to print the DHCP assigned values for
164 # IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
168 3) The netkey file (The network keys description)
169 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171 This file was previously named wpa_supplicant.conf
172 but because i will only use it to store WPA/WEP key, i renamed it netkey and
173 moved it to /etc/sysconfig/network.d/netkey
175 The wpa_supplicant README and wiki explain the composition of this file.
177 The file syntax is the wpa_supplicant.conf file syntax, it is specific
178 to the wpa_supplicant program and only depends of the programmer choice, thus
179 instead of explaining you of how this file is read, i will show you a set of
180 command to create a config file with wpa_supplicant.
182 in a bash shell execute:
184 wpa_passphrase <ssid> [passphrase] >> /etc/sysconfig/network.d/netkey
186 Where <ssid> is the name of the access point and where [pasphrase] is
190 Now edit the newly created netkey file:
191 Which should contains something similar to:
196 psk=2b1d17284c5410ee5eaae7151290e9744af2182b0eb8af20dd4ebb415928f726
199 You will directly see that you can define more than one network in this
200 file, that's why wpa_supplicant is very nice: it chooses automatically in its
201 configuration file the best (aka secure and available) network to connect.
203 4) Geting over troubles (and tunning your network)
204 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
206 open a new console and launch in the foreground wpa_supplicant in debug
209 wpa_supplicant -g/var/run/wpa_supplicant-global \
210 -P/var/run/wpa_supplicant.pid -ddd
212 this will make wpa_supplicant to output anything to us.
214 Now start the wpa_cli in another console:
216 wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan[X]
218 /var/run/wpa_supplicant
220 Where wlan[X] is the device name of your network interface and where
222 the name of your driver
225 wpa_cli -g/var/run/wpa_supplicant-global interface_add ath0 "" madwifi \
226 /var/run/wpa_supplicant
227 wpa_cli -g/var/run/wpa_supplicant-global interface_add eth1 "" wext \
228 /var/run/wpa_supplicant
230 if it fail, please have a look to the output of the wpa_supplicant
233 wpa_cli -iwlan[X] -p/var/run/wpa_supplicant
235 Then in wpa_cli type :
239 and after some seconds type
243 This will output a list of available networks.
247 root at bliscat:/home/eloi# wpa_cli -iath0 -p/var/run/wpa_supplicant
249 Copyright (c) 2004-2005, Jouni Malinen <jkmaline at cc.hut.fi> and
252 This program is free software. You can distribute it and/or modify it
253 under the terms of the GNU General Public License version 2.
255 Alternatively, this software may be distributed under the terms of the
256 BSD license. See README and COPYING for more details.
259 Selected interface 'ath0'
266 bssid / frequency / signal level / flags / ssid
267 00:0f:b5:ee:af:8f 2437 212 [WPA2-PSK-CCMP-preauth] MY_net
268 00:10:c6:eb:95:11 2457 205 [WEP] Wanadoo_5441
271 you can see that my network 'My_net' use WPA2-PSK-CCMP which is WPA-PSK
272 with CCMP as group and pairwise
274 type exit to quit wpa_cli
277 With this output we can now feed the netkey file:
286 psk=2b1d17284c54aeaeeaae7151290e9744af2182b0eb8af20dd4ebb415928f726
290 Note if you wish you can only use the human readable pass-phrase,
291 then comment it out and comment the hexadecimal pass-phrase
293 Now kill the last instance of the wpa_supplicant daemon :
295 killall wpa_supplicant
297 And test your new configuration file:
299 wpa_supplicant -d[driver] -iwlan[X] -c[configfile] -dd
302 wpa_supplicant -dmadwifi -iath0 -c./netkey -dd
304 If you see something like SUCCESS it's done, kill it again and copy the
306 file to a secure directory:
308 install -d /etc/sysconfig/network.d
309 chmod 700 -v /etc/sysconfig/network.d
310 cp netkey /etc/sysconfig/network.d
311 chmod 600 -v /etc/sysconfig/network.d/netkey
318 /etc/rc.d/init.d/network stop
319 /etc/rc.d./init.d/wpa-service restart
320 /etc/rc.d/init.d/network start
322 if there is no errors, and your system is connected, then you can safely
324 your computer to see it setting up your wireless card during boot time.
329 wpa_supplicant README
335 2006 03 10 Second release, first send to lfshint
336 2006 03 16 added some words to help wpa_supplicant.conf writing
337 2006 03 18 fix wrong paths
338 2006 03 31 Rewritten and try to match the LFS-standard thank's to
340 2006 04 01 fix incomplete find commands
341 2006 10 15 wpa-service 0.2
342 2006 02 14 some typo fix in scripts, removed ifplugd support, and
344 2007 03 27 Typo fix, ssid descriptors moved to /etc/sysconfig/network.d
345 this modifiy wpa_actions and wpa_service.conf
346 NETWORKDIR and SERVICESDIR moved to wpa_service.conf
347 version increment to 0.22
348 2007 03 27 added missing installation of wpa-service.conf file
349 rename wpa_service.conf to wpa-service.conf
350 this modify all scripts and the core service script
351 remove line dealing with the install of an ifplugd script
352 version increment to 0.23
353 2007 06 14 wpa_supplicant.conf renamed to netkey and moved to network.d
354 netkey chmoded to 600
355 wpa-service and network.d to 700
356 wpa-rcscript: renamed to wpa-service-rcscript
357 wpa-service-rcscript: updated
358 wpa-service: removed unused wait_for_up function
359 '&> /dev/null' replaced by '2>&1 /dev/null'
360 WPA_CONFIG_FILE is now WPA_KEY_FILE
361 WPA_CONFIG_DIR is now WPA_KEY_DIR
362 wpa-service-conf: updated (to follow wpa-* change)
363 wpa_action-script: renamed to wpa-action-script
364 hint updated and files are now shipped in a tarball
365 with a very basic install.sh script
367 version increment to 0.24
368 2007 09 30 bump to version 0.24.1 this is a release fix
369 install script improved
370 fixed typo in wpa-service.conf (wrong wpa-action name)
371 fixed ifdown process bug, ssid connection are stored in file
372 to correctly set down the previously started service
373 Changelog file added.