4802d32652b18109812c11388f337b1379c61f31
[ikiwiki.git] / docs / docs / newhandbook / WirelessNetwork / index.mdwn
1 [[!toc  levels=6]]
2
3 # Wireless Networking Quick Start
4
5 This section illustrates the basic procedure to connect a DragonFly system to an existing wireless network.  The next section will go into detail should that be required.
6
7 ## Use WPA Supplicant from DPorts
8
9 DragonFly comes with WPA Supplicant in base, but it is an older version (2.1) that will not be updated again.  At the time of this writing, the version of WPA Supplicant in DPorts is 2.4.  The version in base can be used as a fallback though.
10
11 ### Option 1: Install WPA Supplicant from binary package
12
13     > pkg ins wpa_supplicant
14
15 ### Option 2: Build WPA Supplicant from source
16
17 Assuming DPorts has been installed and is up to date,
18
19     > cd /usr/dports/security/wpa_supplicant
20     > make clean ; make install
21
22 ### Update /etc/rc.conf
23
24 In order to use the new WPA Supplicant over the base version, it must be configured in rc.conf .  The following will accomplish this on systems using default locations:
25
26     > echo wpa_supplicant_program="/usr/local/sbin/wpa_supplicant" >> /etc/rc.conf
27
28 ## Credentials
29
30 Obtain the SSID (Service Set Identifier) and PSK (Pre-Shared Key) for the wireless network from the network administrator.
31
32 ## Wireless Adapter
33
34 Identify the wireless adapter. The DragonFly GENERIC kernel includes drivers for many common wireless adapters. If the wireless adapter is one of those models, it will be shown in the output from ifconfig(8):
35
36     > ifconfig | grep -B3 -i wireless
37
38 If a wireless adapter is not listed, an additional kernel module might be required, or it might be a model not supported by DragonFly.  This example shows the Ralink ral0 wireless adapter.
39
40 ## Configure WPA Supplicant
41
42 Add an entry for this network to */etc/wpa_supplicant.conf*. If the file does not exist, create it. Replace _myssid_ and _mypsk_ with the SSID and PSK provided by the network administrator.
43
44     network={
45         ssid="myssid"
46         psk="mypsk"
47     }
48
49 ## Configure RC Init
50
51 Add entries to */etc/rc.conf* to configure the network on startup:
52
53     wlans_ral0="wlan0"
54     ifconfig_wlan0="WPA DHCP"
55
56 ## Start wireless service
57
58 Restart the computer, or restart the network service to connect to the network:
59
60     > service netif restart
61
62 # Unabridged Version
63
64 ## Wireless Networking Basics
65
66 [ Shamelessly plagarized from Loader, Marc Fonvieille and Murray Stokely and FreeBSD Handbook ]
67
68 Most wireless networks are based on the IEEE® 802.11 standards. A basic wireless network consists of multiple stations communicating with radios that broadcast in either the 2.4GHz or 5GHz band, though this varies according to the locale and is also changing to enable communication in the 2.3GHz and 4.9GHz ranges.
69
70 802.11 networks are organized in two ways. In infrastructure mode, one station acts as a master with all the other stations associating to it, the network is known as a BSS, and the master station is termed an access point (AP). In a BSS, all communication passes through the AP; even when one station wants to communicate with another wireless station, messages must go through the AP. In the second form of network, there is no master and stations communicate directly. This form of network is termed an IBSS and is commonly known as an ad-hoc network.
71
72 802.11 networks were first deployed in the 2.4GHz band using protocols defined by the IEEE® 802.11 and 802.11b standard. These specifications include the operating frequencies and the MAC layer characteristics, including framing and transmission rates, as communication can occur at various rates. Later, the 802.11a standard defined operation in the 5GHz band, including different signaling mechanisms and higher transmission rates. Still later, the 802.11g standard defined the use of 802.11a signaling and transmission mechanisms in the 2.4GHz band in such a way as to be backwards compatible with 802.11b networks.
73
74 Separate from the underlying transmission techniques, 802.11 networks have a variety of security mechanisms. The original 802.11 specifications defined a simple security protocol called WEP. This protocol uses a fixed pre-shared key and the RC4 cryptographic cipher to encode data transmitted on a network. Stations must all agree on the fixed key in order to communicate. This scheme was shown to be easily broken and is now rarely used except to discourage transient users from joining networks. Current security practice is given by the IEEE® 802.11i specification that defines new cryptographic ciphers and an additional protocol to authenticate stations to an access point and exchange keys for data communication. Cryptographic keys are periodically refreshed and there are mechanisms for detecting and countering intrusion attempts. Another security protocol specification commonly used in wireless networks is termed WPA, which was a precursor to 802.11i. WPA specifies a subset of the requirements found in 802.11i and is designed for implementation on legacy hardware. Specifically, WPA requires only the TKIP cipher that is derived from the original WEP cipher. 802.11i permits use of TKIP but also requires support for a stronger cipher, AES-CCM, for encrypting data. The AES cipher was not required in WPA because it was deemed too computationally costly to be implemented on legacy hardware.
75
76 The other standard to be aware of is 802.11e. It defines protocols for deploying multimedia applications, such as streaming video and voice over IP (VoIP), in an 802.11 network. Like 802.11i, 802.11e also has a precursor specification termed WME (later renamed WMM) that has been defined by an industry group as a subset of 802.11e that can be deployed now to enable multimedia applications while waiting for the final ratification of 802.11e. The most important thing to know about 802.11e and WME/WMM is that it enables prioritized traffic over a wireless network through Quality of Service (QoS) protocols and enhanced media access protocols. Proper implementation of these protocols enables high speed bursting of data and prioritized traffic flow.
77
78 DragonFly supports networks that operate using 802.11a, 802.11b, and 802.11g. The WPA and 802.11i security protocols are likewise supported (in conjunction with any of 11a, 11b, and 11g) and QoS and traffic prioritization required by the WME/WMM protocols are supported for a limited set of wireless devices.
79
80 ## Basic Setup
81
82 ### Kernel Configuration
83
84 In the GENERIC kernel, all supported wireless devices are built into the kernel by default.  In the normal case, nothing needs to be done.  However, a custom kernel might have all the devices commented out in its configuration, so in this case loading the module will be required for wireless support.
85
86 The most commonly used wireless devices are those that use parts made by Atheros, which will be used as an example.   These devices are supported by ath(4) and require the following line to be added to /boot/loader.conf:
87
88     if_ath_load="YES"
89
90 The Atheros driver is split up into three separate pieces: the driver (ath(4)), the hardware support layer that handles chip-specific functions (ath_hal(4)), and an algorithm for selecting the rate for transmitting frames. When this support is loaded as kernel modules, any dependencies are automatically handled. To load support for a different type of wireless device, specify the module for that device. This example is for devices based on the Intersil Prism parts (wi(4)) driver:
91
92     if_wi_load="YES"
93
94 In addition, the modules that implement cryptographic support for the security protocols to use must be loaded. These are intended to be dynamically loaded on demand by the wlan(4) module, but for now they must be manually configured. The following modules are available: wlan_wep(4), wlan_ccmp(4), and wlan_tkip(4). The wlan_ccmp(4) and wlan_tkip(4) drivers are only needed when using the WPA or 802.11i security protocols. If the network does not use encryption, wlan_wep(4) support is not needed. To load these modules at boot time, add the following lines to /boot/loader.conf:
95
96     wlan_wep_load="YES"
97     wlan_ccmp_load="YES"
98     wlan_tkip_load="YES"
99
100 Once this information has been added to /boot/loader.conf, reboot the DragonFly box. Alternately, load the modules by hand using kldload(8).  Information about the wireless device should appear in the boot messages, like this:
101
102     ath0: <Atheros 5212> mem 0x88000000-0x8800ffff irq 11 at device 0.0 on cardbus1
103     ath0: [ITHREAD]
104     ath0: AR2413 mac 7.9 RF2413 phy 4.5
105
106 ## Infrastructure Mode
107
108 Infrastructure (BSS) mode is the mode that is typically used. In this mode, a number of wireless access points are connected to a wired network. Each wireless network has its own name, called the SSID. Wireless clients connect to the wireless access points.
109
110 ### How to Find Access Points
111
112 To scan for available networks, use ifconfig(8). This request may take a few moments to complete as it requires the system to switch to each available wireless frequency and probe for available access points. Only the superuser can initiate a scan:
113
114     > ifconfig wlan0 create wlandev ath0
115     > ifconfig wlan0 up scan
116     SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
117     dlinkap         00:13:46:49:41:76   11   54M -90:96   100 EPS  WPA WME
118     dragonap        00:11:95:c3:0d:ac    1   54M -83:96   100 EPS  WPA
119
120 Note: The interface must be up before it can scan. Subsequent scan requests do not require the interface to be marked as up again.
121
122 The output of a scan request lists each BSS/IBSS network found. Besides listing the name of the network, the SSID, the output also shows the BSSID, which is the MAC address of the access point. The CAPS field identifies the type of each network and the capabilities of the stations operating there:
123
124 [[!table  data="""
125 Code |Station Capability Code Meaning
126 E|Extended Service Set (ESS). Indicates that the station is part of an infrastructure network rather than an IBSS/ad-hoc network.
127 I|IBSS/ad-hoc network. Indicates that the station is part of an ad-hoc network rather than an ESS network.
128 P|Privacy. Encryption is required for all data frames exchanged within the BSS using cryptographic means such as WEP, TKIP or AES-CCMP.
129 S|Short Preamble. Indicates that the network is using short preambles, defined in 802.11b High Rate/DSSS PHY, and utilizes a 56 bit sync field rather than the 128 bit field used in long preamble mode.
130 s|Short slot time. Indicates that the 802.11g network is using a short slot time because there are no legacy (802.11b) stations present.
131 """]]
132
133 One can also display the current list of known networks with:
134
135     > ifconfig wlan0 list scan
136
137 This information may be updated automatically by the adapter or manually with a scan request. Old data is automatically removed from the cache, so over time this list may shrink unless more scans are done.
138
139 ### Basic Settings
140
141 This section provides a simple example of how to make the wireless network adapter work in DragonFly without encryption. Once familiar with these concepts, it is strongly recommend to use WPA to set up the wireless network.
142
143 There are three basic steps to configure a wireless network: select an access point, authenticate the station, and configure an IP address. The following sections discuss each step.
144
145 #### Selecting an Access Point
146
147 Most of the time, it is sufficient to let the system choose an access point using the builtin heuristics. This is the default behaviour when an interface is marked as up or it is listed in */etc/rc.conf*:
148
149     wlans_ath0="wlan0"
150     ifconfig_wlan0="DHCP"
151
152 If there are multiple access points, a specific one can be selected by its SSID:
153
154     wlans_ath0="wlan0"
155     ifconfig_wlan0="ssid your_ssid_here DHCP"
156
157 In an environment where there are multiple access points with the same SSID, which is often done to simplify roaming, it may be necessary to associate to one specific device. In this case, the BSSID of the access point can be specified, with or without the SSID:
158
159     wlans_ath0="wlan0"
160     ifconfig_wlan0="ssid your_ssid_here bssid xx:xx:xx:xx:xx:xx DHCP"
161
162 There are other ways to constrain the choice of an access point, such as limiting the set of frequencies the system will scan on. This may be useful for a multi-band wireless card as scanning all the possible channels can be time-consuming. To limit operation to a specific band, use the mode parameter:
163
164     wlans_ath0="wlan0"
165     ifconfig_wlan0="mode 11g ssid your_ssid_here DHCP"
166
167 This example will force the card to operate in 802.11g, which is defined only for 2.4GHz frequencies so any 5GHz channels will not be considered. This can also be achieved with the channel parameter, which locks operation to one specific frequency, and the chanlist parameter, to specify a list of channels for scanning. More information about these parameters can be found in ifconfig(8).
168
169 #### Authentication
170
171 Once an access point is selected, the station needs to authenticate before it can pass data. Authentication can happen in several ways. The most common scheme, open authentication, allows any station to join the network and communicate. This is the authentication to use for test purposes the first time a wireless network is setup. Other schemes require cryptographic handshakes to be completed before data traffic can flow, either using pre-shared keys or secrets, or more complex schemes that involve backend services such as RADIUS. Open authentication is the default setting. The next most common setup is WPA-PSK, also known as WPA Personal.
172
173 _Note_: If using an Apple® AirPort® Extreme base station for an access point, shared-key authentication together with a WEP key needs to be configured. This can be configured in */etc/rc.conf* or by using wpa_supplicant(8). For a single AirPort® base station, access can be configured with:
174
175     wlans_ath0="wlan0"
176     ifconfig_wlan0="authmode shared wepmode on weptxkey 1 wepkey 01234567 DHCP"
177
178 In general, shared key authentication should be avoided because it uses the WEP key material in a highly-constrained manner, making it even easier to crack the key. If WEP must be used for compatibility with legacy devices, it is better to use WEP with open authentication.
179
180 #### Getting an IP Address with DHCP
181
182 Once an access point is selected and the authentication parameters are set, an IP address must be obtained in order to communicate. Most of the time, the IP address is obtained via DHCP. To achieve that, edit */etc/rc.conf* and add DHCP to the configuration for the device:
183
184     wlans_ath0="wlan0"
185     ifconfig_wlan0="DHCP"
186
187 The wireless interface is now ready to bring up:
188
189     > service netif start
190
191 Once the interface is running, use ifconfig(8) to see the status of the interface ath0:
192
193     > ifconfig wlan0
194     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
195             ether 00:11:95:d5:43:62
196             inet 192.168.1.100 netmask 0xffffff00 broadcast 192.168.1.255
197             media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
198             status: associated
199             ssid dlinkap channel 11 (2462 Mhz 11g) bssid 00:13:46:49:41:76
200             country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
201             scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
202             roam:rate 5 protmode CTS wme burst
203
204 The *status: associated line* means that it is connected to the wireless network. The bssid *00:13:46:49:41:76* is the MAC address of the access point and authmode OPEN indicates that the communication is not encrypted.
205
206 #### Static IP Address
207
208 In an IP address cannot be obtained from a DHCP server, set a fixed IP address. Replace the DHCP keyword shown above with the address information. Be sure to retain any other parameters for selecting the access point:
209
210     wlans_ath0="wlan0"
211     ifconfig_wlan0="inet 192.168.1.100 netmask 255.255.255.0 ssid your_ssid_here"
212
213 ### WPA
214
215 Wi-Fi Protected Access (WPA) is a security protocol used together with 802.11 networks to address the lack of proper authentication and the weakness of WEP. WPA leverages the 802.1X authentication protocol and uses one of several ciphers instead of WEP for data integrity. The only cipher required by WPA is the Temporary Key Integrity Protocol (TKIP). TKIP is a cipher that extends the basic RC4 cipher used by WEP by adding integrity checking, tamper detection, and measures for responding to detected intrusions. TKIP is designed to work on legacy hardware with only software modification. It represents a compromise that improves security but is still not entirely immune to attack. WPA also specifies the AES-CCMP cipher as an alternative to TKIP, and that is preferred when possible. For this specification, the term WPA2 or RSN is commonly used.
216
217 WPA defines authentication and encryption protocols. Authentication is most commonly done using one of two techniques: by 802.1X and a backend authentication service such as RADIUS, or by a minimal handshake between the station and the access point using a pre-shared secret. The former is commonly termed WPA Enterprise and the latter is known as WPA Personal. Since most people will not set up a RADIUS backend server for their wireless network, WPA-PSK is by far the most commonly encountered configuration for WPA.
218
219 The control of the wireless connection and the key negotiation or authentication with a server is done using wpa_supplicant(8). This program requires a configuration file, */etc/wpa_supplicant.conf*, to run. More information regarding this file can be found in wpa_supplicant.conf(5).
220  
221 #### WPA-PSK
222
223 WPA-PSK, also known as WPA Personal, is based on a pre-shared key (PSK) which is generated from a given password and used as the master key in the wireless network. This means every wireless user will share the same key. WPA-PSK is intended for small networks where the use of an authentication server is not possible or desired.
224
225 The first step is the configuration of */etc/wpa_supplicant.conf* with the SSID and the pre-shared key of the network:
226
227     network={
228       ssid="dragonap"
229       psk="dragonmall"
230     }
231
232 Then, in */etc/rc.conf*, indicate that the wireless device configuration will be done with WPA and the IP address will be obtained with DHCP:
233
234     wlans_ath0="wlan0"
235     ifconfig_wlan0="WPA DHCP"
236
237 Then, bring up the interface:
238
239     > service netif start
240     Starting wpa_supplicant.
241     DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
242     DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
243     DHCPOFFER from 192.168.0.1
244     DHCPREQUEST on wlan0 to 255.255.255.255 port 67
245     DHCPACK from 192.168.0.1
246     bound to 192.168.0.254 -- renewal in 300 seconds.
247     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
248           ether 00:11:95:d5:43:62
249           inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
250           media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
251           status: associated
252           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
253           country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
254           AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
255           bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
256           wme burst roaming MANUAL
257
258 Or, try to configure the interface manually using the information in */etc/wpa_supplicant.conf*:
259
260     > wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
261     Trying to associate with 00:11:95:c3:0d:ac (SSID='dragonap' freq=2412 MHz)
262     Associated with 00:11:95:c3:0d:ac
263     WPA: Key negotiation completed with 00:11:95:c3:0d:ac [PTK=CCMP GTK=CCMP]
264     CTRL-EVENT-CONNECTED - Connection to 00:11:95:c3:0d:ac completed (auth) [id=0 id_str=]
265
266 The next operation is to launch dhclient(8) to get the IP address from the DHCP server:
267
268     > dhclient wlan0
269     DHCPREQUEST on wlan0 to 255.255.255.255 port 67
270     DHCPACK from 192.168.0.1
271     bound to 192.168.0.254 -- renewal in 300 seconds.
272     > ifconfig wlan0
273     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
274           ether 00:11:95:d5:43:62
275           inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
276           media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
277           status: associated
278           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
279           country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
280           AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
281           bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
282           wme burst roaming MANUAL
283
284 _Note_: If */etc/rc.conf* has an ifconfig_wlan0="DHCP" entry, dhclient(8) will be launched automatically after wpa_supplicant(8) associates with the access point.
285
286 If DHCP is not possible or desired, set a static IP address after wpa_supplicant(8) has authenticated the station:
287
288     > ifconfig wlan0 inet 192.168.0.100 netmask 255.255.255.0
289     > ifconfig wlan0
290     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
291           ether 00:11:95:d5:43:62
292           inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255
293           media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
294           status: associated
295           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
296           country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
297           AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
298           bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
299           wme burst roaming MANUAL
300
301 When DHCP is not used, the default gateway and the nameserver also have to be manually set:
302
303     > route add default your_default_router
304     > echo "nameserver your_DNS_server" >> /etc/resolv.conf
305
306 #### WPA with EAP-TLS
307
308 The second way to use WPA is with an 802.1X backend authentication server. In this case, WPA is called WPA Enterprise to differentiate it from the less secure WPA Personal. Authentication in WPA Enterprise is based on the Extensible Authentication Protocol (EAP).
309
310 EAP does not come with an encryption method. Instead, EAP is embedded inside an encrypted tunnel. There are many EAP authentication methods, but EAP-TLS, EAP-TTLS, and EAP-PEAP are the most common.
311
312 EAP with Transport Layer Security (EAP-TLS) is a well-supported wireless authentication protocol since it was the first EAP method to be certified by the Wi-Fi Alliance. EAP-TLS requires three certificates to run: the certificate of the Certificate Authority (CA) installed on all machines, the server certificate for the authentication server, and one client certificate for each wireless client. In this EAP method, both the authentication server and wireless client authenticate each other by presenting their respective certificates, and then verify that these certificates were signed by the organization's CA.
313
314 As previously, the configuration is done via */etc/wpa_supplicant.conf*:
315
316     network={
317       ssid="dragonap"                         [1]
318       proto=RSN                                [2]
319       key_mgmt=WPA-EAP                         [3]
320       eap=TLS                                  [4]
321       identity="loader"                        [5]
322       ca_cert="/etc/certs/cacert.pem"          [6]
323       client_cert="/etc/certs/clientcert.pem"  [7]
324       private_key="/etc/certs/clientkey.pem"   [8]
325       private_key_passwd="dragonmallclient"    [9]
326     }
327
328  1. This field indicates the network name (SSID).
329  2. This example uses the RSN IEEE® 802.11i protocol, also known as WPA2.
330  3. The key_mgmt line refers to the key management protocol to use. In this example, it is WPA using EAP authentication.
331  4. This field indicates the EAP method for the connection.
332  5. The identity field contains the identity string for EAP.
333  6. The ca_cert field indicates the pathname of the CA certificate file. This file is needed to verify the server certificate.
334  7. The client_cert line gives the pathname to the client certificate file. This certificate is unique to each wireless client of the network.
335  8. The private_key field is the pathname to the client certificate private key file.
336  9. The private_key_passwd field contains the passphrase for the private key.
337
338 Then, add the following lines to */etc/rc.conf*:
339
340     wlans_ath0="wlan0"
341     ifconfig_wlan0="WPA DHCP"
342
343 The next step is to bring up the interface:
344
345     > service netif start
346     Starting wpa_supplicant.
347     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
348     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
349     DHCPACK from 192.168.0.20
350     bound to 192.168.0.254 -- renewal in 300 seconds.
351     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
352           ether 00:11:95:d5:43:62
353           inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
354           media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
355           status: associated
356           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
357           country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
358           AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
359           bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
360           wme burst roaming MANUAL
361
362 It is also possible to bring up the interface manually using wpa_supplicant(8) and ifconfig(8).
363  
364 #### WPA with EAP-TTLS
365
366 With EAP-TTLS, both the authentication server and the client need a certificate. With EAP-TTLS, a client certificate is optional. This method is similar to a web server which creates a secure SSL tunnel even if visitors do not have client-side certificates. EAP-TTLS uses an encrypted TLS tunnel for safe transport of the authentication data.
367
368 The required configuration can be added to /etc/wpa_supplicant.conf:
369
370     network={
371       ssid="dragonap"
372       proto=RSN
373       key_mgmt=WPA-EAP
374       eap=TTLS                         [1]
375       identity="test"                  [2]
376       password="test"                  [3]
377       ca_cert="/etc/certs/cacert.pem"  [4]
378       phase2="auth=MD5"                [5]
379     }
380
381  1. This field specifies the EAP method for the connection.
382  2. The identity field contains the identity string for EAP authentication inside the encrypted TLS tunnel.
383  3. The password field contains the passphrase for the EAP authentication.
384  4. The ca_cert field indicates the pathname of the CA certificate file. This file is needed to verify the server certificate.
385  5. This field specifies the authentication method used in the encrypted TLS tunnel. In this example, EAP with MD5-Challenge is used. The “inner authentication” phase is often called “phase2”.
386
387 Next, add the following lines to */etc/rc.conf*:
388
389     wlans_ath0="wlan0"
390     ifconfig_wlan0="WPA DHCP"
391
392 The next step is to bring up the interface:
393
394     > service netif start
395     Starting wpa_supplicant.
396     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
397     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
398     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
399     DHCPACK from 192.168.0.20
400     bound to 192.168.0.254 -- renewal in 300 seconds.
401     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
402           ether 00:11:95:d5:43:62
403           inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
404           media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
405           status: associated
406           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
407           country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
408           AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
409           bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
410           wme burst roaming MANUAL
411  
412 #### WPA with EAP-PEAP
413
414 _Note_: PEAPv0/EAP-MSCHAPv2 is the most common PEAP method. In this chapter, the term PEAP is used to refer to that method.
415
416 Protected EAP (PEAP) is designed as an alternative to EAP-TTLS and is the most used EAP standard after EAP-TLS. In a network with mixed operating systems, PEAP should be the most supported standard after EAP-TLS.
417
418 PEAP is similar to EAP-TTLS as it uses a server-side certificate to authenticate clients by creating an encrypted TLS tunnel between the client and the authentication server, which protects the ensuing exchange of authentication information. PEAP authentication differs from EAP-TTLS as it broadcasts the username in the clear and only the password is sent in the encrypted TLS tunnel. EAP-TTLS will use the TLS tunnel for both the username and password.
419
420 Add the following lines to */etc/wpa_supplicant.conf* to configure the EAP-PEAP related settings:
421
422     network={
423       ssid="dragonap"
424       proto=RSN
425       key_mgmt=WPA-EAP
426       eap=PEAP                          [1]
427       identity="test"                   [2]
428       password="test"                   [3]
429       ca_cert="/etc/certs/cacert.pem"   [4]
430       phase1="peaplabel=0"              [5]
431       phase2="auth=MSCHAPV2"            [6]
432     }
433
434  1. This field specifies the EAP method for the connection.
435  2. The identity field contains the identity string for EAP authentication inside the encrypted TLS tunnel.
436  3. The password field contains the passphrase for the EAP authentication.
437  4. The ca_cert field indicates the pathname of the CA certificate file. This file is needed to verify the server certificate.
438  5. This field contains the parameters for the first phase of authentication, the TLS tunnel. According to the authentication server used, specify a specific label for authentication. Most of the time, the label will be “client EAP encryption” which is set by using peaplabel=0. More information can be found in wpa_supplicant.conf(5).
439  6. This field specifies the authentication protocol used in the encrypted TLS tunnel. In the case of PEAP, it is auth=MSCHAPV2.
440
441 Add the following to */etc/rc.conf*:
442
443     wlans_ath0="wlan0"
444     ifconfig_wlan0="WPA DHCP"
445
446 Then, bring up the interface:
447
448     > service netif start
449     Starting wpa_supplicant.
450     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
451     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
452     DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
453     DHCPACK from 192.168.0.20
454     bound to 192.168.0.254 -- renewal in 300 seconds.
455     wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
456           ether 00:11:95:d5:43:62
457           inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
458           media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
459           status: associated
460           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
461           country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
462           AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
463           bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
464           wme burst roaming MANUAL
465
466 ### WEP
467
468 Wired Equivalent Privacy (WEP) is part of the original 802.11 standard. There is no authentication mechanism, only a weak form of access control which is easily cracked.
469
470 WEP can be set up using ifconfig(8):
471
472     > ifconfig wlan0 create wlandev ath0
473     > ifconfig wlan0 inet 192.168.1.100 netmask 255.255.255.0 \
474       ssid my_net wepmode on weptxkey 3 wepkey 3:0x3456789012
475
476  + The *weptxkey* specifies which WEP key will be used in the transmission. This example uses the third key. This must match the setting on the access point. When unsure which key is used by the access point, try 1 (the first key) for this value.
477  + The *wepkey* selects one of the WEP keys. It should be in the format *index:key*. Key 1 is used by default; the index only needs to be set when using a key other than the first key.
478
479 _Note_: Replace the 0x3456789012 with the key configured for use on the access point.
480
481 Refer to ifconfig(8) for further information.
482
483 The wpa_supplicant(8) facility can be used to configure a wireless interface with WEP. The example above can be set up by adding the following lines to */etc/wpa_supplicant.conf*:
484                                                                      
485     network={
486       ssid="my_net"
487       key_mgmt=NONE
488       wep_key3=3456789012
489       wep_tx_keyidx=3
490     }
491
492 Then:
493
494     > wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
495     Trying to associate with 00:13:46:49:41:76 (SSID='dlinkap' freq=2437 MHz)
496     Associated with 00:13:46:49:41:76
497
498 ## Ad-hoc Mode
499
500 IBSS mode, also called ad-hoc mode, is designed for point to point connections. For example, to establish an ad-hoc network between the machines _A_ and _B_, choose two IP addresses and a SSID.
501
502 On _A_:
503
504     > ifconfig wlan0 create wlandev ath0 wlanmode adhoc
505     > ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid dragonap
506     > ifconfig wlan0
507       wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
508           ether 00:11:95:c3:0d:ac
509           inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
510           media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <adhoc>
511           status: running
512           ssid dragonap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
513           country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
514           protmode CTS wme burst
515
516 The *adhoc* parameter indicates that the interface is running in IBSS mode.
517
518 _B_ should now be able to detect _A_:
519
520     > ifconfig wlan0 create wlandev ath0 wlanmode adhoc
521     > ifconfig wlan0 up scan
522       SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
523       dragonap       02:11:95:c3:0d:ac    2   54M -64:-96  100 IS   WME
524
525 The *I* in the output confirms that _A_ is in ad-hoc mode. Now, configure _B_ with a different IP address:
526
527     > ifconfig wlan0 inet 192.168.0.2 netmask 255.255.255.0 ssid dragonap
528     > ifconfig wlan0
529       wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
530           ether 00:11:95:d5:43:62
531           inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
532           media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <adhoc>
533           status: running
534           ssid dragonap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
535           country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
536           protmode CTS wme burst
537
538 Both _A_ and _B_ are now ready to exchange information.
539
540 ## DragonFly Host Access Points
541
542 DragonFly BSD can act as an Access Point (AP) which eliminates the need to buy a hardware AP or run an ad-hoc network. This can be particularly useful when a DragonFly machine is acting as a gateway to another network such as the Internet.
543
544 ### Basic Settings
545
546 Before configuring a DragonFly machine as an AP, the kernel must be configured with the appropriate networking support for the wireless card as well as the security protocols being used. For more details, see "Basic Setup"
547
548 _Note_: The NDIS driver wrapper for Windows® drivers does not currently support AP operation. Only native DragonFly wireless drivers support AP mode.
549
550 Once wireless networking support is loaded, check if the wireless device supports the host-based access point mode, also known as hostap mode:
551
552     > ifconfig wlan0 create wlandev ath0
553     > ifconfig wlan0 list caps
554     drivercaps=6f85edc1<STA,FF,TURBOP,IBSS,HOSTAP,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,BURST,WME,WDS,BGSCAN,TXFRAG>
555     cryptocaps=1f<WEP,TKIP,AES,AES_CCM,TKIPMIC>
556
557 This output displays the card's capabilities. The HOSTAP word confirms that this wireless card can act as an AP. Various supported ciphers are also listed: WEP, TKIP, and AES. This information indicates which security protocols can be used on the AP.
558
559 The wireless device can only be put into hostap mode during the creation of the network pseudo-device, so a previously created device must be destroyed first:
560
561     > ifconfig wlan0 destroy
562
563 then regenerated with the correct option before setting the other parameters:
564
565     > ifconfig wlan0 create wlandev ath0 wlanmode hostap
566     > ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 ssid dragonap mode 11g channel 1
567
568 Use ifconfig(8) again to see the status of the wlan0 interface:
569
570     > ifconfig wlan0
571       wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
572           ether 00:11:95:c3:0d:ac
573           inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
574           media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
575           status: running
576           ssid dragonap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
577           country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
578           protmode CTS wme burst dtimperiod 1 -dfs
579
580 The hostap parameter indicates the interface is running in the host-based access point mode.
581
582 The interface configuration can be done automatically at boot time by adding the following lines to */etc/rc.conf*:
583
584     wlans_ath0="wlan0"
585     create_args_wlan0="wlanmode hostap"
586     ifconfig_wlan0="inet 192.168.0.1 netmask 255.255.255.0 ssid dragonap mode 11g channel 1"
587
588 ### Host-based Access Point Without Authentication or Encryption
589
590 Although it is not recommended to run an AP without any authentication or encryption, this is a simple way to check if the AP is working. This configuration is also important for debugging client issues.
591
592 Once the AP is configured, initiate a scan from another wireless machine to find the AP:
593
594     > ifconfig wlan0 create wlandev ath0
595     > ifconfig wlan0 up scan
596     SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
597     dragonap        00:11:95:c3:0d:ac    1   54M -66:-96  100 ES   WME
598
599 The client machine found the AP and can be associated with it:
600
601     > ifconfig wlan0 inet 192.168.0.2 netmask 255.255.255.0 ssid dragonap
602     > ifconfig wlan0
603       wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
604           ether 00:11:95:d5:43:62
605           inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
606           media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
607           status: associated
608           ssid dragonfap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
609           country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
610           scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
611           roam:rate 5 protmode CTS wme burst
612
613 ### WPA Host-based Access Point
614
615 This section focuses on setting up a DragonFly AP using the WPA security protocol. More details regarding WPA and the configuration of WPA-based wireless clients can be found in "WPA" Section.
616
617 The hostapd(8) daemon is used to deal with client authentication and key management on the WPA-enabled AP.
618
619 The following configuration operations are performed on the DragonFly machine acting as the AP. Once the AP is correctly working, hostapd(8) should be automatically enabled at boot with the following line in */etc/rc.conf*:
620
621     hostapd_enable="YES"
622
623 Before trying to configure hostapd(8), first configure the basic settings.
624
625 #### WPA-PSK
626
627 WPA-PSK is intended for small networks where the use of a backend authentication server is not possible or desired.
628
629 The configuration is done in */etc/hostapd.conf*:
630
631     interface=wlan0                   [1]
632     debug=1                           [2]
633     ctrl_interface=/var/run/hostapd   [3]
634     ctrl_interface_group=wheel        [4]
635     ssid=dragonap                     [5]
636     wpa=1                             [6]
637     wpa_passphrase=dragonmall         [7]
638     wpa_key_mgmt=WPA-PSK              [8]
639     wpa_pairwise=CCMP TKIP            [9]
640
641  1. This field indicates the wireless interface used for the AP.
642  2. This field sets the level of verbosity during the execution of hostapd(8). A value of 1 represents the minimal level.
643  3. The ctrl_interface field gives the pathname of the directory used by hostapd(8) to store its domain socket files for the communication with external programs such as hostapd_cli(8). The default value is used in this example.
644  4. The ctrl_interface_group line sets the group which is allowed to access the control interface files.
645  5. This field sets the network name.
646  6. The wpa field enables WPA and specifies which WPA authentication protocol will be required. A value of 1 configures the AP for WPA-PSK.
647  7. The wpa_passphrase field contains the ASCII passphrase for WPA authentication.
648  8. The wpa_key_mgmt line refers to the key management protocol to use. This example sets WPA-PSK.
649  9. The wpa_pairwise field indicates the set of accepted encryption algorithms by the AP. In this example, both TKIP (WPA) and CCMP (WPA2) ciphers are accepted. The CCMP cipher is an alternative to TKIP and is strongly preferred when possible. TKIP should be used solely for stations incapable of doing CCMP.
650
651 The next step is to start hostapd(8):
652
653     > service hostapd forcestart
654
655     > ifconfig wlan0
656       wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2290
657           inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
658           inet6 fe80::211:95ff:fec3:dac%ath0 prefixlen 64 scopeid 0x4
659           ether 00:11:95:c3:0d:ac
660           media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
661           status: associated
662           ssid dragonap channel 1 bssid 00:11:95:c3:0d:ac
663           authmode WPA2/802.11i privacy MIXED deftxkey 2 TKIP 2:128-bit txpowmax 36 protmode CTS dtimperiod 1 bintval 100
664
665 Once the AP is running, the clients can associate with it. See "WPA" Section for more details. It is possible to see the stations associated with the AP using *ifconfig wlan0 list sta*.
666
667 ### WEP Host-based Access Point
668
669 It is not recommended to use WEP for setting up an AP since there is no authentication mechanism and the encryption is easily cracked. Some legacy wireless cards only support WEP and these cards will only support an AP without authentication or encryption.
670
671 The wireless device can now be put into hostap mode and configured with the correct SSID and IP address:
672
673     > ifconfig wlan0 create wlandev ath0 wlanmode hostap
674     > ifconfig wlan0 inet 192.168.0.1 netmask 255.255.255.0 \
675         ssid dragonap wepmode on weptxkey 3 wepkey 3:0x3456789012 mode 11g
676
677  + The *weptxkey* indicates which WEP key will be used in the transmission. This example uses the third key as key numbering starts with 1. This parameter must be specified in order to encrypt the data.
678  + The *wepkey* sets the selected WEP key. It should be in the format *index:key*. If the index is not given, key 1 is set. The index needs to be set when using keys other than the first key.
679
680 Use ifconfig(8) to see the status of the wlan0 interface:
681
682     # ifconfig wlan0
683       wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
684           ether 00:11:95:c3:0d:ac
685           inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
686           media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
687           status: running
688           ssid dragonap channel 4 (2427 Mhz 11g) bssid 00:11:95:c3:0d:ac
689           country US ecm authmode OPEN privacy ON deftxkey 3 wepkey 3:40-bit
690           txpower 21.5 scanvalid 60 protmode CTS wme burst dtimperiod 1 -dfs
691
692 From another wireless machine, it is now possible to initiate a scan to find the AP:
693
694     > ifconfig wlan0 create wlandev ath0
695     > ifconfig wlan0 up scan
696     SSID            BSSID              CHAN RATE  S:N   INT CAPS
697     dragonfap        00:11:95:c3:0d:ac    1   54M 22:1   100 EPS
698
699 In this example, the client machine found the AP and can associate with it using the correct parameters. See "WEP" for more details.
700
701 ## Using Both Wired and Wireless Connections
702
703 A wired connection provides better performance and reliability, while a wireless connection provides flexibility and mobility. Laptop users typically want to roam seamlessly between the two types of connections.
704
705 On DragonFly, it is possible to combine two or even more network interfaces together in a “failover” fashion (see lagg(4)). This type of configuration uses the most preferred and available connection from a group of network interfaces, and the operating system switches automatically when the link state changes.
706
707 ## Troubleshooting
708
709 This section describes a number of steps to help troubleshoot common wireless networking problems.
710
711  + If the access point is not listed when scanning, check that the configuration has not limited the wireless device to a limited set of channels.
712  + If the device cannot associate with an access point, verify that the configuration matches the settings on the access point. This includes the authentication scheme and any security protocols. Simplify the configuration as much as possible. If using a security protocol such as WPA or WEP, configure the access point for open authentication and no security to see if traffic will pass.  Debugging support is provided by wpa_supplicant(8). Try running this utility manually with -dd and look at the system logs.
713  + Once the system can associate with the access point, diagnose the network configuration using tools like ping(8).
714  + There are many lower-level debugging tools. Debugging messages can be enabled in the 802.11 protocol support layer using wlandebug(8).
715
716     > wlandebug -i ath0 +scan+auth+debug+assoc
717       net.wlan.0.debug: 0 => 0xc80000<assoc,auth,scan>