wireless.tex 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. The WiFi settings are configured in the file \texttt{/etc/config/wireless}
  2. (currently supported on Broadcom, Atheros and mac80211). When booting the router for the first time
  3. it should detect your card and create a sample configuration file. By default '\texttt{option network lan}' is
  4. commented. This prevents unsecured sharing of the network over the wireless interface.
  5. Each wireless driver has its own configuration script in \texttt{/lib/wifi/driver\_name.sh} which handles
  6. driver specific options and configurations. This script is also calling driver specific binaries like wlc for
  7. Broadcom, or hostapd and wpa\_supplicant for atheros.
  8. The reason for using such architecture, is that it abstracts the driver configuration.
  9. \paragraph{Generic Broadcom wireless config:}
  10. \begin{Verbatim}
  11. config wifi-device "wl0"
  12. option type "broadcom"
  13. option channel "5"
  14. config wifi-iface
  15. option device "wl0"
  16. # option network lan
  17. option mode "ap"
  18. option ssid "OpenWrt"
  19. option hidden "0"
  20. option encryption "none"
  21. \end{Verbatim}
  22. \paragraph{Generic Atheros wireless config:}
  23. \begin{Verbatim}
  24. config wifi-device "wifi0"
  25. option type "atheros"
  26. option channel "5"
  27. option agmode "11g"
  28. config wifi-iface
  29. option device "wifi0"
  30. # option network lan
  31. option mode "ap"
  32. option ssid "OpenWrt"
  33. option hidden "0"
  34. option encryption "none"
  35. \end{Verbatim}
  36. \paragraph{Generic mac80211 wireless config:}
  37. \begin{Verbatim}
  38. config wifi-device "wifi0"
  39. option type "mac80211"
  40. option channel "5"
  41. config wifi-iface
  42. option device "wlan0"
  43. # option network lan
  44. option mode "ap"
  45. option ssid "OpenWrt"
  46. option hidden "0"
  47. option encryption "none"
  48. \end{Verbatim}
  49. \paragraph{Generic multi-radio Atheros wireless config:}
  50. \begin{Verbatim}
  51. config wifi-device wifi0
  52. option type atheros
  53. option channel 1
  54. config wifi-iface
  55. option device wifi0
  56. # option network lan
  57. option mode ap
  58. option ssid OpenWrt_private
  59. option hidden 0
  60. option encryption none
  61. config wifi-device wifi1
  62. option type atheros
  63. option channel 11
  64. config wifi-iface
  65. option device wifi1
  66. # option network lan
  67. option mode ap
  68. option ssid OpenWrt_public
  69. option hidden 1
  70. option encryption none
  71. \end{Verbatim}
  72. There are two types of config sections in this file. The '\texttt{wifi-device}' refers to
  73. the physical wifi interface and '\texttt{wifi-iface}' configures a virtual interface on top
  74. of that (if supported by the driver).
  75. A full outline of the wireless configuration file with description of each field:
  76. \begin{Verbatim}
  77. config wifi-device wifi device name
  78. option type broadcom, atheros, mac80211
  79. option country us, uk, fr, de, etc.
  80. option channel 1-14
  81. option maxassoc 1-128 (broadcom only)
  82. option distance 1-n
  83. option agmode 11b, 11g, 11a, 11bg (atheros only)
  84. config wifi-iface
  85. option network the interface you want wifi to bridge with
  86. option device wifi0, wifi1, wifi2, wifiN
  87. option mode ap, sta, adhoc, monitor, or wds
  88. option ssid ssid name
  89. option bssid bssid address
  90. option encryption none, wep, psk, psk2, wpa, wpa2
  91. option key encryption key
  92. option key1 key 1
  93. option key2 key 2
  94. option key3 key 3
  95. option key4 key 4
  96. option server ip address
  97. option port port
  98. option hidden 0,1
  99. option isolate 0,1
  100. \end{Verbatim}
  101. \paragraph{Options for the \texttt{wifi-device}:}
  102. \begin{itemize}
  103. \item \texttt{type} \\
  104. The driver to use for this interface.
  105. \item \texttt{country} \\
  106. The country code used to determine the regulatory settings.
  107. \item \texttt{channel} \\
  108. The wifi channel (e.g. 1-14, depending on your country setting).
  109. \item \texttt{maxassoc} \\
  110. Optional: Maximum number of associated clients. This feature is supported only on the broadcom chipset.
  111. \item \texttt{distance} \\
  112. Optional: Distance between the ap and the furthest client in meters. This feature is supported only on the atheros chipset.
  113. \item \texttt{mode} \\
  114. The frequency band (\texttt{b}, \texttt{g}, \texttt{bg}, \texttt{a}). This feature is only supported on the atheros chipset.
  115. \item \texttt{diversity} \\
  116. Optional: Enable diversity for the Wi-Fi device. This feature is supported only on the atheros chipset.
  117. \item \texttt{rxanteanna} \\
  118. Optional: Antenna identifier (0, 1 or 2) for reception. This feature is supported only on the atheros chipset.
  119. \item \texttt{txanteanna} \\
  120. Optional: Antenna identifier (0, 1 or 2) for emission. This feature is supported only on the atheros chipset.
  121. \end{itemize}
  122. \paragraph{Options for the \texttt{wifi-iface}:}
  123. \begin{itemize}
  124. \item \texttt{network} \\
  125. Selects the interface section from \texttt{/etc/config/network} to be
  126. used with this interface
  127. \item \texttt{device} \\
  128. Set the wifi device name.
  129. \item \texttt{mode} \\
  130. Operating mode:
  131. \begin{itemize}
  132. \item \texttt{ap} \\
  133. Access point mode
  134. \item \texttt{sta} \\
  135. Client mode
  136. \item \texttt{adhoc} \\
  137. Ad-Hoc mode
  138. \item \texttt{monitor} \\
  139. Monitor mode
  140. \item \texttt{wds} \\
  141. WDS point-to-point link
  142. \end{itemize}
  143. \item \texttt{ssid}
  144. Set the SSID to be used on the wifi device.
  145. \item \texttt{bssid}
  146. Set the BSSID address to be used for wds to set the mac address of the other wds unit.
  147. \item \texttt{encryption} \\
  148. Encryption setting. Accepts the following values:
  149. \begin{itemize}
  150. \item \texttt{none}
  151. \item \texttt{wep}
  152. \item \texttt{psk}, \texttt{psk2} \\
  153. WPA(2) Pre-shared Key
  154. \item \texttt{wpa}, \texttt{wpa2} \\
  155. WPA(2) RADIUS
  156. \end{itemize}
  157. \item \texttt{key, key1, key2, key3, key4} (wep, wpa and psk) \\
  158. WEP key, WPA key (PSK mode) or the RADIUS shared secret (WPA RADIUS mode)
  159. \item \texttt{server} (wpa) \\
  160. The RADIUS server ip address
  161. \item \texttt{port} (wpa) \\
  162. The RADIUS server port (defaults to 1812)
  163. \item \texttt{hidden} \\
  164. 0 broadcasts the ssid; 1 disables broadcasting of the ssid
  165. \item \texttt{isolate} \\
  166. Optional: Isolation is a mode usually set on hotspots that limits the clients to communicate only with the AP and not with other wireless clients.
  167. 0 disables ap isolation (default); 1 enables ap isolation.
  168. \end{itemize}
  169. \paragraph{Wireless Distribution System}
  170. WDS is a non-standard mode which will be working between two Broadcom devices for instance
  171. but not between a Broadcom and Atheros device.
  172. \subparagraph{Unencrypted WDS connections}
  173. This configuration example shows you how to setup unencrypted WDS connections.
  174. We assume that the peer configured as below as the BSSID ca:fe:ba:be:00:01
  175. and the remote WDS endpoint ca:fe:ba:be:00:02 (option bssid field).
  176. \begin{Verbatim}
  177. config wifi-device "wl0"
  178. option type "broadcom"
  179. option channel "5"
  180. config wifi-iface
  181. option device "wl0"
  182. option network lan
  183. option mode "ap"
  184. option ssid "OpenWrt"
  185. option hidden "0"
  186. option encryption "none"
  187. config wifi-iface
  188. option device "wl0"
  189. option network lan
  190. option mode wds
  191. option ssid "OpenWrt WDS"
  192. option bssid "ca:fe:ba:be:00:02"
  193. \end{Verbatim}
  194. \subparagraph{Encrypted WDS connections}
  195. It is also possible to encrypt WDS connections. \texttt{psk}, \texttt{psk2} and
  196. \texttt{psk+psk2} modes are supported. Configuration below is an example
  197. configuration using Pre-Shared-Keys with AES algorithm.
  198. \begin{Verbatim}
  199. config wifi-device wl0
  200. option type broadcom
  201. option channel 5
  202. config wifi-iface
  203. option device "wl0"
  204. option network lan
  205. option mode ap
  206. option ssid "OpenWrt"
  207. option encryption psk2
  208. option key "<key for clients>"
  209. config wifi-iface
  210. option device "wl0"
  211. option network lan
  212. option mode wds
  213. option bssid ca:fe:ba:be:00:02
  214. option ssid "OpenWrt WDS"
  215. option encryption psk2
  216. option key "<psk for WDS>"
  217. \end{Verbatim}
  218. \paragraph{802.1x configurations}
  219. OpenWrt supports both 802.1x client and Access Point
  220. configurations. 802.1x client is only working with
  221. Atheros or mac80211 drivers. Configuration only
  222. supports EAP types TLS, TTLS or PEAP.
  223. \subparagraph{EAP-TLS}
  224. \begin{Verbatim}
  225. config wifi-iface
  226. option device "ath0"
  227. option network lan
  228. option ssid OpenWrt
  229. option eap_type tls
  230. option ca_cert "/etc/config/certs/ca.crt"
  231. option priv_key "/etc/config/certs/priv.crt"
  232. option priv_key_pwd "PKCS#12 passphrase"
  233. \end{Verbatim}
  234. \subparagraph{EAP-PEAP}
  235. \begin{Verbatim}
  236. config wifi-iface
  237. option device "ath0"
  238. option network lan
  239. option ssid OpenWrt
  240. option eap_type peap
  241. option ca_cert "/etc/config/certs/ca.crt"
  242. option auth MSCHAPV2
  243. option identity username
  244. option password password
  245. \end{Verbatim}
  246. \paragraph{Limitations:}
  247. There are certain limitations when combining modes.
  248. Only the following mode combinations are supported:
  249. \begin{itemize}
  250. \item \textbf{Broadcom}: \\
  251. \begin{itemize}
  252. \item 1x \texttt{sta}, 0-3x \texttt{ap}
  253. \item 1-4x \texttt{ap}
  254. \item 1x \texttt{adhoc}
  255. \item 1x \texttt{monitor}
  256. \end{itemize}
  257. WDS links can only be used in pure AP mode and cannot use WEP (except when sharing the
  258. settings with the master interface, which is done automatically).
  259. \item \textbf{Atheros}: \\
  260. \begin{itemize}
  261. \item 1x \texttt{sta}, 0-Nx \texttt{ap}
  262. \item 1-Nx \texttt{ap}
  263. \item 1x \texttt{adhoc}
  264. \end{itemize}
  265. N is the maximum number of VAPs that the module allows, it defaults to 4, but can be
  266. changed by loading the module with the maxvaps=N parameter.
  267. \end{itemize}
  268. \paragraph{Adding a new driver configuration}
  269. Since we currently only support thread different wireless drivers : Broadcom, Atheros and mac80211,
  270. you might be interested in adding support for another driver like Ralink RT2x00,
  271. Texas Instruments ACX100/111.
  272. The driver specific script should be placed in \texttt{/lib/wifi/<driver>.sh} and has to
  273. include several functions providing :
  274. \begin{itemize}
  275. \item detection of the driver presence
  276. \item enabling/disabling the wifi interface(s)
  277. \item configuration reading and setting
  278. \item third-party programs calling (nas, supplicant)
  279. \end{itemize}
  280. Each driver script should append the driver to a global DRIVERS variable :
  281. \begin{Verbatim}
  282. append DRIVERS "driver name"
  283. \end{Verbatim}
  284. \subparagraph{\texttt{scan\_<driver>}}
  285. This function will parse the \texttt{/etc/config/wireless} and make sure there
  286. are no configuration incompatibilities, like enabling hidden SSIDS with ad-hoc mode
  287. for instance. This can be more complex if your driver supports a lof of configuration
  288. options. It does not change the state of the interface.
  289. Example:
  290. \begin{Verbatim}
  291. scan_dummy() {
  292. local device="$1"
  293. config_get vifs "$device" vifs
  294. for vif in $vifs; do
  295. # check config consistency for wifi-iface sections
  296. done
  297. # check mode combination
  298. }
  299. \end{Verbatim}
  300. \subparagraph{\texttt{enable\_<driver>}}
  301. This function will bring up the wifi device and optionally create application specific
  302. configuration files, e.g. for the WPA authenticator or supplicant.
  303. Example:
  304. \begin{Verbatim}
  305. enable_dummy() {
  306. local device="$1"
  307. config_get vifs "$device" vifs
  308. for vif in $vifs; do
  309. # bring up virtual interface belonging to
  310. # the wifi-device "$device"
  311. done
  312. }
  313. \end{Verbatim}
  314. \subparagraph{\texttt{disable\_<driver>}}
  315. This function will bring down the wifi device and all its virtual interfaces (if supported).
  316. Example:
  317. \begin{Verbatim}
  318. disable_dummy() {
  319. local device="$1"
  320. # bring down virtual interfaces belonging to
  321. # "$device" regardless of whether they are
  322. # configured or not. Don't rely on the vifs
  323. # variable at this point
  324. }
  325. \end{Verbatim}
  326. \subparagraph{\texttt{detect\_<driver>}}
  327. This function looks for interfaces that are usable with the driver. Template config sections
  328. for new devices should be written to stdout. Must check for already existing config sections
  329. belonging to the interfaces before creating new templates.
  330. Example:
  331. \begin{Verbatim}
  332. detect_dummy() {
  333. [ wifi-device = "$(config_get dummydev type)" ] && return 0
  334. cat <<EOF
  335. config wifi-device dummydev
  336. option type dummy
  337. # REMOVE THIS LINE TO ENABLE WIFI:
  338. option disabled 1
  339. config wifi-iface
  340. option device dummydev
  341. option mode ap
  342. option ssid OpenWrt
  343. EOF
  344. }
  345. \end{Verbatim}