wireless.tex 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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. \end{itemize}
  116. \paragraph{Options for the \texttt{wifi-iface}:}
  117. \begin{itemize}
  118. \item \texttt{network} \\
  119. Selects the interface section from \texttt{/etc/config/network} to be
  120. used with this interface
  121. \item \texttt{device} \\
  122. Set the wifi device name.
  123. \item \texttt{mode} \\
  124. Operating mode:
  125. \begin{itemize}
  126. \item \texttt{ap} \\
  127. Access point mode
  128. \item \texttt{sta} \\
  129. Client mode
  130. \item \texttt{adhoc} \\
  131. Ad-Hoc mode
  132. \item \texttt{monitor} \\
  133. Monitor mode
  134. \item \texttt{wds} \\
  135. WDS point-to-point link
  136. \end{itemize}
  137. \item \texttt{ssid}
  138. Set the SSID to be used on the wifi device.
  139. \item \texttt{bssid}
  140. Set the BSSID address to be used for wds to set the mac address of the other wds unit.
  141. \item \texttt{encryption} \\
  142. Encryption setting. Accepts the following values:
  143. \begin{itemize}
  144. \item \texttt{none}
  145. \item \texttt{wep}
  146. \item \texttt{psk}, \texttt{psk2} \\
  147. WPA(2) Pre-shared Key
  148. \item \texttt{wpa}, \texttt{wpa2} \\
  149. WPA(2) RADIUS
  150. \end{itemize}
  151. \item \texttt{key, key1, key2, key3, key4} (wep, wpa and psk) \\
  152. WEP key, WPA key (PSK mode) or the RADIUS shared secret (WPA RADIUS mode)
  153. \item \texttt{server} (wpa) \\
  154. The RADIUS server ip address
  155. \item \texttt{port} (wpa) \\
  156. The RADIUS server port (defaults to 1812)
  157. \item \texttt{hidden} \\
  158. 0 broadcasts the ssid; 1 disables broadcasting of the ssid
  159. \item \texttt{isolate} \\
  160. 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.
  161. 0 disables ap isolation (default); 1 enables ap isolation.
  162. \end{itemize}
  163. \paragraph{Wireless Distribution System}
  164. WDS is a non-standard mode which will be working between two Broadcom devices for instance
  165. but not between a Broadcom and Atheros device.
  166. \subparagraph{Unencrypted WDS connections}
  167. This configuration example shows you how to setup unencrypted WDS connections.
  168. We assume that the peer configured as below as the BSSID ca:fe:ba:be:00:01
  169. and the remote WDS endpoint ca:fe:ba:be:00:02 (option bssid field).
  170. \begin{Verbatim}
  171. config wifi-device "wl0"
  172. option type "broadcom"
  173. option channel "5"
  174. config wifi-iface
  175. option device "wl0"
  176. option network lan
  177. option mode "ap"
  178. option ssid "OpenWrt"
  179. option hidden "0"
  180. option encryption "none"
  181. config wifi-iface
  182. option device "wl0"
  183. option network lan
  184. option mode wds
  185. option ssid "OpenWrt WDS"
  186. option bssid "ca:fe:ba:be:00:02"
  187. \end{Verbatim}
  188. \subparagraph{Encrypted WDS connections}
  189. It is also possible to encrypt WDS connections. \texttt{psk}, \texttt{psk2} and
  190. \texttt{psk+psk2} modes are supported. Configuration below is an example
  191. configuration using Pre-Shared-Keys with AES algorithm.
  192. \begin{Verbatim}
  193. config wifi-device wl0
  194. option type broadcom
  195. option channel 5
  196. config wifi-iface
  197. option device "wl0"
  198. option network lan
  199. option mode ap
  200. option ssid "OpenWrt"
  201. option encryption psk2
  202. option key "<key for clients>"
  203. config wifi-iface
  204. option device "wl0"
  205. option network lan
  206. option mode wds
  207. option bssid ca:fe:ba:be:00:02
  208. option ssid "OpenWrt WDS"
  209. option encryption psk2
  210. option key "<psk for WDS>"
  211. \end{Verbatim}
  212. \paragraph{Limitations:}
  213. There are certain limitations when combining modes.
  214. Only the following mode combinations are supported:
  215. \begin{itemize}
  216. \item \textbf{Broadcom}: \\
  217. \begin{itemize}
  218. \item 1x \texttt{sta}, 0-3x \texttt{ap}
  219. \item 1-4x \texttt{ap}
  220. \item 1x \texttt{adhoc}
  221. \item 1x \texttt{monitor}
  222. \end{itemize}
  223. WDS links can only be used in pure AP mode and cannot use WEP (except when sharing the
  224. settings with the master interface, which is done automatically).
  225. \item \textbf{Atheros}: \\
  226. \begin{itemize}
  227. \item 1x \texttt{sta}, 0-Nx \texttt{ap}
  228. \item 1-Nx \texttt{ap}
  229. \item 1x \texttt{adhoc}
  230. \end{itemize}
  231. N is the maximum number of VAPs that the module allows, it defaults to 4, but can be
  232. changed by loading the module with the maxvaps=N parameter.
  233. \end{itemize}
  234. \paragraph{Adding a new driver configuration}
  235. Since we currently only support thread different wireless drivers : Broadcom, Atheros and mac80211,
  236. you might be interested in adding support for another driver like Ralink RT2x00,
  237. Texas Instruments ACX100/111.
  238. The driver specific script should be placed in \texttt{/lib/wifi/<driver>.sh} and has to
  239. include several functions providing :
  240. \begin{itemize}
  241. \item detection of the driver presence
  242. \item enabling/disabling the wifi interface(s)
  243. \item configuration reading and setting
  244. \item third-party programs calling (nas, supplicant)
  245. \end{itemize}
  246. Each driver script should append the driver to a global DRIVERS variable :
  247. \begin{Verbatim}
  248. append DRIVERS "driver name"
  249. \end{Verbatim}
  250. \subparagraph{\texttt{scan\_<driver>}}
  251. This function will parse the \texttt{/etc/config/wireless} and make sure there
  252. are no configuration incompatibilities, like enabling hidden SSIDS with ad-hoc mode
  253. for instance. This can be more complex if your driver supports a lof of configuration
  254. options. It does not change the state of the interface.
  255. Example:
  256. \begin{Verbatim}
  257. scan_dummy() {
  258. local device="$1"
  259. config_get vifs "$device" vifs
  260. for vif in $vifs; do
  261. # check config consistency for wifi-iface sections
  262. done
  263. # check mode combination
  264. }
  265. \end{Verbatim}
  266. \subparagraph{\texttt{enable\_<driver>}}
  267. This function will bring up the wifi device and optionally create application specific
  268. configuration files, e.g. for the WPA authenticator or supplicant.
  269. Example:
  270. \begin{Verbatim}
  271. enable_dummy() {
  272. local device="$1"
  273. config_get vifs "$device" vifs
  274. for vif in $vifs; do
  275. # bring up virtual interface belonging to
  276. # the wifi-device "$device"
  277. done
  278. }
  279. \end{Verbatim}
  280. \subparagraph{\texttt{disable\_<driver>}}
  281. This function will bring down the wifi device and all its virtual interfaces (if supported).
  282. Example:
  283. \begin{Verbatim}
  284. disable_dummy() {
  285. local device="$1"
  286. # bring down virtual interfaces belonging to
  287. # "$device" regardless of whether they are
  288. # configured or not. Don't rely on the vifs
  289. # variable at this point
  290. }
  291. \end{Verbatim}
  292. \subparagraph{\texttt{detect\_<driver>}}
  293. This function looks for interfaces that are usable with the driver. Template config sections
  294. for new devices should be written to stdout. Must check for already existing config sections
  295. belonging to the interfaces before creating new templates.
  296. Example:
  297. \begin{Verbatim}
  298. detect_dummy() {
  299. [ wifi-device = "$(config_get dummydev type)" ] && return 0
  300. cat <<EOF
  301. config wifi-device dummydev
  302. option type dummy
  303. # REMOVE THIS LINE TO ENABLE WIFI:
  304. option disabled 1
  305. config wifi-iface
  306. option device dummydev
  307. option mode ap
  308. option ssid OpenWrt
  309. EOF
  310. }
  311. \end{Verbatim}