README 38 KB

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