wireless.tex 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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 and mac80211.
  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 hwmode "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 (meters)
  83. option hwmode 11b, 11g, 11a, 11bg (atheros, mac80211)
  84. option rxantenna 0,1,2 (atheros, broadcom)
  85. option txantenna 0,1,2 (atheros, broadcom)
  86. option txpower transmission power in dBm
  87. config wifi-iface
  88. option network the interface you want wifi to bridge with
  89. option device wifi0, wifi1, wifi2, wifiN
  90. option mode ap, sta, adhoc, monitor, mesh, or wds
  91. option txpower (deprecated) transmission power in dBm
  92. option ssid ssid name
  93. option bssid bssid address
  94. option encryption none, wep, psk, psk2, wpa, wpa2
  95. option key encryption key
  96. option key1 key 1
  97. option key2 key 2
  98. option key3 key 3
  99. option key4 key 4
  100. option server ip address
  101. option port port
  102. option hidden 0,1
  103. option isolate 0,1 (broadcom)
  104. \end{Verbatim}
  105. \paragraph{Options for the \texttt{wifi-device}:}
  106. \begin{itemize}
  107. \item \texttt{type} \\
  108. The driver to use for this interface.
  109. \item \texttt{country} \\
  110. The country code used to determine the regulatory settings.
  111. \item \texttt{channel} \\
  112. The wifi channel (e.g. 1-14, depending on your country setting).
  113. \item \texttt{maxassoc} \\
  114. Optional: Maximum number of associated clients. This feature is supported only on the Broadcom chipsets.
  115. \item \texttt{distance} \\
  116. Optional: Distance between the ap and the furthest client in meters. This feature is supported only on the Atheros chipsets.
  117. \item \texttt{mode} \\
  118. The frequency band (\texttt{b}, \texttt{g}, \texttt{bg}, \texttt{a}). This feature is only supported on the Atheros chipsets.
  119. \item \texttt{diversity} \\
  120. Optional: Enable diversity for the Wi-Fi device. This feature is supported only on the Atheros chipsets.
  121. \item \texttt{rxantenna} \\
  122. Optional: Antenna identifier (0, 1 or 2) for reception. This feature is supported by Atheros and some Broadcom chipsets.
  123. \item \texttt{txantenna} \\
  124. Optional: Antenna identifier (0, 1 or 2) for emission. This feature is supported by Atheros and some Broadcom chipsets.
  125. \item \texttt{txpower}
  126. Set the transmission power to be used. The amount is specified in dBm.
  127. \end{itemize}
  128. \paragraph{Options for the \texttt{wifi-iface}:}
  129. \begin{itemize}
  130. \item \texttt{network} \\
  131. Selects the interface section from \texttt{/etc/config/network} to be
  132. used with this interface
  133. \item \texttt{device} \\
  134. Set the wifi device name.
  135. \item \texttt{mode} \\
  136. Operating mode:
  137. \begin{itemize}
  138. \item \texttt{ap} \\
  139. Access point mode
  140. \item \texttt{sta} \\
  141. Client mode
  142. \item \texttt{adhoc} \\
  143. Ad-Hoc mode
  144. \item \texttt{monitor} \\
  145. Monitor mode
  146. \item \texttt{mesh} \\
  147. Mesh Point mode (802.11s)
  148. \item \texttt{wds} \\
  149. WDS point-to-point link
  150. \end{itemize}
  151. \item \texttt{ssid}
  152. Set the SSID to be used on the wifi device.
  153. \item \texttt{bssid}
  154. Set the BSSID address to be used for wds to set the mac address of the other wds unit.
  155. \item \texttt{txpower}
  156. (Deprecated, set in wifi-device) Set the transmission power to be used. The amount is specified in dBm.
  157. \item \texttt{encryption} \\
  158. Encryption setting. Accepts the following values:
  159. \begin{itemize}
  160. \item \texttt{none}
  161. \item \texttt{wep}
  162. \item \texttt{psk}, \texttt{psk2} \\
  163. WPA(2) Pre-shared Key
  164. \item \texttt{wpa}, \texttt{wpa2} \\
  165. WPA(2) RADIUS
  166. \end{itemize}
  167. \item \texttt{key, key1, key2, key3, key4} (wep, wpa and psk) \\
  168. WEP key, WPA key (PSK mode) or the RADIUS shared secret (WPA RADIUS mode)
  169. \item \texttt{server} (wpa) \\
  170. The RADIUS server ip address
  171. \item \texttt{port} (wpa) \\
  172. The RADIUS server port (defaults to 1812)
  173. \item \texttt{hidden} \\
  174. 0 broadcasts the ssid; 1 disables broadcasting of the ssid
  175. \item \texttt{isolate} \\
  176. 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.
  177. 0 disables ap isolation (default); 1 enables ap isolation.
  178. \end{itemize}
  179. \paragraph{Mesh Point}
  180. Mesh Point (802.11s) is only supported by some mac80211 drivers. It requires the iw package
  181. to be installed to setup mesh links. OpenWrt creates mshN mesh point interfaces. A sample
  182. configuration looks like this:
  183. \begin{Verbatim}
  184. config wifi-device "wlan0"
  185. option type "mac80211"
  186. option channel "5"
  187. config wifi-iface
  188. option device "wlan0"
  189. option network lan
  190. option mode "mesh"
  191. option mesh_id "OpenWrt"
  192. \end{Verbatim}
  193. \paragraph{Wireless Distribution System}
  194. WDS is a non-standard mode which will be working between two Broadcom devices for instance
  195. but not between a Broadcom and Atheros device.
  196. \subparagraph{Unencrypted WDS connections}
  197. This configuration example shows you how to setup unencrypted WDS connections.
  198. We assume that the peer configured as below as the BSSID ca:fe:ba:be:00:01
  199. and the remote WDS endpoint ca:fe:ba:be:00:02 (option bssid field).
  200. \begin{Verbatim}
  201. config wifi-device "wl0"
  202. option type "broadcom"
  203. option channel "5"
  204. config wifi-iface
  205. option device "wl0"
  206. option network lan
  207. option mode "ap"
  208. option ssid "OpenWrt"
  209. option hidden "0"
  210. option encryption "none"
  211. config wifi-iface
  212. option device "wl0"
  213. option network lan
  214. option mode wds
  215. option ssid "OpenWrt WDS"
  216. option bssid "ca:fe:ba:be:00:02"
  217. \end{Verbatim}
  218. \subparagraph{Encrypted WDS connections}
  219. It is also possible to encrypt WDS connections. \texttt{psk}, \texttt{psk2} and
  220. \texttt{psk+psk2} modes are supported. Configuration below is an example
  221. configuration using Pre-Shared-Keys with AES algorithm.
  222. \begin{Verbatim}
  223. config wifi-device wl0
  224. option type broadcom
  225. option channel 5
  226. config wifi-iface
  227. option device "wl0"
  228. option network lan
  229. option mode ap
  230. option ssid "OpenWrt"
  231. option encryption psk2
  232. option key "<key for clients>"
  233. config wifi-iface
  234. option device "wl0"
  235. option network lan
  236. option mode wds
  237. option bssid ca:fe:ba:be:00:02
  238. option ssid "OpenWrt WDS"
  239. option encryption psk2
  240. option key "<psk for WDS>"
  241. \end{Verbatim}
  242. \paragraph{802.1x configurations}
  243. OpenWrt supports both 802.1x client and Access Point
  244. configurations. 802.1x client is only working with
  245. drivers supported by wpa-supplicant. Configuration
  246. only supports EAP types TLS, TTLS or PEAP.
  247. \subparagraph{EAP-TLS}
  248. \begin{Verbatim}
  249. config wifi-iface
  250. option device "ath0"
  251. option network lan
  252. option ssid OpenWrt
  253. option eap_type tls
  254. option ca_cert "/etc/config/certs/ca.crt"
  255. option priv_key "/etc/config/certs/priv.crt"
  256. option priv_key_pwd "PKCS#12 passphrase"
  257. \end{Verbatim}
  258. \subparagraph{EAP-PEAP}
  259. \begin{Verbatim}
  260. config wifi-iface
  261. option device "ath0"
  262. option network lan
  263. option ssid OpenWrt
  264. option eap_type peap
  265. option ca_cert "/etc/config/certs/ca.crt"
  266. option auth MSCHAPV2
  267. option identity username
  268. option password password
  269. \end{Verbatim}
  270. \paragraph{Limitations:}
  271. There are certain limitations when combining modes.
  272. Only the following mode combinations are supported:
  273. \begin{itemize}
  274. \item \textbf{Broadcom}: \\
  275. \begin{itemize}
  276. \item 1x \texttt{sta}, 0-3x \texttt{ap}
  277. \item 1-4x \texttt{ap}
  278. \item 1x \texttt{adhoc}
  279. \item 1x \texttt{monitor}
  280. \end{itemize}
  281. WDS links can only be used in pure AP mode and cannot use WEP (except when sharing the
  282. settings with the master interface, which is done automatically).
  283. \item \textbf{Atheros}: \\
  284. \begin{itemize}
  285. \item 1x \texttt{sta}, 0-Nx \texttt{ap}
  286. \item 1-Nx \texttt{ap}
  287. \item 1x \texttt{adhoc}
  288. \end{itemize}
  289. N is the maximum number of VAPs that the module allows, it defaults to 4, but can be
  290. changed by loading the module with the maxvaps=N parameter.
  291. \end{itemize}
  292. \paragraph{Adding a new driver configuration}
  293. Since we currently only support thread different wireless drivers : Broadcom, Atheros and mac80211,
  294. you might be interested in adding support for another driver like Ralink RT2x00,
  295. Texas Instruments ACX100/111.
  296. The driver specific script should be placed in \texttt{/lib/wifi/<driver>.sh} and has to
  297. include several functions providing :
  298. \begin{itemize}
  299. \item detection of the driver presence
  300. \item enabling/disabling the wifi interface(s)
  301. \item configuration reading and setting
  302. \item third-party programs calling (nas, supplicant)
  303. \end{itemize}
  304. Each driver script should append the driver to a global DRIVERS variable :
  305. \begin{Verbatim}
  306. append DRIVERS "driver name"
  307. \end{Verbatim}
  308. \subparagraph{\texttt{scan\_<driver>}}
  309. This function will parse the \texttt{/etc/config/wireless} and make sure there
  310. are no configuration incompatibilities, like enabling hidden SSIDS with ad-hoc mode
  311. for instance. This can be more complex if your driver supports a lof of configuration
  312. options. It does not change the state of the interface.
  313. Example:
  314. \begin{Verbatim}
  315. scan_dummy() {
  316. local device="$1"
  317. config_get vifs "$device" vifs
  318. for vif in $vifs; do
  319. # check config consistency for wifi-iface sections
  320. done
  321. # check mode combination
  322. }
  323. \end{Verbatim}
  324. \subparagraph{\texttt{enable\_<driver>}}
  325. This function will bring up the wifi device and optionally create application specific
  326. configuration files, e.g. for the WPA authenticator or supplicant.
  327. Example:
  328. \begin{Verbatim}
  329. enable_dummy() {
  330. local device="$1"
  331. config_get vifs "$device" vifs
  332. for vif in $vifs; do
  333. # bring up virtual interface belonging to
  334. # the wifi-device "$device"
  335. done
  336. }
  337. \end{Verbatim}
  338. \subparagraph{\texttt{disable\_<driver>}}
  339. This function will bring down the wifi device and all its virtual interfaces (if supported).
  340. Example:
  341. \begin{Verbatim}
  342. disable_dummy() {
  343. local device="$1"
  344. # bring down virtual interfaces belonging to
  345. # "$device" regardless of whether they are
  346. # configured or not. Don't rely on the vifs
  347. # variable at this point
  348. }
  349. \end{Verbatim}
  350. \subparagraph{\texttt{detect\_<driver>}}
  351. This function looks for interfaces that are usable with the driver. Template config sections
  352. for new devices should be written to stdout. Must check for already existing config sections
  353. belonging to the interfaces before creating new templates.
  354. Example:
  355. \begin{Verbatim}
  356. detect_dummy() {
  357. [ wifi-device = "$(config_get dummydev type)" ] && return 0
  358. cat <<EOF
  359. config wifi-device dummydev
  360. option type dummy
  361. # REMOVE THIS LINE TO ENABLE WIFI:
  362. option disabled 1
  363. config wifi-iface
  364. option device dummydev
  365. option mode ap
  366. option ssid OpenWrt
  367. EOF
  368. }
  369. \end{Verbatim}