README 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  1. WPA Supplicant
  2. ==============
  3. Copyright (c) 2003-2017, 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> [-MN -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. -M = start describing matching interface
  356. -N = start describing new interface
  357. -m = Configuration file for the P2P Device
  358. drivers:
  359. nl80211 = Linux nl80211/cfg80211
  360. wext = Linux wireless extensions (generic)
  361. wired = wpa_supplicant wired Ethernet driver
  362. roboswitch = wpa_supplicant Broadcom switch driver
  363. bsd = BSD 802.11 support (Atheros, etc.)
  364. ndis = Windows NDIS driver
  365. In most common cases, wpa_supplicant is started with
  366. wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
  367. This makes the process fork into background.
  368. The easiest way to debug problems, and to get debug log for bug
  369. reports, is to start wpa_supplicant on foreground with debugging
  370. enabled:
  371. wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d
  372. If the specific driver wrapper is not known beforehand, it is possible
  373. to specify multiple comma separated driver wrappers on the command
  374. line. wpa_supplicant will use the first driver wrapper that is able to
  375. initialize the interface.
  376. wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0
  377. wpa_supplicant can control multiple interfaces (radios) either by
  378. running one process for each interface separately or by running just
  379. one process and list of options at command line. Each interface is
  380. separated with -N argument. As an example, following command would
  381. start wpa_supplicant for two interfaces:
  382. wpa_supplicant \
  383. -c wpa1.conf -i wlan0 -D nl80211 -N \
  384. -c wpa2.conf -i wlan1 -D wext
  385. If the interfaces on which wpa_supplicant is to run are not known or do
  386. not exist, wpa_supplicant can match an interface when it arrives. Each
  387. matched interface is separated with -M argument and the -i argument now
  388. allows for pattern matching.
  389. As an example, the following command would start wpa_supplicant for a
  390. specific wired interface called lan0, any interface starting with wlan
  391. and lastly any other interface. Each match has its own configuration
  392. file, and for the wired interface a specific driver has also been given.
  393. wpa_supplicant \
  394. -M -c wpa_wired.conf -ilan0 -D wired \
  395. -M -c wpa1.conf -iwlan* \
  396. -M -c wpa2.conf
  397. If the interface is added in a Linux bridge (e.g., br0), the bridge
  398. interface needs to be configured to wpa_supplicant in addition to the
  399. main interface:
  400. wpa_supplicant -cw.conf -Dnl80211 -iwlan0 -bbr0
  401. Configuration file
  402. ------------------
  403. wpa_supplicant is configured using a text file that lists all accepted
  404. networks and security policies, including pre-shared keys. See
  405. example configuration file, wpa_supplicant.conf, for detailed
  406. information about the configuration format and supported fields.
  407. Changes to configuration file can be reloaded be sending SIGHUP signal
  408. to wpa_supplicant ('killall -HUP wpa_supplicant'). Similarly,
  409. reloading can be triggered with 'wpa_cli reconfigure' command.
  410. Configuration file can include one or more network blocks, e.g., one
  411. for each used SSID. wpa_supplicant will automatically select the best
  412. network based on the order of network blocks in the configuration
  413. file, network security level (WPA/WPA2 is preferred), and signal
  414. strength.
  415. Example configuration files for some common configurations:
  416. 1) WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work
  417. network
  418. # allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
  419. ctrl_interface=/var/run/wpa_supplicant
  420. ctrl_interface_group=wheel
  421. #
  422. # home network; allow all valid ciphers
  423. network={
  424. ssid="home"
  425. scan_ssid=1
  426. key_mgmt=WPA-PSK
  427. psk="very secret passphrase"
  428. }
  429. #
  430. # work network; use EAP-TLS with WPA; allow only CCMP and TKIP ciphers
  431. network={
  432. ssid="work"
  433. scan_ssid=1
  434. key_mgmt=WPA-EAP
  435. pairwise=CCMP TKIP
  436. group=CCMP TKIP
  437. eap=TLS
  438. identity="user@example.com"
  439. ca_cert="/etc/cert/ca.pem"
  440. client_cert="/etc/cert/user.pem"
  441. private_key="/etc/cert/user.prv"
  442. private_key_passwd="password"
  443. }
  444. 2) WPA-RADIUS/EAP-PEAP/MSCHAPv2 with RADIUS servers that use old peaplabel
  445. (e.g., Funk Odyssey and SBR, Meetinghouse Aegis, Interlink RAD-Series)
  446. ctrl_interface=/var/run/wpa_supplicant
  447. ctrl_interface_group=wheel
  448. network={
  449. ssid="example"
  450. scan_ssid=1
  451. key_mgmt=WPA-EAP
  452. eap=PEAP
  453. identity="user@example.com"
  454. password="foobar"
  455. ca_cert="/etc/cert/ca.pem"
  456. phase1="peaplabel=0"
  457. phase2="auth=MSCHAPV2"
  458. }
  459. 3) EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
  460. unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
  461. ctrl_interface=/var/run/wpa_supplicant
  462. ctrl_interface_group=wheel
  463. network={
  464. ssid="example"
  465. scan_ssid=1
  466. key_mgmt=WPA-EAP
  467. eap=TTLS
  468. identity="user@example.com"
  469. anonymous_identity="anonymous@example.com"
  470. password="foobar"
  471. ca_cert="/etc/cert/ca.pem"
  472. phase2="auth=MD5"
  473. }
  474. 4) IEEE 802.1X (i.e., no WPA) with dynamic WEP keys (require both unicast and
  475. broadcast); use EAP-TLS for authentication
  476. ctrl_interface=/var/run/wpa_supplicant
  477. ctrl_interface_group=wheel
  478. network={
  479. ssid="1x-test"
  480. scan_ssid=1
  481. key_mgmt=IEEE8021X
  482. eap=TLS
  483. identity="user@example.com"
  484. ca_cert="/etc/cert/ca.pem"
  485. client_cert="/etc/cert/user.pem"
  486. private_key="/etc/cert/user.prv"
  487. private_key_passwd="password"
  488. eapol_flags=3
  489. }
  490. 5) Catch all example that allows more or less all configuration modes. The
  491. configuration options are used based on what security policy is used in the
  492. selected SSID. This is mostly for testing and is not recommended for normal
  493. use.
  494. ctrl_interface=/var/run/wpa_supplicant
  495. ctrl_interface_group=wheel
  496. network={
  497. ssid="example"
  498. scan_ssid=1
  499. key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
  500. pairwise=CCMP TKIP
  501. group=CCMP TKIP WEP104 WEP40
  502. psk="very secret passphrase"
  503. eap=TTLS PEAP TLS
  504. identity="user@example.com"
  505. password="foobar"
  506. ca_cert="/etc/cert/ca.pem"
  507. client_cert="/etc/cert/user.pem"
  508. private_key="/etc/cert/user.prv"
  509. private_key_passwd="password"
  510. phase1="peaplabel=0"
  511. ca_cert2="/etc/cert/ca2.pem"
  512. client_cert2="/etc/cer/user.pem"
  513. private_key2="/etc/cer/user.prv"
  514. private_key2_passwd="password"
  515. }
  516. 6) Authentication for wired Ethernet. This can be used with 'wired' or
  517. 'roboswitch' interface (-Dwired or -Droboswitch on command line).
  518. ctrl_interface=/var/run/wpa_supplicant
  519. ctrl_interface_group=wheel
  520. ap_scan=0
  521. network={
  522. key_mgmt=IEEE8021X
  523. eap=MD5
  524. identity="user"
  525. password="password"
  526. eapol_flags=0
  527. }
  528. Certificates
  529. ------------
  530. Some EAP authentication methods require use of certificates. EAP-TLS
  531. uses both server side and client certificates whereas EAP-PEAP and
  532. EAP-TTLS only require the server side certificate. When client
  533. certificate is used, a matching private key file has to also be
  534. included in configuration. If the private key uses a passphrase, this
  535. has to be configured in wpa_supplicant.conf ("private_key_passwd").
  536. wpa_supplicant supports X.509 certificates in PEM and DER
  537. formats. User certificate and private key can be included in the same
  538. file.
  539. If the user certificate and private key is received in PKCS#12/PFX
  540. format, they need to be converted to suitable PEM/DER format for
  541. wpa_supplicant. This can be done, e.g., with following commands:
  542. # convert client certificate and private key to PEM format
  543. openssl pkcs12 -in example.pfx -out user.pem -clcerts
  544. # convert CA certificate (if included in PFX file) to PEM format
  545. openssl pkcs12 -in example.pfx -out ca.pem -cacerts -nokeys
  546. wpa_cli
  547. -------
  548. wpa_cli is a text-based frontend program for interacting with
  549. wpa_supplicant. It is used to query current status, change
  550. configuration, trigger events, and request interactive user input.
  551. wpa_cli can show the current authentication status, selected security
  552. mode, dot11 and dot1x MIBs, etc. In addition, it can configure some
  553. variables like EAPOL state machine parameters and trigger events like
  554. reassociation and IEEE 802.1X logoff/logon. wpa_cli provides a user
  555. interface to request authentication information, like username and
  556. password, if these are not included in the configuration. This can be
  557. used to implement, e.g., one-time-passwords or generic token card
  558. authentication where the authentication is based on a
  559. challenge-response that uses an external device for generating the
  560. response.
  561. The control interface of wpa_supplicant can be configured to allow
  562. non-root user access (ctrl_interface_group in the configuration
  563. file). This makes it possible to run wpa_cli with a normal user
  564. account.
  565. wpa_cli supports two modes: interactive and command line. Both modes
  566. share the same command set and the main difference is in interactive
  567. mode providing access to unsolicited messages (event messages,
  568. username/password requests).
  569. Interactive mode is started when wpa_cli is executed without including
  570. the command as a command line parameter. Commands are then entered on
  571. the wpa_cli prompt. In command line mode, the same commands are
  572. entered as command line arguments for wpa_cli.
  573. Interactive authentication parameters request
  574. When wpa_supplicant need authentication parameters, like username and
  575. password, which are not present in the configuration file, it sends a
  576. request message to all attached frontend programs, e.g., wpa_cli in
  577. interactive mode. wpa_cli shows these requests with
  578. "CTRL-REQ-<type>-<id>:<text>" prefix. <type> is IDENTITY, PASSWORD, or
  579. OTP (one-time-password). <id> is a unique identifier for the current
  580. network. <text> is description of the request. In case of OTP request,
  581. it includes the challenge from the authentication server.
  582. The reply to these requests can be given with 'identity', 'password',
  583. and 'otp' commands. <id> needs to be copied from the the matching
  584. request. 'password' and 'otp' commands can be used regardless of
  585. whether the request was for PASSWORD or OTP. The main difference
  586. between these two commands is that values given with 'password' are
  587. remembered as long as wpa_supplicant is running whereas values given
  588. with 'otp' are used only once and then forgotten, i.e., wpa_supplicant
  589. will ask frontend for a new value for every use. This can be used to
  590. implement one-time-password lists and generic token card -based
  591. authentication.
  592. Example request for password and a matching reply:
  593. CTRL-REQ-PASSWORD-1:Password needed for SSID foobar
  594. > password 1 mysecretpassword
  595. Example request for generic token card challenge-response:
  596. CTRL-REQ-OTP-2:Challenge 1235663 needed for SSID foobar
  597. > otp 2 9876
  598. wpa_cli commands
  599. status = get current WPA/EAPOL/EAP status
  600. mib = get MIB variables (dot1x, dot11)
  601. help = show this usage help
  602. interface [ifname] = show interfaces/select interface
  603. level <debug level> = change debug level
  604. license = show full wpa_cli license
  605. logoff = IEEE 802.1X EAPOL state machine logoff
  606. logon = IEEE 802.1X EAPOL state machine logon
  607. set = set variables (shows list of variables when run without arguments)
  608. pmksa = show PMKSA cache
  609. reassociate = force reassociation
  610. reconfigure = force wpa_supplicant to re-read its configuration file
  611. preauthenticate <BSSID> = force preauthentication
  612. identity <network id> <identity> = configure identity for an SSID
  613. password <network id> <password> = configure password for an SSID
  614. pin <network id> <pin> = configure pin for an SSID
  615. otp <network id> <password> = configure one-time-password for an SSID
  616. passphrase <network id> <passphrase> = configure private key passphrase
  617. for an SSID
  618. bssid <network id> <BSSID> = set preferred BSSID for an SSID
  619. list_networks = list configured networks
  620. select_network <network id> = select a network (disable others)
  621. enable_network <network id> = enable a network
  622. disable_network <network id> = disable a network
  623. add_network = add a network
  624. remove_network <network id> = remove a network
  625. set_network <network id> <variable> <value> = set network variables (shows
  626. list of variables when run without arguments)
  627. get_network <network id> <variable> = get network variables
  628. save_config = save the current configuration
  629. disconnect = disconnect and wait for reassociate command before connecting
  630. scan = request new BSS scan
  631. scan_results = get latest scan results
  632. get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
  633. terminate = terminate wpa_supplicant
  634. quit = exit wpa_cli
  635. wpa_cli command line options
  636. wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] [-a<action file>] \
  637. [-P<pid file>] [-g<global ctrl>] [command..]
  638. -h = help (show this usage text)
  639. -v = shown version information
  640. -a = run in daemon mode executing the action file based on events from
  641. wpa_supplicant
  642. -B = run a daemon in the background
  643. default path: /var/run/wpa_supplicant
  644. default interface: first interface found in socket path
  645. Using wpa_cli to run external program on connect/disconnect
  646. -----------------------------------------------------------
  647. wpa_cli can used to run external programs whenever wpa_supplicant
  648. connects or disconnects from a network. This can be used, e.g., to
  649. update network configuration and/or trigget DHCP client to update IP
  650. addresses, etc.
  651. One wpa_cli process in "action" mode needs to be started for each
  652. interface. For example, the following command starts wpa_cli for the
  653. default interface (-i can be used to select the interface in case of
  654. more than one interface being used at the same time):
  655. wpa_cli -a/sbin/wpa_action.sh -B
  656. The action file (-a option, /sbin/wpa_action.sh in this example) will
  657. be executed whenever wpa_supplicant completes authentication (connect
  658. event) or detects disconnection). The action script will be called
  659. with two command line arguments: interface name and event (CONNECTED
  660. or DISCONNECTED). If the action script needs to get more information
  661. about the current network, it can use 'wpa_cli status' to query
  662. wpa_supplicant for more information.
  663. Following example can be used as a simple template for an action
  664. script:
  665. #!/bin/sh
  666. IFNAME=$1
  667. CMD=$2
  668. if [ "$CMD" = "CONNECTED" ]; then
  669. SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
  670. # configure network, signal DHCP client, etc.
  671. fi
  672. if [ "$CMD" = "DISCONNECTED" ]; then
  673. # remove network configuration, if needed
  674. SSID=
  675. fi
  676. Integrating with pcmcia-cs/cardmgr scripts
  677. ------------------------------------------
  678. wpa_supplicant needs to be running when using a wireless network with
  679. WPA. It can be started either from system startup scripts or from
  680. pcmcia-cs/cardmgr scripts (when using PC Cards). WPA handshake must be
  681. completed before data frames can be exchanged, so wpa_supplicant
  682. should be started before DHCP client.
  683. For example, following small changes to pcmcia-cs scripts can be used
  684. to enable WPA support:
  685. Add MODE="Managed" and WPA="y" to the network scheme in
  686. /etc/pcmcia/wireless.opts.
  687. Add the following block to the end of 'start' action handler in
  688. /etc/pcmcia/wireless:
  689. if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
  690. /usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf \
  691. -i$DEVICE
  692. fi
  693. Add the following block to the end of 'stop' action handler (may need
  694. to be separated from other actions) in /etc/pcmcia/wireless:
  695. if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
  696. killall wpa_supplicant
  697. fi
  698. This will make cardmgr start wpa_supplicant when the card is plugged
  699. in.
  700. Dynamic interface add and operation without configuration files
  701. ---------------------------------------------------------------
  702. wpa_supplicant can be started without any configuration files or
  703. network interfaces. When used in this way, a global (i.e., per
  704. wpa_supplicant process) control interface is used to add and remove
  705. network interfaces. Each network interface can then be configured
  706. through a per-network interface control interface. For example,
  707. following commands show how to start wpa_supplicant without any
  708. network interfaces and then add a network interface and configure a
  709. network (SSID):
  710. # Start wpa_supplicant in the background
  711. wpa_supplicant -g/var/run/wpa_supplicant-global -B
  712. # Add a new interface (wlan0, no configuration file, driver=nl80211, and
  713. # enable control interface)
  714. wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan0 \
  715. "" nl80211 /var/run/wpa_supplicant
  716. # Configure a network using the newly added network interface:
  717. wpa_cli -iwlan0 add_network
  718. wpa_cli -iwlan0 set_network 0 ssid '"test"'
  719. wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
  720. wpa_cli -iwlan0 set_network 0 psk '"12345678"'
  721. wpa_cli -iwlan0 set_network 0 pairwise TKIP
  722. wpa_cli -iwlan0 set_network 0 group TKIP
  723. wpa_cli -iwlan0 set_network 0 proto WPA
  724. wpa_cli -iwlan0 enable_network 0
  725. # At this point, the new network interface should start trying to associate
  726. # with the WPA-PSK network using SSID test.
  727. # Remove network interface
  728. wpa_cli -g/var/run/wpa_supplicant-global interface_remove wlan0
  729. Privilege separation
  730. --------------------
  731. To minimize the size of code that needs to be run with root privileges
  732. (e.g., to control wireless interface operation), wpa_supplicant
  733. supports optional privilege separation. If enabled, this separates the
  734. privileged operations into a separate process (wpa_priv) while leaving
  735. rest of the code (e.g., EAP authentication and WPA handshakes) into an
  736. unprivileged process (wpa_supplicant) that can be run as non-root
  737. user. Privilege separation restricts the effects of potential software
  738. errors by containing the majority of the code in an unprivileged
  739. process to avoid full system compromise.
  740. Privilege separation is not enabled by default and it can be enabled
  741. by adding CONFIG_PRIVSEP=y to the build configuration (.config). When
  742. enabled, the privileged operations (driver wrapper and l2_packet) are
  743. linked into a separate daemon program, wpa_priv. The unprivileged
  744. program, wpa_supplicant, will be built with a special driver/l2_packet
  745. wrappers that communicate with the privileged wpa_priv process to
  746. perform the needed operations. wpa_priv can control what privileged
  747. are allowed.
  748. wpa_priv needs to be run with network admin privileges (usually, root
  749. user). It opens a UNIX domain socket for each interface that is
  750. included on the command line; any other interface will be off limits
  751. for wpa_supplicant in this kind of configuration. After this,
  752. wpa_supplicant can be run as a non-root user (e.g., all standard users
  753. on a laptop or as a special non-privileged user account created just
  754. for this purpose to limit access to user files even further).
  755. Example configuration:
  756. - create user group for users that are allowed to use wpa_supplicant
  757. ('wpapriv' in this example) and assign users that should be able to
  758. use wpa_supplicant into that group
  759. - create /var/run/wpa_priv directory for UNIX domain sockets and control
  760. user access by setting it accessible only for the wpapriv group:
  761. mkdir /var/run/wpa_priv
  762. chown root:wpapriv /var/run/wpa_priv
  763. chmod 0750 /var/run/wpa_priv
  764. - start wpa_priv as root (e.g., from system startup scripts) with the
  765. enabled interfaces configured on the command line:
  766. wpa_priv -B -P /var/run/wpa_priv.pid nl80211:wlan0
  767. - run wpa_supplicant as non-root with a user that is in wpapriv group:
  768. wpa_supplicant -i ath0 -c wpa_supplicant.conf
  769. wpa_priv does not use the network interface before wpa_supplicant is
  770. started, so it is fine to include network interfaces that are not
  771. available at the time wpa_priv is started. As an alternative, wpa_priv
  772. can be started when an interface is added (hotplug/udev/etc. scripts).
  773. wpa_priv can control multiple interface with one process, but it is
  774. also possible to run multiple wpa_priv processes at the same time, if
  775. desired.
  776. It should be noted that the interface used between wpa_supplicant and
  777. wpa_priv does not include all the capabilities of the wpa_supplicant
  778. driver interface and at times, this interface lacks update especially
  779. for recent addition. Consequently, use of wpa_priv does come with the
  780. price of somewhat reduced available functionality. The next section
  781. describing how wpa_supplicant can be used with reduced privileges
  782. without having to handle the complexity of separate wpa_priv. While that
  783. approve does not provide separation for network admin capabilities, it
  784. does allow other root privileges to be dropped without the drawbacks of
  785. the wpa_priv process.
  786. Linux capabilities instead of privileged process
  787. ------------------------------------------------
  788. wpa_supplicant performs operations that need special permissions, e.g.,
  789. to control the network connection. Traditionally this has been achieved
  790. by running wpa_supplicant as a privileged process with effective user id
  791. 0 (root). Linux capabilities can be used to provide restricted set of
  792. capabilities to match the functions needed by wpa_supplicant. The
  793. minimum set of capabilities needed for the operations is CAP_NET_ADMIN
  794. and CAP_NET_RAW.
  795. setcap(8) can be used to set file capabilities. For example:
  796. sudo setcap cap_net_raw,cap_net_admin+ep wpa_supplicant
  797. Please note that this would give anyone being able to run that
  798. wpa_supplicant binary access to the additional capabilities. This can
  799. further be limited by file owner/group and mode bits. For example:
  800. sudo chown wpas wpa_supplicant
  801. sudo chmod 0100 wpa_supplicant
  802. This combination of setcap, chown, and chmod commands would allow wpas
  803. user to execute wpa_supplicant with additional network admin/raw
  804. capabilities.
  805. Common way style of creating a control interface socket in
  806. /var/run/wpa_supplicant could not be done by this user, but this
  807. directory could be created before starting the wpa_supplicant and set to
  808. suitable mode to allow wpa_supplicant to create sockets
  809. there. Alternatively, other directory or abstract socket namespace could
  810. be used for the control interface.
  811. External requests for radio control
  812. -----------------------------------
  813. External programs can request wpa_supplicant to not start offchannel
  814. operations during other tasks that may need exclusive control of the
  815. radio. The RADIO_WORK control interface command can be used for this.
  816. "RADIO_WORK add <name> [freq=<MHz>] [timeout=<seconds>]" command can be
  817. used to reserve a slot for radio access. If freq is specified, other
  818. radio work items on the same channel may be completed in
  819. parallel. Otherwise, all other radio work items are blocked during
  820. execution. Timeout is set to 10 seconds by default to avoid blocking
  821. wpa_supplicant operations for excessive time. If a longer (or shorter)
  822. safety timeout is needed, that can be specified with the optional
  823. timeout parameter. This command returns an identifier for the radio work
  824. item.
  825. Once the radio work item has been started, "EXT-RADIO-WORK-START <id>"
  826. event message is indicated that the external processing can start. Once
  827. the operation has been completed, "RADIO_WORK done <id>" is used to
  828. indicate that to wpa_supplicant. This allows other radio works to be
  829. performed. If this command is forgotten (e.g., due to the external
  830. program terminating), wpa_supplicant will time out the radio work item
  831. and send "EXT-RADIO-WORK-TIMEOUT <id>" event to indicate that this has
  832. happened. "RADIO_WORK done <id>" can also be used to cancel items that
  833. have not yet been started.
  834. For example, in wpa_cli interactive mode:
  835. > radio_work add test
  836. 1
  837. <3>EXT-RADIO-WORK-START 1
  838. > radio_work show
  839. ext:test@wlan0:0:1:2.487797
  840. > radio_work done 1
  841. OK
  842. > radio_work show
  843. > radio_work done 3
  844. OK
  845. > radio_work show
  846. ext:test freq=2412 timeout=30@wlan0:2412:1:28.583483
  847. <3>EXT-RADIO-WORK-TIMEOUT 2
  848. > radio_work add test2 freq=2412 timeout=60
  849. 5
  850. <3>EXT-RADIO-WORK-START 5
  851. > radio_work add test3
  852. 6
  853. > radio_work add test4
  854. 7
  855. > radio_work show
  856. ext:test2 freq=2412 timeout=60@wlan0:2412:1:9.751844
  857. ext:test3@wlan0:0:0:5.071812
  858. ext:test4@wlan0:0:0:3.143870
  859. > radio_work done 6
  860. OK
  861. > radio_work show
  862. ext:test2 freq=2412 timeout=60@wlan0:2412:1:16.287869
  863. ext:test4@wlan0:0:0:9.679895
  864. > radio_work done 5
  865. OK
  866. <3>EXT-RADIO-WORK-START 7
  867. <3>EXT-RADIO-WORK-TIMEOUT 7