README 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051
  1. WPA Supplicant
  2. ==============
  3. Copyright (c) 2003-2016, Jouni Malinen <j@w1.fi> and contributors
  4. All Rights Reserved.
  5. This program is licensed under the BSD license (the one with
  6. advertisement clause removed).
  7. If you are submitting changes to the project, please see CONTRIBUTIONS
  8. file for more instructions.
  9. License
  10. -------
  11. This software may be distributed, used, and modified under the terms of
  12. BSD license:
  13. Redistribution and use in source and binary forms, with or without
  14. modification, are permitted provided that the following conditions are
  15. met:
  16. 1. Redistributions of source code must retain the above copyright
  17. notice, this list of conditions and the following disclaimer.
  18. 2. Redistributions in binary form must reproduce the above copyright
  19. notice, this list of conditions and the following disclaimer in the
  20. documentation and/or other materials provided with the distribution.
  21. 3. Neither the name(s) of the above-listed copyright holder(s) nor the
  22. names of its contributors may be used to endorse or promote products
  23. derived from this software without specific prior written permission.
  24. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. Features
  36. --------
  37. Supported WPA/IEEE 802.11i features:
  38. - WPA-PSK ("WPA-Personal")
  39. - WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
  40. Following authentication methods are supported with an integrate IEEE 802.1X
  41. Supplicant:
  42. * EAP-TLS
  43. * EAP-PEAP/MSCHAPv2 (both PEAPv0 and PEAPv1)
  44. * EAP-PEAP/TLS (both PEAPv0 and PEAPv1)
  45. * EAP-PEAP/GTC (both PEAPv0 and PEAPv1)
  46. * EAP-PEAP/OTP (both PEAPv0 and PEAPv1)
  47. * EAP-PEAP/MD5-Challenge (both PEAPv0 and PEAPv1)
  48. * EAP-TTLS/EAP-MD5-Challenge
  49. * EAP-TTLS/EAP-GTC
  50. * EAP-TTLS/EAP-OTP
  51. * EAP-TTLS/EAP-MSCHAPv2
  52. * EAP-TTLS/EAP-TLS
  53. * EAP-TTLS/MSCHAPv2
  54. * EAP-TTLS/MSCHAP
  55. * EAP-TTLS/PAP
  56. * EAP-TTLS/CHAP
  57. * EAP-SIM
  58. * EAP-AKA
  59. * EAP-AKA'
  60. * EAP-PSK
  61. * EAP-PAX
  62. * EAP-SAKE
  63. * EAP-IKEv2
  64. * EAP-GPSK
  65. * EAP-pwd
  66. * LEAP (note: requires special support from the driver for IEEE 802.11
  67. authentication)
  68. (following methods are supported, but since they do not generate keying
  69. material, they cannot be used with WPA or IEEE 802.1X WEP keying)
  70. * EAP-MD5-Challenge
  71. * EAP-MSCHAPv2
  72. * EAP-GTC
  73. * EAP-OTP
  74. - key management for CCMP, TKIP, WEP104, WEP40
  75. - RSN/WPA2 (IEEE 802.11i)
  76. * pre-authentication
  77. * PMKSA caching
  78. Supported TLS/crypto libraries:
  79. - OpenSSL (default)
  80. - GnuTLS
  81. Internal TLS/crypto implementation (optional):
  82. - can be used in place of an external TLS/crypto library
  83. - TLSv1
  84. - X.509 certificate processing
  85. - PKCS #1
  86. - ASN.1
  87. - RSA
  88. - bignum
  89. - minimal size (ca. 50 kB binary, parts of which are already needed for WPA;
  90. TLSv1/X.509/ASN.1/RSA/bignum parts are about 25 kB on x86)
  91. Requirements
  92. ------------
  93. Current hardware/software requirements:
  94. - Linux kernel 2.4.x or 2.6.x with Linux Wireless Extensions v15 or newer
  95. - FreeBSD 6-CURRENT
  96. - NetBSD-current
  97. - Microsoft Windows with WinPcap (at least WinXP, may work with other versions)
  98. - drivers:
  99. Linux drivers that support cfg80211/nl80211. Even though there are
  100. number of driver specific interface included in wpa_supplicant, please
  101. note that Linux drivers are moving to use generic wireless configuration
  102. interface driver_nl80211 (-Dnl80211 on wpa_supplicant command line)
  103. should be the default option to start with before falling back to driver
  104. specific interface.
  105. Linux drivers that support WPA/WPA2 configuration with the generic
  106. Linux wireless extensions (WE-18 or newer). Obsoleted by nl80211.
  107. In theory, any driver that supports Linux wireless extensions can be
  108. used with IEEE 802.1X (i.e., not WPA) when using ap_scan=0 option in
  109. configuration file.
  110. Wired Ethernet drivers (with ap_scan=0)
  111. BSD net80211 layer (e.g., Atheros driver)
  112. At the moment, this is for FreeBSD 6-CURRENT branch and NetBSD-current.
  113. Windows NDIS
  114. The current Windows port requires WinPcap (http://winpcap.polito.it/).
  115. See README-Windows.txt for more information.
  116. wpa_supplicant was designed to be portable for different drivers and
  117. operating systems. Hopefully, support for more wlan cards and OSes will be
  118. added in the future. See developer's documentation
  119. (http://hostap.epitest.fi/wpa_supplicant/devel/) for more information about the
  120. design of wpa_supplicant and porting to other drivers. One main goal
  121. is to add full WPA/WPA2 support to Linux wireless extensions to allow
  122. new drivers to be supported without having to implement new
  123. driver-specific interface code in wpa_supplicant.
  124. Optional libraries for layer2 packet processing:
  125. - libpcap (tested with 0.7.2, most relatively recent versions assumed to work,
  126. this is likely to be available with most distributions,
  127. http://tcpdump.org/)
  128. - libdnet (tested with v1.4, most versions assumed to work,
  129. http://libdnet.sourceforge.net/)
  130. These libraries are _not_ used in the default Linux build. Instead,
  131. internal Linux specific implementation is used. libpcap/libdnet are
  132. more portable and they can be used by adding CONFIG_L2_PACKET=pcap into
  133. .config. They may also be selected automatically for other operating
  134. systems. In case of Windows builds, WinPcap is used by default
  135. (CONFIG_L2_PACKET=winpcap).
  136. Optional libraries for EAP-TLS, EAP-PEAP, and EAP-TTLS:
  137. - OpenSSL (tested with 1.0.1 and 1.0.2 versions; assumed to
  138. work with most relatively recent versions; this is likely to be
  139. available with most distributions, http://www.openssl.org/)
  140. - GnuTLS
  141. - internal TLSv1 implementation
  142. One of these libraries is needed when EAP-TLS, EAP-PEAP, EAP-TTLS, or
  143. EAP-FAST support is enabled. WPA-PSK mode does not require this or EAPOL/EAP
  144. implementation. A configuration file, .config, for compilation is
  145. needed to enable IEEE 802.1X/EAPOL and EAP methods. Note that EAP-MD5,
  146. EAP-GTC, EAP-OTP, and EAP-MSCHAPV2 cannot be used alone with WPA, so
  147. they should only be enabled if testing the EAPOL/EAP state
  148. machines. However, there can be used as inner authentication
  149. algorithms with EAP-PEAP and EAP-TTLS.
  150. See Building and installing section below for more detailed
  151. information about the wpa_supplicant build time configuration.
  152. WPA
  153. ---
  154. The original security mechanism of IEEE 802.11 standard was not
  155. designed to be strong and has proven to be insufficient for most
  156. networks that require some kind of security. Task group I (Security)
  157. of IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
  158. to address the flaws of the base standard and has in practice
  159. completed its work in May 2004. The IEEE 802.11i amendment to the IEEE
  160. 802.11 standard was approved in June 2004 and published in July 2004.
  161. Wi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
  162. IEEE 802.11i work (draft 3.0) to define a subset of the security
  163. enhancements that can be implemented with existing wlan hardware. This
  164. is called Wi-Fi Protected Access<TM> (WPA). This has now become a
  165. mandatory component of interoperability testing and certification done
  166. by Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
  167. site (http://www.wi-fi.org/OpenSection/protected_access.asp).
  168. IEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
  169. for protecting wireless networks. WEP uses RC4 with 40-bit keys,
  170. 24-bit initialization vector (IV), and CRC32 to protect against packet
  171. forgery. All these choices have proven to be insufficient: key space is
  172. too small against current attacks, RC4 key scheduling is insufficient
  173. (beginning of the pseudorandom stream should be skipped), IV space is
  174. too small and IV reuse makes attacks easier, there is no replay
  175. protection, and non-keyed authentication does not protect against bit
  176. flipping packet data.
  177. WPA is an intermediate solution for the security issues. It uses
  178. Temporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
  179. compromise on strong security and possibility to use existing
  180. hardware. It still uses RC4 for the encryption like WEP, but with
  181. per-packet RC4 keys. In addition, it implements replay protection,
  182. keyed packet authentication mechanism (Michael MIC).
  183. Keys can be managed using two different mechanisms. WPA can either use
  184. an external authentication server (e.g., RADIUS) and EAP just like
  185. IEEE 802.1X is using or pre-shared keys without need for additional
  186. servers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
  187. respectively. Both mechanisms will generate a master session key for
  188. the Authenticator (AP) and Supplicant (client station).
  189. WPA implements a new key handshake (4-Way Handshake and Group Key
  190. Handshake) for generating and exchanging data encryption keys between
  191. the Authenticator and Supplicant. This handshake is also used to
  192. verify that both Authenticator and Supplicant know the master session
  193. key. These handshakes are identical regardless of the selected key
  194. management mechanism (only the method for generating master session
  195. key changes).
  196. IEEE 802.11i / WPA2
  197. -------------------
  198. The design for parts of IEEE 802.11i that were not included in WPA has
  199. finished (May 2004) and this amendment to IEEE 802.11 was approved in
  200. June 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
  201. version of WPA called WPA2. This includes, e.g., support for more
  202. robust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
  203. to replace TKIP and optimizations for handoff (reduced number of
  204. messages in initial key handshake, pre-authentication, and PMKSA caching).
  205. wpa_supplicant
  206. --------------
  207. wpa_supplicant is an implementation of the WPA Supplicant component,
  208. i.e., the part that runs in the client stations. It implements WPA key
  209. negotiation with a WPA Authenticator and EAP authentication with
  210. Authentication Server. In addition, it controls the roaming and IEEE
  211. 802.11 authentication/association of the wlan driver.
  212. wpa_supplicant is designed to be a "daemon" program that runs in the
  213. background and acts as the backend component controlling the wireless
  214. connection. wpa_supplicant supports separate frontend programs and an
  215. example text-based frontend, wpa_cli, is included with wpa_supplicant.
  216. Following steps are used when associating with an AP using WPA:
  217. - wpa_supplicant requests the kernel driver to scan neighboring BSSes
  218. - wpa_supplicant selects a BSS based on its configuration
  219. - wpa_supplicant requests the kernel driver to associate with the chosen
  220. BSS
  221. - If WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP
  222. authentication with the authentication server (proxied by the
  223. Authenticator in the AP)
  224. - If WPA-EAP: master key is received from the IEEE 802.1X Supplicant
  225. - If WPA-PSK: wpa_supplicant uses PSK as the master session key
  226. - wpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake
  227. with the Authenticator (AP)
  228. - wpa_supplicant configures encryption keys for unicast and broadcast
  229. - normal data packets can be transmitted and received
  230. Building and installing
  231. -----------------------
  232. In order to be able to build wpa_supplicant, you will first need to
  233. select which parts of it will be included. This is done by creating a
  234. build time configuration file, .config, in the wpa_supplicant root
  235. directory. Configuration options are text lines using following
  236. format: CONFIG_<option>=y. Lines starting with # are considered
  237. comments and are ignored. See defconfig file for an example configuration
  238. and a list of available options and additional notes.
  239. The build time configuration can be used to select only the needed
  240. features and limit the binary size and requirements for external
  241. libraries. The main configuration parts are the selection of which
  242. driver interfaces (e.g., nl80211, wext, ..) and which authentication
  243. methods (e.g., EAP-TLS, EAP-PEAP, ..) are included.
  244. Following build time configuration options are used to control IEEE
  245. 802.1X/EAPOL and EAP state machines and all EAP methods. Including
  246. TLS, PEAP, or TTLS will require linking wpa_supplicant with OpenSSL
  247. library for TLS implementation. Alternatively, GnuTLS or the internal
  248. TLSv1 implementation can be used for TLS functionality.
  249. CONFIG_IEEE8021X_EAPOL=y
  250. CONFIG_EAP_MD5=y
  251. CONFIG_EAP_MSCHAPV2=y
  252. CONFIG_EAP_TLS=y
  253. CONFIG_EAP_PEAP=y
  254. CONFIG_EAP_TTLS=y
  255. CONFIG_EAP_GTC=y
  256. CONFIG_EAP_OTP=y
  257. CONFIG_EAP_SIM=y
  258. CONFIG_EAP_AKA=y
  259. CONFIG_EAP_AKA_PRIME=y
  260. CONFIG_EAP_PSK=y
  261. CONFIG_EAP_SAKE=y
  262. CONFIG_EAP_GPSK=y
  263. CONFIG_EAP_PAX=y
  264. CONFIG_EAP_LEAP=y
  265. CONFIG_EAP_IKEV2=y
  266. CONFIG_EAP_PWD=y
  267. Following option can be used to include GSM SIM/USIM interface for GSM/UMTS
  268. authentication algorithm (for EAP-SIM/EAP-AKA/EAP-AKA'). This requires pcsc-lite
  269. (http://www.linuxnet.com/) for smart card access.
  270. CONFIG_PCSC=y
  271. Following options can be added to .config to select which driver
  272. interfaces are included.
  273. CONFIG_DRIVER_NL80211=y
  274. CONFIG_DRIVER_WEXT=y
  275. CONFIG_DRIVER_BSD=y
  276. CONFIG_DRIVER_NDIS=y
  277. Following example includes some more features and driver interfaces that
  278. are included in the wpa_supplicant package:
  279. CONFIG_DRIVER_NL80211=y
  280. CONFIG_DRIVER_WEXT=y
  281. CONFIG_DRIVER_BSD=y
  282. CONFIG_DRIVER_NDIS=y
  283. CONFIG_IEEE8021X_EAPOL=y
  284. CONFIG_EAP_MD5=y
  285. CONFIG_EAP_MSCHAPV2=y
  286. CONFIG_EAP_TLS=y
  287. CONFIG_EAP_PEAP=y
  288. CONFIG_EAP_TTLS=y
  289. CONFIG_EAP_GTC=y
  290. CONFIG_EAP_OTP=y
  291. CONFIG_EAP_SIM=y
  292. CONFIG_EAP_AKA=y
  293. CONFIG_EAP_PSK=y
  294. CONFIG_EAP_SAKE=y
  295. CONFIG_EAP_GPSK=y
  296. CONFIG_EAP_PAX=y
  297. CONFIG_EAP_LEAP=y
  298. CONFIG_EAP_IKEV2=y
  299. CONFIG_PCSC=y
  300. EAP-PEAP and EAP-TTLS will automatically include configured EAP
  301. methods (MD5, OTP, GTC, MSCHAPV2) for inner authentication selection.
  302. After you have created a configuration file, you can build
  303. wpa_supplicant and wpa_cli with 'make' command. You may then install
  304. the binaries to a suitable system directory, e.g., /usr/local/bin.
  305. Example commands:
  306. # build wpa_supplicant and wpa_cli
  307. make
  308. # install binaries (this may need root privileges)
  309. cp wpa_cli wpa_supplicant /usr/local/bin
  310. You will need to make a configuration file, e.g.,
  311. /etc/wpa_supplicant.conf, with network configuration for the networks
  312. you are going to use. Configuration file section below includes
  313. explanation fo the configuration file format and includes various
  314. examples. Once the configuration is ready, you can test whether the
  315. configuration work by first running wpa_supplicant with following
  316. command to start it on foreground with debugging enabled:
  317. wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -d
  318. Assuming everything goes fine, you can start using following command
  319. to start wpa_supplicant on background without debugging:
  320. wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
  321. Please note that if you included more than one driver interface in the
  322. build time configuration (.config), you may need to specify which
  323. interface to use by including -D<driver name> option on the command
  324. line. See following section for more details on command line options
  325. for wpa_supplicant.
  326. Command line options
  327. --------------------
  328. usage:
  329. wpa_supplicant [-BddfhKLqqtuvW] [-P<pid file>] [-g<global ctrl>] \
  330. [-G<group>] \
  331. -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
  332. [-b<br_ifname> [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
  333. [-p<driver_param>] [-b<br_ifname>] [-m<P2P Device config file>] ...
  334. options:
  335. -b = optional bridge interface name
  336. -B = run daemon in the background
  337. -c = Configuration file
  338. -C = ctrl_interface parameter (only used if -c is not)
  339. -i = interface name
  340. -d = increase debugging verbosity (-dd even more)
  341. -D = driver name (can be multiple drivers: nl80211,wext)
  342. -f = Log output to default log location (normally /tmp)
  343. -g = global ctrl_interface
  344. -G = global ctrl_interface group
  345. -K = include keys (passwords, etc.) in debug output
  346. -t = include timestamp in debug messages
  347. -h = show this help text
  348. -L = show license (BSD)
  349. -p = driver parameters
  350. -P = PID file
  351. -q = decrease debugging verbosity (-qq even less)
  352. -u = enable DBus control interface
  353. -v = show version
  354. -W = wait for a control interface monitor before starting
  355. -N = start describing new interface
  356. -m = Configuration file for the P2P Device
  357. drivers:
  358. nl80211 = Linux nl80211/cfg80211
  359. wext = Linux wireless extensions (generic)
  360. wired = wpa_supplicant wired Ethernet driver
  361. roboswitch = wpa_supplicant Broadcom switch driver
  362. bsd = BSD 802.11 support (Atheros, etc.)
  363. ndis = Windows NDIS driver
  364. In most common cases, wpa_supplicant is started with
  365. wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
  366. This makes the process fork into background.
  367. The easiest way to debug problems, and to get debug log for bug
  368. reports, is to start wpa_supplicant on foreground with debugging
  369. enabled:
  370. wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d
  371. If the specific driver wrapper is not known beforehand, it is possible
  372. to specify multiple comma separated driver wrappers on the command
  373. line. wpa_supplicant will use the first driver wrapper that is able to
  374. initialize the interface.
  375. wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0
  376. wpa_supplicant can control multiple interfaces (radios) either by
  377. running one process for each interface separately or by running just
  378. one process and list of options at command line. Each interface is
  379. separated with -N argument. As an example, following command would
  380. start wpa_supplicant for two interfaces:
  381. wpa_supplicant \
  382. -c wpa1.conf -i wlan0 -D nl80211 -N \
  383. -c wpa2.conf -i wlan1 -D wext
  384. If the interface is added in a Linux bridge (e.g., br0), the bridge
  385. interface needs to be configured to wpa_supplicant in addition to the
  386. main interface:
  387. wpa_supplicant -cw.conf -Dnl80211 -iwlan0 -bbr0
  388. Configuration file
  389. ------------------
  390. wpa_supplicant is configured using a text file that lists all accepted
  391. networks and security policies, including pre-shared keys. See
  392. example configuration file, wpa_supplicant.conf, for detailed
  393. information about the configuration format and supported fields.
  394. Changes to configuration file can be reloaded be sending SIGHUP signal
  395. to wpa_supplicant ('killall -HUP wpa_supplicant'). Similarly,
  396. reloading can be triggered with 'wpa_cli reconfigure' command.
  397. Configuration file can include one or more network blocks, e.g., one
  398. for each used SSID. wpa_supplicant will automatically select the best
  399. network based on the order of network blocks in the configuration
  400. file, network security level (WPA/WPA2 is preferred), and signal
  401. strength.
  402. Example configuration files for some common configurations:
  403. 1) WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work
  404. network
  405. # allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
  406. ctrl_interface=/var/run/wpa_supplicant
  407. ctrl_interface_group=wheel
  408. #
  409. # home network; allow all valid ciphers
  410. network={
  411. ssid="home"
  412. scan_ssid=1
  413. key_mgmt=WPA-PSK
  414. psk="very secret passphrase"
  415. }
  416. #
  417. # work network; use EAP-TLS with WPA; allow only CCMP and TKIP ciphers
  418. network={
  419. ssid="work"
  420. scan_ssid=1
  421. key_mgmt=WPA-EAP
  422. pairwise=CCMP TKIP
  423. group=CCMP TKIP
  424. eap=TLS
  425. identity="user@example.com"
  426. ca_cert="/etc/cert/ca.pem"
  427. client_cert="/etc/cert/user.pem"
  428. private_key="/etc/cert/user.prv"
  429. private_key_passwd="password"
  430. }
  431. 2) WPA-RADIUS/EAP-PEAP/MSCHAPv2 with RADIUS servers that use old peaplabel
  432. (e.g., Funk Odyssey and SBR, Meetinghouse Aegis, Interlink RAD-Series)
  433. ctrl_interface=/var/run/wpa_supplicant
  434. ctrl_interface_group=wheel
  435. network={
  436. ssid="example"
  437. scan_ssid=1
  438. key_mgmt=WPA-EAP
  439. eap=PEAP
  440. identity="user@example.com"
  441. password="foobar"
  442. ca_cert="/etc/cert/ca.pem"
  443. phase1="peaplabel=0"
  444. phase2="auth=MSCHAPV2"
  445. }
  446. 3) EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
  447. unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
  448. ctrl_interface=/var/run/wpa_supplicant
  449. ctrl_interface_group=wheel
  450. network={
  451. ssid="example"
  452. scan_ssid=1
  453. key_mgmt=WPA-EAP
  454. eap=TTLS
  455. identity="user@example.com"
  456. anonymous_identity="anonymous@example.com"
  457. password="foobar"
  458. ca_cert="/etc/cert/ca.pem"
  459. phase2="auth=MD5"
  460. }
  461. 4) IEEE 802.1X (i.e., no WPA) with dynamic WEP keys (require both unicast and
  462. broadcast); use EAP-TLS for authentication
  463. ctrl_interface=/var/run/wpa_supplicant
  464. ctrl_interface_group=wheel
  465. network={
  466. ssid="1x-test"
  467. scan_ssid=1
  468. key_mgmt=IEEE8021X
  469. eap=TLS
  470. identity="user@example.com"
  471. ca_cert="/etc/cert/ca.pem"
  472. client_cert="/etc/cert/user.pem"
  473. private_key="/etc/cert/user.prv"
  474. private_key_passwd="password"
  475. eapol_flags=3
  476. }
  477. 5) Catch all example that allows more or less all configuration modes. The
  478. configuration options are used based on what security policy is used in the
  479. selected SSID. This is mostly for testing and is not recommended for normal
  480. use.
  481. ctrl_interface=/var/run/wpa_supplicant
  482. ctrl_interface_group=wheel
  483. network={
  484. ssid="example"
  485. scan_ssid=1
  486. key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
  487. pairwise=CCMP TKIP
  488. group=CCMP TKIP WEP104 WEP40
  489. psk="very secret passphrase"
  490. eap=TTLS PEAP TLS
  491. identity="user@example.com"
  492. password="foobar"
  493. ca_cert="/etc/cert/ca.pem"
  494. client_cert="/etc/cert/user.pem"
  495. private_key="/etc/cert/user.prv"
  496. private_key_passwd="password"
  497. phase1="peaplabel=0"
  498. ca_cert2="/etc/cert/ca2.pem"
  499. client_cert2="/etc/cer/user.pem"
  500. private_key2="/etc/cer/user.prv"
  501. private_key2_passwd="password"
  502. }
  503. 6) Authentication for wired Ethernet. This can be used with 'wired' or
  504. 'roboswitch' interface (-Dwired or -Droboswitch on command line).
  505. ctrl_interface=/var/run/wpa_supplicant
  506. ctrl_interface_group=wheel
  507. ap_scan=0
  508. network={
  509. key_mgmt=IEEE8021X
  510. eap=MD5
  511. identity="user"
  512. password="password"
  513. eapol_flags=0
  514. }
  515. Certificates
  516. ------------
  517. Some EAP authentication methods require use of certificates. EAP-TLS
  518. uses both server side and client certificates whereas EAP-PEAP and
  519. EAP-TTLS only require the server side certificate. When client
  520. certificate is used, a matching private key file has to also be
  521. included in configuration. If the private key uses a passphrase, this
  522. has to be configured in wpa_supplicant.conf ("private_key_passwd").
  523. wpa_supplicant supports X.509 certificates in PEM and DER
  524. formats. User certificate and private key can be included in the same
  525. file.
  526. If the user certificate and private key is received in PKCS#12/PFX
  527. format, they need to be converted to suitable PEM/DER format for
  528. wpa_supplicant. This can be done, e.g., with following commands:
  529. # convert client certificate and private key to PEM format
  530. openssl pkcs12 -in example.pfx -out user.pem -clcerts
  531. # convert CA certificate (if included in PFX file) to PEM format
  532. openssl pkcs12 -in example.pfx -out ca.pem -cacerts -nokeys
  533. wpa_cli
  534. -------
  535. wpa_cli is a text-based frontend program for interacting with
  536. wpa_supplicant. It is used to query current status, change
  537. configuration, trigger events, and request interactive user input.
  538. wpa_cli can show the current authentication status, selected security
  539. mode, dot11 and dot1x MIBs, etc. In addition, it can configure some
  540. variables like EAPOL state machine parameters and trigger events like
  541. reassociation and IEEE 802.1X logoff/logon. wpa_cli provides a user
  542. interface to request authentication information, like username and
  543. password, if these are not included in the configuration. This can be
  544. used to implement, e.g., one-time-passwords or generic token card
  545. authentication where the authentication is based on a
  546. challenge-response that uses an external device for generating the
  547. response.
  548. The control interface of wpa_supplicant can be configured to allow
  549. non-root user access (ctrl_interface_group in the configuration
  550. file). This makes it possible to run wpa_cli with a normal user
  551. account.
  552. wpa_cli supports two modes: interactive and command line. Both modes
  553. share the same command set and the main difference is in interactive
  554. mode providing access to unsolicited messages (event messages,
  555. username/password requests).
  556. Interactive mode is started when wpa_cli is executed without including
  557. the command as a command line parameter. Commands are then entered on
  558. the wpa_cli prompt. In command line mode, the same commands are
  559. entered as command line arguments for wpa_cli.
  560. Interactive authentication parameters request
  561. When wpa_supplicant need authentication parameters, like username and
  562. password, which are not present in the configuration file, it sends a
  563. request message to all attached frontend programs, e.g., wpa_cli in
  564. interactive mode. wpa_cli shows these requests with
  565. "CTRL-REQ-<type>-<id>:<text>" prefix. <type> is IDENTITY, PASSWORD, or
  566. OTP (one-time-password). <id> is a unique identifier for the current
  567. network. <text> is description of the request. In case of OTP request,
  568. it includes the challenge from the authentication server.
  569. The reply to these requests can be given with 'identity', 'password',
  570. and 'otp' commands. <id> needs to be copied from the the matching
  571. request. 'password' and 'otp' commands can be used regardless of
  572. whether the request was for PASSWORD or OTP. The main difference
  573. between these two commands is that values given with 'password' are
  574. remembered as long as wpa_supplicant is running whereas values given
  575. with 'otp' are used only once and then forgotten, i.e., wpa_supplicant
  576. will ask frontend for a new value for every use. This can be used to
  577. implement one-time-password lists and generic token card -based
  578. authentication.
  579. Example request for password and a matching reply:
  580. CTRL-REQ-PASSWORD-1:Password needed for SSID foobar
  581. > password 1 mysecretpassword
  582. Example request for generic token card challenge-response:
  583. CTRL-REQ-OTP-2:Challenge 1235663 needed for SSID foobar
  584. > otp 2 9876
  585. wpa_cli commands
  586. status = get current WPA/EAPOL/EAP status
  587. mib = get MIB variables (dot1x, dot11)
  588. help = show this usage help
  589. interface [ifname] = show interfaces/select interface
  590. level <debug level> = change debug level
  591. license = show full wpa_cli license
  592. logoff = IEEE 802.1X EAPOL state machine logoff
  593. logon = IEEE 802.1X EAPOL state machine logon
  594. set = set variables (shows list of variables when run without arguments)
  595. pmksa = show PMKSA cache
  596. reassociate = force reassociation
  597. reconfigure = force wpa_supplicant to re-read its configuration file
  598. preauthenticate <BSSID> = force preauthentication
  599. identity <network id> <identity> = configure identity for an SSID
  600. password <network id> <password> = configure password for an SSID
  601. pin <network id> <pin> = configure pin for an SSID
  602. otp <network id> <password> = configure one-time-password for an SSID
  603. passphrase <network id> <passphrase> = configure private key passphrase
  604. for an SSID
  605. bssid <network id> <BSSID> = set preferred BSSID for an SSID
  606. list_networks = list configured networks
  607. select_network <network id> = select a network (disable others)
  608. enable_network <network id> = enable a network
  609. disable_network <network id> = disable a network
  610. add_network = add a network
  611. remove_network <network id> = remove a network
  612. set_network <network id> <variable> <value> = set network variables (shows
  613. list of variables when run without arguments)
  614. get_network <network id> <variable> = get network variables
  615. save_config = save the current configuration
  616. disconnect = disconnect and wait for reassociate command before connecting
  617. scan = request new BSS scan
  618. scan_results = get latest scan results
  619. get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
  620. terminate = terminate wpa_supplicant
  621. quit = exit wpa_cli
  622. wpa_cli command line options
  623. wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] [-a<action file>] \
  624. [-P<pid file>] [-g<global ctrl>] [command..]
  625. -h = help (show this usage text)
  626. -v = shown version information
  627. -a = run in daemon mode executing the action file based on events from
  628. wpa_supplicant
  629. -B = run a daemon in the background
  630. default path: /var/run/wpa_supplicant
  631. default interface: first interface found in socket path
  632. Using wpa_cli to run external program on connect/disconnect
  633. -----------------------------------------------------------
  634. wpa_cli can used to run external programs whenever wpa_supplicant
  635. connects or disconnects from a network. This can be used, e.g., to
  636. update network configuration and/or trigget DHCP client to update IP
  637. addresses, etc.
  638. One wpa_cli process in "action" mode needs to be started for each
  639. interface. For example, the following command starts wpa_cli for the
  640. default interface (-i can be used to select the interface in case of
  641. more than one interface being used at the same time):
  642. wpa_cli -a/sbin/wpa_action.sh -B
  643. The action file (-a option, /sbin/wpa_action.sh in this example) will
  644. be executed whenever wpa_supplicant completes authentication (connect
  645. event) or detects disconnection). The action script will be called
  646. with two command line arguments: interface name and event (CONNECTED
  647. or DISCONNECTED). If the action script needs to get more information
  648. about the current network, it can use 'wpa_cli status' to query
  649. wpa_supplicant for more information.
  650. Following example can be used as a simple template for an action
  651. script:
  652. #!/bin/sh
  653. IFNAME=$1
  654. CMD=$2
  655. if [ "$CMD" = "CONNECTED" ]; then
  656. SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
  657. # configure network, signal DHCP client, etc.
  658. fi
  659. if [ "$CMD" = "DISCONNECTED" ]; then
  660. # remove network configuration, if needed
  661. SSID=
  662. fi
  663. Integrating with pcmcia-cs/cardmgr scripts
  664. ------------------------------------------
  665. wpa_supplicant needs to be running when using a wireless network with
  666. WPA. It can be started either from system startup scripts or from
  667. pcmcia-cs/cardmgr scripts (when using PC Cards). WPA handshake must be
  668. completed before data frames can be exchanged, so wpa_supplicant
  669. should be started before DHCP client.
  670. For example, following small changes to pcmcia-cs scripts can be used
  671. to enable WPA support:
  672. Add MODE="Managed" and WPA="y" to the network scheme in
  673. /etc/pcmcia/wireless.opts.
  674. Add the following block to the end of 'start' action handler in
  675. /etc/pcmcia/wireless:
  676. if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
  677. /usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf \
  678. -i$DEVICE
  679. fi
  680. Add the following block to the end of 'stop' action handler (may need
  681. to be separated from other actions) in /etc/pcmcia/wireless:
  682. if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
  683. killall wpa_supplicant
  684. fi
  685. This will make cardmgr start wpa_supplicant when the card is plugged
  686. in.
  687. Dynamic interface add and operation without configuration files
  688. ---------------------------------------------------------------
  689. wpa_supplicant can be started without any configuration files or
  690. network interfaces. When used in this way, a global (i.e., per
  691. wpa_supplicant process) control interface is used to add and remove
  692. network interfaces. Each network interface can then be configured
  693. through a per-network interface control interface. For example,
  694. following commands show how to start wpa_supplicant without any
  695. network interfaces and then add a network interface and configure a
  696. network (SSID):
  697. # Start wpa_supplicant in the background
  698. wpa_supplicant -g/var/run/wpa_supplicant-global -B
  699. # Add a new interface (wlan0, no configuration file, driver=nl80211, and
  700. # enable control interface)
  701. wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan0 \
  702. "" nl80211 /var/run/wpa_supplicant
  703. # Configure a network using the newly added network interface:
  704. wpa_cli -iwlan0 add_network
  705. wpa_cli -iwlan0 set_network 0 ssid '"test"'
  706. wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
  707. wpa_cli -iwlan0 set_network 0 psk '"12345678"'
  708. wpa_cli -iwlan0 set_network 0 pairwise TKIP
  709. wpa_cli -iwlan0 set_network 0 group TKIP
  710. wpa_cli -iwlan0 set_network 0 proto WPA
  711. wpa_cli -iwlan0 enable_network 0
  712. # At this point, the new network interface should start trying to associate
  713. # with the WPA-PSK network using SSID test.
  714. # Remove network interface
  715. wpa_cli -g/var/run/wpa_supplicant-global interface_remove wlan0
  716. Privilege separation
  717. --------------------
  718. To minimize the size of code that needs to be run with root privileges
  719. (e.g., to control wireless interface operation), wpa_supplicant
  720. supports optional privilege separation. If enabled, this separates the
  721. privileged operations into a separate process (wpa_priv) while leaving
  722. rest of the code (e.g., EAP authentication and WPA handshakes) into an
  723. unprivileged process (wpa_supplicant) that can be run as non-root
  724. user. Privilege separation restricts the effects of potential software
  725. errors by containing the majority of the code in an unprivileged
  726. process to avoid full system compromise.
  727. Privilege separation is not enabled by default and it can be enabled
  728. by adding CONFIG_PRIVSEP=y to the build configuration (.config). When
  729. enabled, the privileged operations (driver wrapper and l2_packet) are
  730. linked into a separate daemon program, wpa_priv. The unprivileged
  731. program, wpa_supplicant, will be built with a special driver/l2_packet
  732. wrappers that communicate with the privileged wpa_priv process to
  733. perform the needed operations. wpa_priv can control what privileged
  734. are allowed.
  735. wpa_priv needs to be run with network admin privileges (usually, root
  736. user). It opens a UNIX domain socket for each interface that is
  737. included on the command line; any other interface will be off limits
  738. for wpa_supplicant in this kind of configuration. After this,
  739. wpa_supplicant can be run as a non-root user (e.g., all standard users
  740. on a laptop or as a special non-privileged user account created just
  741. for this purpose to limit access to user files even further).
  742. Example configuration:
  743. - create user group for users that are allowed to use wpa_supplicant
  744. ('wpapriv' in this example) and assign users that should be able to
  745. use wpa_supplicant into that group
  746. - create /var/run/wpa_priv directory for UNIX domain sockets and control
  747. user access by setting it accessible only for the wpapriv group:
  748. mkdir /var/run/wpa_priv
  749. chown root:wpapriv /var/run/wpa_priv
  750. chmod 0750 /var/run/wpa_priv
  751. - start wpa_priv as root (e.g., from system startup scripts) with the
  752. enabled interfaces configured on the command line:
  753. wpa_priv -B -P /var/run/wpa_priv.pid nl80211:wlan0
  754. - run wpa_supplicant as non-root with a user that is in wpapriv group:
  755. wpa_supplicant -i ath0 -c wpa_supplicant.conf
  756. wpa_priv does not use the network interface before wpa_supplicant is
  757. started, so it is fine to include network interfaces that are not
  758. available at the time wpa_priv is started. As an alternative, wpa_priv
  759. can be started when an interface is added (hotplug/udev/etc. scripts).
  760. wpa_priv can control multiple interface with one process, but it is
  761. also possible to run multiple wpa_priv processes at the same time, if
  762. desired.
  763. Linux capabilities instead of privileged process
  764. ------------------------------------------------
  765. wpa_supplicant performs operations that need special permissions, e.g.,
  766. to control the network connection. Traditionally this has been achieved
  767. by running wpa_supplicant as a privileged process with effective user id
  768. 0 (root). Linux capabilities can be used to provide restricted set of
  769. capabilities to match the functions needed by wpa_supplicant. The
  770. minimum set of capabilities needed for the operations is CAP_NET_ADMIN
  771. and CAP_NET_RAW.
  772. setcap(8) can be used to set file capabilities. For example:
  773. sudo setcap cap_net_raw,cap_net_admin+ep wpa_supplicant
  774. Please note that this would give anyone being able to run that
  775. wpa_supplicant binary access to the additional capabilities. This can
  776. further be limited by file owner/group and mode bits. For example:
  777. sudo chown wpas wpa_supplicant
  778. sudo chmod 0100 wpa_supplicant
  779. This combination of setcap, chown, and chmod commands would allow wpas
  780. user to execute wpa_supplicant with additional network admin/raw
  781. capabilities.
  782. Common way style of creating a control interface socket in
  783. /var/run/wpa_supplicant could not be done by this user, but this
  784. directory could be created before starting the wpa_supplicant and set to
  785. suitable mode to allow wpa_supplicant to create sockets
  786. there. Alternatively, other directory or abstract socket namespace could
  787. be used for the control interface.
  788. External requests for radio control
  789. -----------------------------------
  790. External programs can request wpa_supplicant to not start offchannel
  791. operations during other tasks that may need exclusive control of the
  792. radio. The RADIO_WORK control interface command can be used for this.
  793. "RADIO_WORK add <name> [freq=<MHz>] [timeout=<seconds>]" command can be
  794. used to reserve a slot for radio access. If freq is specified, other
  795. radio work items on the same channel may be completed in
  796. parallel. Otherwise, all other radio work items are blocked during
  797. execution. Timeout is set to 10 seconds by default to avoid blocking
  798. wpa_supplicant operations for excessive time. If a longer (or shorter)
  799. safety timeout is needed, that can be specified with the optional
  800. timeout parameter. This command returns an identifier for the radio work
  801. item.
  802. Once the radio work item has been started, "EXT-RADIO-WORK-START <id>"
  803. event message is indicated that the external processing can start. Once
  804. the operation has been completed, "RADIO_WORK done <id>" is used to
  805. indicate that to wpa_supplicant. This allows other radio works to be
  806. performed. If this command is forgotten (e.g., due to the external
  807. program terminating), wpa_supplicant will time out the radio work item
  808. and send "EXT-RADIO-WORK-TIMEOUT <id>" event to indicate that this has
  809. happened. "RADIO_WORK done <id>" can also be used to cancel items that
  810. have not yet been started.
  811. For example, in wpa_cli interactive mode:
  812. > radio_work add test
  813. 1
  814. <3>EXT-RADIO-WORK-START 1
  815. > radio_work show
  816. ext:test@wlan0:0:1:2.487797
  817. > radio_work done 1
  818. OK
  819. > radio_work show
  820. > radio_work done 3
  821. OK
  822. > radio_work show
  823. ext:test freq=2412 timeout=30@wlan0:2412:1:28.583483
  824. <3>EXT-RADIO-WORK-TIMEOUT 2
  825. > radio_work add test2 freq=2412 timeout=60
  826. 5
  827. <3>EXT-RADIO-WORK-START 5
  828. > radio_work add test3
  829. 6
  830. > radio_work add test4
  831. 7
  832. > radio_work show
  833. ext:test2 freq=2412 timeout=60@wlan0:2412:1:9.751844
  834. ext:test3@wlan0:0:0:5.071812
  835. ext:test4@wlan0:0:0:3.143870
  836. > radio_work done 6
  837. OK
  838. > radio_work show
  839. ext:test2 freq=2412 timeout=60@wlan0:2412:1:16.287869
  840. ext:test4@wlan0:0:0:9.679895
  841. > radio_work done 5
  842. OK
  843. <3>EXT-RADIO-WORK-START 7
  844. <3>EXT-RADIO-WORK-TIMEOUT 7