View | Details | Raw Unified | Return to bug 219966
Collapse All | Expand All

(-)b/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.xml (-1 / +1 lines)
Lines 1-5263 Link Here
1
<?xml version="1.0" encoding="iso-8859-1"?>
1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!--
2
<!--
3
     The FreeBSD Documentation Project
3
     The FreeBSD Documentation Project
4
4
5
     $FreeBSD$
5
     $FreeBSD$
6
-->
6
-->
7
<chapter xmlns="http://docbook.org/ns/docbook"
7
<chapter xmlns="http://docbook.org/ns/docbook"
8
  xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
8
  xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
9
  xml:id="advanced-networking">
9
  xml:id="advanced-networking">
10
  <title>Advanced Networking</title>
10
  <title>Advanced Networking</title>
11
11
12
  <sect1 xml:id="advanced-networking-synopsis">
12
  <sect1 xml:id="advanced-networking-synopsis">
13
    <title>Synopsis</title>
13
    <title>Synopsis</title>
14
14
15
    <para>This chapter covers a number of advanced networking
15
    <para>This chapter covers a number of advanced networking
16
      topics.</para>
16
      topics.</para>
17
17
18
    <para>After reading this chapter, you will know:</para>
18
    <para>After reading this chapter, you will know:</para>
19
19
20
    <itemizedlist>
20
    <itemizedlist>
21
      <listitem>
21
      <listitem>
22
	<para>The basics of gateways and routes.</para>
22
	<para>The basics of gateways and routes.</para>
23
      </listitem>
23
      </listitem>
24
24
25
      <listitem>
25
      <listitem>
26
	<para>How to set up USB tethering.</para>
26
	<para>How to set up USB tethering.</para>
27
      </listitem>
27
      </listitem>
28
28
29
      <listitem>
29
      <listitem>
30
	<para>How to set up &ieee; 802.11 and &bluetooth;
30
	<para>How to set up &ieee; 802.11 and &bluetooth;
31
	  devices.</para>
31
	  devices.</para>
32
      </listitem>
32
      </listitem>
33
33
34
      <listitem>
34
      <listitem>
35
	<para>How to make &os; act as a bridge.</para>
35
	<para>How to make &os; act as a bridge.</para>
36
      </listitem>
36
      </listitem>
37
37
38
      <listitem>
38
      <listitem>
39
	<para>How to set up network <acronym>PXE</acronym>
39
	<para>How to set up network <acronym>PXE</acronym>
40
	  booting.</para>
40
	  booting.</para>
41
      </listitem>
41
      </listitem>
42
42
43
      <listitem>
43
      <listitem>
44
	<para>How to set up <acronym>IPv6</acronym> on a &os;
44
	<para>How to set up <acronym>IPv6</acronym> on a &os;
45
	  machine.</para>
45
	  machine.</para>
46
      </listitem>
46
      </listitem>
47
47
48
      <listitem>
48
      <listitem>
49
	<para>How to enable and utilize the features of the Common
49
	<para>How to enable and utilize the features of the Common
50
	  Address Redundancy Protocol (<acronym>CARP</acronym>) in
50
	  Address Redundancy Protocol (<acronym>CARP</acronym>) in
51
	  &os;.</para>
51
	  &os;.</para>
52
      </listitem>
52
      </listitem>
53
53
54
      <listitem>
54
      <listitem>
55
	<para>How to configure multiple <acronym>VLANs</acronym> on
55
	<para>How to configure multiple <acronym>VLANs</acronym> on
56
	  &os;.</para>
56
	  &os;.</para>
57
      </listitem>
57
      </listitem>
58
    </itemizedlist>
58
    </itemizedlist>
59
59
60
    <para>Before reading this chapter, you should:</para>
60
    <para>Before reading this chapter, you should:</para>
61
61
62
    <itemizedlist>
62
    <itemizedlist>
63
      <listitem>
63
      <listitem>
64
	<para>Understand the basics of the
64
	<para>Understand the basics of the
65
	  <filename>/etc/rc</filename> scripts.</para>
65
	  <filename>/etc/rc</filename> scripts.</para>
66
      </listitem>
66
      </listitem>
67
67
68
      <listitem>
68
      <listitem>
69
	<para>Be familiar with basic network terminology.</para>
69
	<para>Be familiar with basic network terminology.</para>
70
      </listitem>
70
      </listitem>
71
71
72
      <listitem>
72
      <listitem>
73
	<para>Know how to configure and install a new &os; kernel
73
	<para>Know how to configure and install a new &os; kernel
74
	  (<xref linkend="kernelconfig"/>).</para>
74
	  (<xref linkend="kernelconfig"/>).</para>
75
      </listitem>
75
      </listitem>
76
76
77
      <listitem>
77
      <listitem>
78
	<para>Know how to install additional third-party software
78
	<para>Know how to install additional third-party software
79
	  (<xref linkend="ports"/>).</para>
79
	  (<xref linkend="ports"/>).</para>
80
      </listitem>
80
      </listitem>
81
81
82
    </itemizedlist>
82
    </itemizedlist>
83
  </sect1>
83
  </sect1>
84
84
85
  <sect1 xml:id="network-routing">
85
  <sect1 xml:id="network-routing">
86
    <info>
86
    <info>
87
      <title>Gateways and Routes</title>
87
      <title>Gateways and Routes</title>
88
88
89
      <authorgroup>
89
      <authorgroup>
90
	<author>
90
	<author>
91
	  <personname>
91
	  <personname>
92
	    <firstname>Coranth</firstname>
92
	    <firstname>Coranth</firstname>
93
	    <surname>Gryphon</surname>
93
	    <surname>Gryphon</surname>
94
	  </personname>
94
	  </personname>
95
	  <contrib>Contributed by </contrib>
95
	  <contrib>Contributed by </contrib>
96
	</author>
96
	</author>
97
      </authorgroup>
97
      </authorgroup>
98
    </info>
98
    </info>
99
99
100
    <indexterm>
100
    <indexterm>
101
      <primary>routing</primary>
101
      <primary>routing</primary>
102
    </indexterm>
102
    </indexterm>
103
    <indexterm>
103
    <indexterm>
104
      <primary>gateway</primary>
104
      <primary>gateway</primary>
105
    </indexterm>
105
    </indexterm>
106
    <indexterm>
106
    <indexterm>
107
      <primary>subnet</primary>
107
      <primary>subnet</primary>
108
    </indexterm>
108
    </indexterm>
109
109
110
    <para><firstterm>Routing</firstterm> is the mechanism that allows
110
    <para><firstterm>Routing</firstterm> is the mechanism that allows
111
      a system to find the network path to another system.  A
111
      a system to find the network path to another system.  A
112
      <firstterm>route</firstterm> is a defined pair of addresses
112
      <firstterm>route</firstterm> is a defined pair of addresses
113
      which represent the <quote>destination</quote> and a
113
      which represent the <quote>destination</quote> and a
114
      <quote>gateway</quote>.  The route indicates that when trying
114
      <quote>gateway</quote>.  The route indicates that when trying
115
      to get to the specified destination, send the packets through
115
      to get to the specified destination, send the packets through
116
      the specified gateway.  There are three types of destinations:
116
      the specified gateway.  There are three types of destinations:
117
      individual hosts, subnets, and <quote>default</quote>.  The
117
      individual hosts, subnets, and <quote>default</quote>.  The
118
      <quote>default route</quote> is used if no other routes apply.
118
      <quote>default route</quote> is used if no other routes apply.
119
      There are also three types of gateways: individual hosts,
119
      There are also three types of gateways: individual hosts,
120
      interfaces, also called links, and Ethernet hardware
120
      interfaces, also called links, and Ethernet hardware
121
      (<acronym>MAC</acronym>) addresses.  Known routes are stored in
121
      (<acronym>MAC</acronym>) addresses.  Known routes are stored in
122
      a routing table.</para>
122
      a routing table.</para>
123
123
124
    <para>This section provides an overview of routing basics.  It
124
    <para>This section provides an overview of routing basics.  It
125
      then demonstrates how to configure a &os; system as a router and
125
      then demonstrates how to configure a &os; system as a router and
126
      offers some troubleshooting tips.</para>
126
      offers some troubleshooting tips.</para>
127
127
128
    <sect2 xml:id="network-routing-default">
128
    <sect2 xml:id="network-routing-default">
129
      <title>Routing Basics</title>
129
      <title>Routing Basics</title>
130
130
131
      <para>To view the routing table of a &os; system, use
131
      <para>To view the routing table of a &os; system, use
132
	&man.netstat.1;:</para>
132
	&man.netstat.1;:</para>
133
133
134
      <screen>&prompt.user; <userinput>netstat -r</userinput>
134
      <screen>&prompt.user; <userinput>netstat -r</userinput>
135
Routing tables
135
Routing tables
136
136
137
Internet:
137
Internet:
138
Destination      Gateway            Flags     Refs     Use     Netif Expire
138
Destination      Gateway            Flags     Refs     Use     Netif Expire
139
default          outside-gw         UGS        37      418       em0
139
default          outside-gw         UGS        37      418       em0
140
localhost        localhost          UH          0      181       lo0
140
localhost        localhost          UH          0      181       lo0
141
test0            0:e0:b5:36:cf:4f   UHLW        5    63288       re0     77
141
test0            0:e0:b5:36:cf:4f   UHLW        5    63288       re0     77
142
10.20.30.255     link#1             UHLW        1     2421
142
10.20.30.255     link#1             UHLW        1     2421
143
example.com      link#1             UC          0        0
143
example.com      link#1             UC          0        0
144
host1            0:e0:a8:37:8:1e    UHLW        3     4601       lo0
144
host1            0:e0:a8:37:8:1e    UHLW        3     4601       lo0
145
host2            0:e0:a8:37:8:1e    UHLW        0        5       lo0 =&gt;
145
host2            0:e0:a8:37:8:1e    UHLW        0        5       lo0 =&gt;
146
host2.example.com link#1            UC          0        0
146
host2.example.com link#1            UC          0        0
147
224              link#1             UC          0        0</screen>
147
224              link#1             UC          0        0</screen>
148
148
149
      <para>The entries in this example are as follows:</para>
149
      <para>The entries in this example are as follows:</para>
150
150
151
      <variablelist>
151
      <variablelist>
152
	<varlistentry>
152
	<varlistentry>
153
	  <term>default</term>
153
	  <term>default</term>
154
	  <listitem>
154
	  <listitem>
155
	    <para>The first route in this table specifies the
155
	    <para>The first route in this table specifies the
156
	      <literal>default</literal> route.  When the local system
156
	      <literal>default</literal> route.  When the local system
157
	      needs to make a connection to a remote host, it checks
157
	      needs to make a connection to a remote host, it checks
158
	      the routing table to determine if a known path exists.
158
	      the routing table to determine if a known path exists.
159
	      If the remote host matches an entry in the table, the
159
	      If the remote host matches an entry in the table, the
160
	      system checks to see if it can connect using the
160
	      system checks to see if it can connect using the
161
	      interface specified in that entry.</para>
161
	      interface specified in that entry.</para>
162
162
163
	    <para>If the destination does not match an entry, or if
163
	    <para>If the destination does not match an entry, or if
164
	      all known paths fail, the system uses the entry for the
164
	      all known paths fail, the system uses the entry for the
165
	      default route.  For hosts on a local area network, the
165
	      default route.  For hosts on a local area network, the
166
	      <literal>Gateway</literal> field in the default route is
166
	      <literal>Gateway</literal> field in the default route is
167
	      set to the system which has a direct connection to the
167
	      set to the system which has a direct connection to the
168
	      Internet.  When reading this entry, verify that the
168
	      Internet.  When reading this entry, verify that the
169
	      <literal>Flags</literal> column indicates that the
169
	      <literal>Flags</literal> column indicates that the
170
	      gateway is usable (<literal>UG</literal>).</para>
170
	      gateway is usable (<literal>UG</literal>).</para>
171
171
172
	    <para>The default route for a machine which itself is
172
	    <para>The default route for a machine which itself is
173
	      functioning as the gateway to the outside world will be
173
	      functioning as the gateway to the outside world will be
174
	      the gateway machine at the Internet Service Provider
174
	      the gateway machine at the Internet Service Provider
175
	      (<acronym>ISP</acronym>).</para>
175
	      (<acronym>ISP</acronym>).</para>
176
	  </listitem>
176
	  </listitem>
177
	</varlistentry>
177
	</varlistentry>
178
178
179
	<varlistentry>
179
	<varlistentry>
180
	  <term>localhost</term>
180
	  <term>localhost</term>
181
	  <listitem>
181
	  <listitem>
182
	    <para>The second route is the <literal>localhost</literal>
182
	    <para>The second route is the <literal>localhost</literal>
183
	      route.  The interface specified in the
183
	      route.  The interface specified in the
184
	      <literal>Netif</literal> column for
184
	      <literal>Netif</literal> column for
185
	      <literal>localhost</literal> is
185
	      <literal>localhost</literal> is
186
	      <filename>lo0</filename>, also known as the loopback
186
	      <filename>lo0</filename>, also known as the loopback
187
	      device.  This indicates that all traffic for this
187
	      device.  This indicates that all traffic for this
188
	      destination should be internal, rather than sending it
188
	      destination should be internal, rather than sending it
189
	      out over the network.</para>
189
	      out over the network.</para>
190
	  </listitem>
190
	  </listitem>
191
	</varlistentry>
191
	</varlistentry>
192
192
193
	<varlistentry>
193
	<varlistentry>
194
	  <term>MAC address</term>
194
	  <term>MAC address</term>
195
	  <listitem>
195
	  <listitem>
196
	    <para>The addresses beginning with <systemitem
196
	    <para>The addresses beginning with <systemitem
197
		class="etheraddress">0:e0:</systemitem> are
197
		class="etheraddress">0:e0:</systemitem> are
198
	      <acronym>MAC</acronym> addresses.  &os; will
198
	      <acronym>MAC</acronym> addresses.  &os; will
199
	      automatically identify any hosts,
199
	      automatically identify any hosts,
200
	      <systemitem>test0</systemitem> in the example, on the
200
	      <systemitem>test0</systemitem> in the example, on the
201
	      local Ethernet and add a route for that host over the
201
	      local Ethernet and add a route for that host over the
202
	      Ethernet interface, <filename>re0</filename>.  This type
202
	      Ethernet interface, <filename>re0</filename>.  This type
203
	      of route has a timeout, seen in the
203
	      of route has a timeout, seen in the
204
	      <literal>Expire</literal> column, which is used if the
204
	      <literal>Expire</literal> column, which is used if the
205
	      host does not respond in a specific amount of time.
205
	      host does not respond in a specific amount of time.
206
	      When this happens, the route to this host will be
206
	      When this happens, the route to this host will be
207
	      automatically deleted.  These hosts are identified using
207
	      automatically deleted.  These hosts are identified using
208
	      the Routing Information Protocol
208
	      the Routing Information Protocol
209
	      (<acronym>RIP</acronym>), which calculates routes to
209
	      (<acronym>RIP</acronym>), which calculates routes to
210
	      local hosts based upon a shortest path
210
	      local hosts based upon a shortest path
211
	      determination.</para>
211
	      determination.</para>
212
	  </listitem>
212
	  </listitem>
213
	</varlistentry>
213
	</varlistentry>
214
214
215
	<varlistentry>
215
	<varlistentry>
216
	  <term>subnet</term>
216
	  <term>subnet</term>
217
	  <listitem>
217
	  <listitem>
218
	    <para>&os; will automatically add subnet routes for the
218
	    <para>&os; will automatically add subnet routes for the
219
	      local subnet.  In this example, <systemitem
219
	      local subnet.  In this example, <systemitem
220
		class="ipaddress">10.20.30.255</systemitem> is the
220
		class="ipaddress">10.20.30.255</systemitem> is the
221
	      broadcast address for the subnet <systemitem
221
	      broadcast address for the subnet <systemitem
222
		class="ipaddress">10.20.30</systemitem> and
222
		class="ipaddress">10.20.30</systemitem> and
223
	      <systemitem
223
	      <systemitem
224
		class="fqdomainname">example.com</systemitem> is the
224
		class="fqdomainname">example.com</systemitem> is the
225
	      domain name associated with that subnet.  The
225
	      domain name associated with that subnet.  The
226
	      designation <literal>link#1</literal> refers to the
226
	      designation <literal>link#1</literal> refers to the
227
	      first Ethernet card in the machine.</para>
227
	      first Ethernet card in the machine.</para>
228
228
229
	    <para>Local network hosts and local subnets have their
229
	    <para>Local network hosts and local subnets have their
230
	      routes automatically configured by a daemon called
230
	      routes automatically configured by a daemon called
231
	      &man.routed.8;.  If it is not running, only routes which
231
	      &man.routed.8;.  If it is not running, only routes which
232
	      are statically defined by the administrator will
232
	      are statically defined by the administrator will
233
	      exist.</para>
233
	      exist.</para>
234
	  </listitem>
234
	  </listitem>
235
	</varlistentry>
235
	</varlistentry>
236
236
237
	<varlistentry>
237
	<varlistentry>
238
	  <term>host</term>
238
	  <term>host</term>
239
	  <listitem>
239
	  <listitem>
240
	    <para>The <literal>host1</literal> line refers to the host
240
	    <para>The <literal>host1</literal> line refers to the host
241
	      by its Ethernet address.  Since it is the sending host,
241
	      by its Ethernet address.  Since it is the sending host,
242
	      &os; knows to use the loopback interface
242
	      &os; knows to use the loopback interface
243
	      (<filename>lo0</filename>) rather than the Ethernet
243
	      (<filename>lo0</filename>) rather than the Ethernet
244
	      interface.</para>
244
	      interface.</para>
245
245
246
	    <para>The two <literal>host2</literal> lines represent
246
	    <para>The two <literal>host2</literal> lines represent
247
	      aliases which were created using &man.ifconfig.8;.  The
247
	      aliases which were created using &man.ifconfig.8;.  The
248
	      <literal>=&gt;</literal> symbol after the
248
	      <literal>=&gt;</literal> symbol after the
249
	      <filename>lo0</filename> interface says that an alias
249
	      <filename>lo0</filename> interface says that an alias
250
	      has been set in addition to the loopback address.  Such
250
	      has been set in addition to the loopback address.  Such
251
	      routes only show up on the host that supports the alias
251
	      routes only show up on the host that supports the alias
252
	      and all other hosts on the local network will have a
252
	      and all other hosts on the local network will have a
253
	      <literal>link#1</literal> line for such routes.</para>
253
	      <literal>link#1</literal> line for such routes.</para>
254
	  </listitem>
254
	  </listitem>
255
	</varlistentry>
255
	</varlistentry>
256
256
257
	<varlistentry>
257
	<varlistentry>
258
	  <term>224</term>
258
	  <term>224</term>
259
	  <listitem>
259
	  <listitem>
260
	    <para>The final line (destination subnet <systemitem
260
	    <para>The final line (destination subnet <systemitem
261
		class="ipaddress">224</systemitem>) deals with
261
		class="ipaddress">224</systemitem>) deals with
262
	      multicasting.</para>
262
	      multicasting.</para>
263
	  </listitem>
263
	  </listitem>
264
	</varlistentry>
264
	</varlistentry>
265
      </variablelist>
265
      </variablelist>
266
266
267
      <para>Various attributes of each route can be seen in the
267
      <para>Various attributes of each route can be seen in the
268
	<literal>Flags</literal> column.  <xref linkend="routeflags"/>
268
	<literal>Flags</literal> column.  <xref linkend="routeflags"/>
269
	summarizes some of these flags and their meanings:</para>
269
	summarizes some of these flags and their meanings:</para>
270
270
271
      <table xml:id="routeflags" frame="none" pgwide="1">
271
      <table xml:id="routeflags" frame="none" pgwide="1">
272
	<title>Commonly Seen Routing Table Flags</title>
272
	<title>Commonly Seen Routing Table Flags</title>
273
273
274
	<tgroup cols="2">
274
	<tgroup cols="2">
275
	  <thead>
275
	  <thead>
276
	    <row>
276
	    <row>
277
	      <entry>Command</entry>
277
	      <entry>Command</entry>
278
	      <entry>Purpose</entry>
278
	      <entry>Purpose</entry>
279
	    </row>
279
	    </row>
280
	  </thead>
280
	  </thead>
281
281
282
	  <tbody>
282
	  <tbody>
283
	    <row>
283
	    <row>
284
	      <entry>U</entry>
284
	      <entry>U</entry>
285
	      <entry>The route is active (up).</entry>
285
	      <entry>The route is active (up).</entry>
286
	    </row>
286
	    </row>
287
287
288
	    <row>
288
	    <row>
289
	      <entry>H</entry>
289
	      <entry>H</entry>
290
	      <entry>The route destination is a single host.</entry>
290
	      <entry>The route destination is a single host.</entry>
291
	    </row>
291
	    </row>
292
292
293
	    <row>
293
	    <row>
294
	      <entry>G</entry>
294
	      <entry>G</entry>
295
	      <entry>Send anything for this destination on to this
295
	      <entry>Send anything for this destination on to this
296
		gateway, which will figure out from there where to
296
		gateway, which will figure out from there where to
297
		send it.</entry>
297
		send it.</entry>
298
	    </row>
298
	    </row>
299
299
300
	    <row>
300
	    <row>
301
	      <entry>S</entry>
301
	      <entry>S</entry>
302
	      <entry>This route was statically configured.</entry>
302
	      <entry>This route was statically configured.</entry>
303
	    </row>
303
	    </row>
304
304
305
	    <row>
305
	    <row>
306
	      <entry>C</entry>
306
	      <entry>C</entry>
307
	      <entry>Clones a new route based upon this route for
307
	      <entry>Clones a new route based upon this route for
308
		machines to connect to.  This type of route is
308
		machines to connect to.  This type of route is
309
		normally used for local networks.</entry>
309
		normally used for local networks.</entry>
310
	    </row>
310
	    </row>
311
311
312
	    <row>
312
	    <row>
313
	      <entry>W</entry>
313
	      <entry>W</entry>
314
	      <entry>The route was auto-configured based upon a local
314
	      <entry>The route was auto-configured based upon a local
315
		area network (clone) route.</entry>
315
		area network (clone) route.</entry>
316
	    </row>
316
	    </row>
317
317
318
	    <row>
318
	    <row>
319
	      <entry>L</entry>
319
	      <entry>L</entry>
320
	      <entry>Route involves references to Ethernet (link)
320
	      <entry>Route involves references to Ethernet (link)
321
		hardware.</entry>
321
		hardware.</entry>
322
	    </row>
322
	    </row>
323
	  </tbody>
323
	  </tbody>
324
	</tgroup>
324
	</tgroup>
325
      </table>
325
      </table>
326
326
327
      <para>On a &os; system, the default route can defined in
327
      <para>On a &os; system, the default route can defined in
328
	<filename>/etc/rc.conf</filename> by specifying the
328
	<filename>/etc/rc.conf</filename> by specifying the
329
	<acronym>IP</acronym> address of the default gateway:</para>
329
	<acronym>IP</acronym> address of the default gateway:</para>
330
330
331
      <programlisting>defaultrouter="10.20.30.1"</programlisting>
331
      <programlisting>defaultrouter="10.20.30.1"</programlisting>
332
332
333
      <para>It is also possible to manually add the route using
333
      <para>It is also possible to manually add the route using
334
	<command>route</command>:</para>
334
	<command>route</command>:</para>
335
335
336
      <screen>&prompt.root; <userinput>route add default 10.20.30.1</userinput></screen>
336
      <screen>&prompt.root; <userinput>route add default 10.20.30.1</userinput></screen>
337
337
338
      <para>Note that manually added routes will not survive a reboot.
338
      <para>Note that manually added routes will not survive a reboot.
339
	For more information on manual manipulation of network
339
	For more information on manual manipulation of network
340
	routing tables, refer to &man.route.8;.</para>
340
	routing tables, refer to &man.route.8;.</para>
341
    </sect2>
341
    </sect2>
342
342
343
    <sect2 xml:id="network-static-routes">
343
    <sect2 xml:id="network-static-routes">
344
      <info>
344
      <info>
345
	<title>Configuring a Router with Static Routes</title>
345
	<title>Configuring a Router with Static Routes</title>
346
346
347
	<authorgroup>
347
	<authorgroup>
348
	  <author>
348
	  <author>
349
	    <personname>
349
	    <personname>
350
	      <firstname>Al</firstname>
350
	      <firstname>Al</firstname>
351
	      <surname>Hoang</surname>
351
	      <surname>Hoang</surname>
352
	    </personname>
352
	    </personname>
353
	    <contrib>Contributed by </contrib>
353
	    <contrib>Contributed by </contrib>
354
	  </author>
354
	  </author>
355
	</authorgroup>
355
	</authorgroup>
356
      </info>
356
      </info>
357
      <!-- Feb 2004 -->
357
      <!-- Feb 2004 -->
358
358
359
      <indexterm>
359
      <indexterm>
360
	<primary>dual homed hosts</primary>
360
	<primary>dual homed hosts</primary>
361
      </indexterm>
361
      </indexterm>
362
362
363
      <para>A &os; system can be configured as the default gateway, or
363
      <para>A &os; system can be configured as the default gateway, or
364
	router, for a network if it is a dual-homed system.  A
364
	router, for a network if it is a dual-homed system.  A
365
	dual-homed system is a host which resides on at least two
365
	dual-homed system is a host which resides on at least two
366
	different networks.  Typically, each network is connected to a
366
	different networks.  Typically, each network is connected to a
367
	separate network interface, though <acronym>IP</acronym>
367
	separate network interface, though <acronym>IP</acronym>
368
	aliasing can be used to bind multiple addresses, each on a
368
	aliasing can be used to bind multiple addresses, each on a
369
	different subnet, to one physical interface.</para>
369
	different subnet, to one physical interface.</para>
370
370
371
      <indexterm>
371
      <indexterm>
372
	<primary>router</primary>
372
	<primary>router</primary>
373
      </indexterm>
373
      </indexterm>
374
374
375
      <para>In order for the system to forward packets between
375
      <para>In order for the system to forward packets between
376
	interfaces, &os; must be configured as a router.  Internet
376
	interfaces, &os; must be configured as a router.  Internet
377
	standards and good engineering practice prevent the &os;
377
	standards and good engineering practice prevent the &os;
378
	Project from enabling this feature by default, but it can be
378
	Project from enabling this feature by default, but it can be
379
	configured to start at boot by adding this line to
379
	configured to start at boot by adding this line to
380
	<filename>/etc/rc.conf</filename>:</para>
380
	<filename>/etc/rc.conf</filename>:</para>
381
381
382
      <programlisting>gateway_enable="YES"          # Set to YES if this host will be a gateway</programlisting>
382
      <programlisting>gateway_enable="YES"          # Set to YES if this host will be a gateway</programlisting>
383
383
384
      <para>To enable routing now, set the &man.sysctl.8; variable
384
      <para>To enable routing now, set the &man.sysctl.8; variable
385
	<varname>net.inet.ip.forwarding</varname> to
385
	<varname>net.inet.ip.forwarding</varname> to
386
	<literal>1</literal>.  To stop routing, reset this variable to
386
	<literal>1</literal>.  To stop routing, reset this variable to
387
	<literal>0</literal>.</para>
387
	<literal>0</literal>.</para>
388
388
389
      <indexterm>
389
      <indexterm>
390
	<primary>BGP</primary>
390
	<primary>BGP</primary>
391
      </indexterm>
391
      </indexterm>
392
      <indexterm>
392
      <indexterm>
393
	<primary>RIP</primary>
393
	<primary>RIP</primary>
394
      </indexterm>
394
      </indexterm>
395
      <indexterm>
395
      <indexterm>
396
	<primary>OSPF</primary>
396
	<primary>OSPF</primary>
397
      </indexterm>
397
      </indexterm>
398
398
399
      <para>The routing table of a router needs additional routes so
399
      <para>The routing table of a router needs additional routes so
400
	it knows how to reach other networks.  Routes can be either
400
	it knows how to reach other networks.  Routes can be either
401
	added manually using static routes or routes can be
401
	added manually using static routes or routes can be
402
	automatically learned using a routing protocol.  Static routes
402
	automatically learned using a routing protocol.  Static routes
403
	are appropriate for small networks and this section describes
403
	are appropriate for small networks and this section describes
404
	how to add a static routing entry for a small network.</para>
404
	how to add a static routing entry for a small network.</para>
405
405
406
      <note>
406
      <note>
407
	<para>For large networks, static routes quickly become
407
	<para>For large networks, static routes quickly become
408
	  unscalable.  &os; comes with the standard
408
	  unscalable.  &os; comes with the standard
409
	  <acronym>BSD</acronym> routing daemon &man.routed.8;, which
409
	  <acronym>BSD</acronym> routing daemon &man.routed.8;, which
410
	  provides the routing protocols <acronym>RIP</acronym>,
410
	  provides the routing protocols <acronym>RIP</acronym>,
411
	  versions 1 and 2, and <acronym>IRDP</acronym>.  Support for
411
	  versions 1 and 2, and <acronym>IRDP</acronym>.  Support for
412
	  the <acronym>BGP</acronym> and <acronym>OSPF</acronym>
412
	  the <acronym>BGP</acronym> and <acronym>OSPF</acronym>
413
	  routing protocols can be installed using the
413
	  routing protocols can be installed using the
414
	  <package>net/zebra</package> package or port.</para>
414
	  <package>net/zebra</package> package or port.</para>
415
      </note>
415
      </note>
416
416
417
      <para>Consider the following network:</para>
417
      <para>Consider the following network:</para>
418
418
419
      <mediaobject>
419
      <mediaobject>
420
	<imageobject>
420
	<imageobject>
421
	  <imagedata fileref="advanced-networking/static-routes"/>
421
	  <imagedata fileref="advanced-networking/static-routes"/>
422
	</imageobject>
422
	</imageobject>
423
423
424
	<textobject>
424
	<textobject>
425
	<literallayout class="monospaced">
425
	<literallayout class="monospaced">
426
    INTERNET
426
    INTERNET
427
      | (10.0.0.1/24) Default Router to Internet
427
      | (10.0.0.1/24) Default Router to Internet
428
      |
428
      |
429
      |Interface xl0
429
      |Interface xl0
430
      |10.0.0.10/24
430
      |10.0.0.10/24
431
   +------+
431
   +------+
432
   |      | RouterA
432
   |      | RouterA
433
   |      | (FreeBSD gateway)
433
   |      | (FreeBSD gateway)
434
   +------+
434
   +------+
435
      | Interface xl1
435
      | Interface xl1
436
      | 192.168.1.1/24
436
      | 192.168.1.1/24
437
      |
437
      |
438
  +--------------------------------+
438
  +--------------------------------+
439
   Internal Net 1      | 192.168.1.2/24
439
   Internal Net 1      | 192.168.1.2/24
440
                       |
440
                       |
441
                   +------+
441
                   +------+
442
                   |      | RouterB
442
                   |      | RouterB
443
                   |      |
443
                   |      |
444
                   +------+
444
                   +------+
445
                       | 192.168.2.1/24
445
                       | 192.168.2.1/24
446
                       |
446
                       |
447
                     Internal Net 2</literallayout>
447
                     Internal Net 2</literallayout>
448
	</textobject>
448
	</textobject>
449
      </mediaobject>
449
      </mediaobject>
450
450
451
      <para>In this scenario, <systemitem>RouterA</systemitem> is a
451
      <para>In this scenario, <systemitem>RouterA</systemitem> is a
452
	&os; machine that is acting as a router to the rest of the
452
	&os; machine that is acting as a router to the rest of the
453
	Internet.  It has a default route set to <systemitem
453
	Internet.  It has a default route set to <systemitem
454
	  class="ipaddress">10.0.0.1</systemitem> which allows it to
454
	  class="ipaddress">10.0.0.1</systemitem> which allows it to
455
	connect with the outside world.
455
	connect with the outside world.
456
	<systemitem>RouterB</systemitem> is already configured to use
456
	<systemitem>RouterB</systemitem> is already configured to use
457
	<systemitem class="ipaddress">192.168.1.1</systemitem> as its
457
	<systemitem class="ipaddress">192.168.1.1</systemitem> as its
458
	default gateway.</para>
458
	default gateway.</para>
459
459
460
      <para>Before adding any static routes, the routing table on
460
      <para>Before adding any static routes, the routing table on
461
	<systemitem>RouterA</systemitem> looks like this:</para>
461
	<systemitem>RouterA</systemitem> looks like this:</para>
462
462
463
      <screen>&prompt.user; <userinput>netstat -nr</userinput>
463
      <screen>&prompt.user; <userinput>netstat -nr</userinput>
464
Routing tables
464
Routing tables
465
465
466
Internet:
466
Internet:
467
Destination        Gateway            Flags    Refs      Use  Netif  Expire
467
Destination        Gateway            Flags    Refs      Use  Netif  Expire
468
default            10.0.0.1           UGS         0    49378    xl0
468
default            10.0.0.1           UGS         0    49378    xl0
469
127.0.0.1          127.0.0.1          UH          0        6    lo0
469
127.0.0.1          127.0.0.1          UH          0        6    lo0
470
10.0.0.0/24        link#1             UC          0        0    xl0
470
10.0.0.0/24        link#1             UC          0        0    xl0
471
192.168.1.0/24     link#2             UC          0        0    xl1</screen>
471
192.168.1.0/24     link#2             UC          0        0    xl1</screen>
472
472
473
      <para>With the current routing table,
473
      <para>With the current routing table,
474
	<systemitem>RouterA</systemitem> does not have a route to the
474
	<systemitem>RouterA</systemitem> does not have a route to the
475
	<systemitem class="ipaddress">192.168.2.0/24</systemitem>
475
	<systemitem class="ipaddress">192.168.2.0/24</systemitem>
476
	network.  The following command adds the <literal>Internal Net
476
	network.  The following command adds the <literal>Internal Net
477
	  2</literal> network to <systemitem>RouterA</systemitem>'s
477
	  2</literal> network to <systemitem>RouterA</systemitem>'s
478
	routing table using <systemitem
478
	routing table using <systemitem
479
	  class="ipaddress">192.168.1.2</systemitem> as the next
479
	  class="ipaddress">192.168.1.2</systemitem> as the next
480
	hop:</para>
480
	hop:</para>
481
481
482
      <screen>&prompt.root; <userinput>route add -net 192.168.2.0/24 192.168.1.2</userinput></screen>
482
      <screen>&prompt.root; <userinput>route add -net 192.168.2.0/24 192.168.1.2</userinput></screen>
483
483
484
      <para>Now, <systemitem>RouterA</systemitem> can reach any host
484
      <para>Now, <systemitem>RouterA</systemitem> can reach any host
485
	on the <systemitem
485
	on the <systemitem
486
	  class="ipaddress">192.168.2.0/24</systemitem> network.
486
	  class="ipaddress">192.168.2.0/24</systemitem> network.
487
	However, the routing information will not persist if the &os;
487
	However, the routing information will not persist if the &os;
488
	system reboots.  If a static route needs to be persistent, add
488
	system reboots.  If a static route needs to be persistent, add
489
	it to <filename>/etc/rc.conf</filename>:</para>
489
	it to <filename>/etc/rc.conf</filename>:</para>
490
490
491
      <programlisting># Add Internal Net 2 as a persistent static route
491
      <programlisting># Add Internal Net 2 as a persistent static route
492
static_routes="internalnet2"
492
static_routes="internalnet2"
493
route_internalnet2="-net 192.168.2.0/24 192.168.1.2"</programlisting>
493
route_internalnet2="-net 192.168.2.0/24 192.168.1.2"</programlisting>
494
494
495
      <para>The <literal>static_routes</literal> configuration
495
      <para>The <literal>static_routes</literal> configuration
496
	variable is a list of strings separated by a space, where each
496
	variable is a list of strings separated by a space, where each
497
	string references a route name.  The variable
497
	string references a route name.  The variable
498
	<literal>route_<replaceable>internalnet2</replaceable></literal>
498
	<literal>route_<replaceable>internalnet2</replaceable></literal>
499
	contains the static route for that route name.</para>
499
	contains the static route for that route name.</para>
500
500
501
      <para>Using more than one string in
501
      <para>Using more than one string in
502
	<literal>static_routes</literal> creates multiple static
502
	<literal>static_routes</literal> creates multiple static
503
	routes.  The following shows an example of adding static
503
	routes.  The following shows an example of adding static
504
	routes for the <systemitem
504
	routes for the <systemitem
505
	  class="ipaddress">192.168.0.0/24</systemitem> and
505
	  class="ipaddress">192.168.0.0/24</systemitem> and
506
	<systemitem class="ipaddress">192.168.1.0/24</systemitem>
506
	<systemitem class="ipaddress">192.168.1.0/24</systemitem>
507
	networks:</para>
507
	networks:</para>
508
508
509
      <programlisting>static_routes="net1 net2"
509
      <programlisting>static_routes="net1 net2"
510
route_net1="-net 192.168.0.0/24 192.168.0.1"
510
route_net1="-net 192.168.0.0/24 192.168.0.1"
511
route_net2="-net 192.168.1.0/24 192.168.1.1"</programlisting>
511
route_net2="-net 192.168.1.0/24 192.168.1.1"</programlisting>
512
    </sect2>
512
    </sect2>
513
513
514
    <sect2 xml:id="network-routing-troubleshooting">
514
    <sect2 xml:id="network-routing-troubleshooting">
515
      <title>Troubleshooting</title>
515
      <title>Troubleshooting</title>
516
516
517
      <para>When an address space is assigned to a network, the
517
      <para>When an address space is assigned to a network, the
518
	service provider configures their routing tables so that all
518
	service provider configures their routing tables so that all
519
	traffic for the network will be sent to the link for the site.
519
	traffic for the network will be sent to the link for the site.
520
	But how do external sites know to send their packets to the
520
	But how do external sites know to send their packets to the
521
	network's <acronym>ISP</acronym>?</para>
521
	network's <acronym>ISP</acronym>?</para>
522
522
523
      <para>There is a system that keeps track of all assigned
523
      <para>There is a system that keeps track of all assigned
524
	address spaces and defines their point of connection to the
524
	address spaces and defines their point of connection to the
525
	Internet backbone, or the main trunk lines that carry Internet
525
	Internet backbone, or the main trunk lines that carry Internet
526
	traffic across the country and around the world.  Each
526
	traffic across the country and around the world.  Each
527
	backbone machine has a copy of a master set of tables, which
527
	backbone machine has a copy of a master set of tables, which
528
	direct traffic for a particular network to a specific
528
	direct traffic for a particular network to a specific
529
	backbone carrier, and from there down the chain of service
529
	backbone carrier, and from there down the chain of service
530
	providers until it reaches a particular network.</para>
530
	providers until it reaches a particular network.</para>
531
531
532
      <para>It is the task of the service provider to advertise to
532
      <para>It is the task of the service provider to advertise to
533
	the backbone sites that they are the point of connection, and
533
	the backbone sites that they are the point of connection, and
534
	thus the path inward, for a site.  This is known as route
534
	thus the path inward, for a site.  This is known as route
535
	propagation.</para>
535
	propagation.</para>
536
536
537
      <indexterm>
537
      <indexterm>
538
	<primary>&man.traceroute.8;</primary>
538
	<primary>&man.traceroute.8;</primary>
539
      </indexterm>
539
      </indexterm>
540
540
541
      <para>Sometimes, there is a problem with route propagation and
541
      <para>Sometimes, there is a problem with route propagation and
542
	some sites are unable to connect.  Perhaps the most useful
542
	some sites are unable to connect.  Perhaps the most useful
543
	command for trying to figure out where routing is breaking
543
	command for trying to figure out where routing is breaking
544
	down is <command>traceroute</command>.  It is useful when
544
	down is <command>traceroute</command>.  It is useful when
545
	<command>ping</command> fails.</para>
545
	<command>ping</command> fails.</para>
546
546
547
      <para>When using <command>traceroute</command>, include the
547
      <para>When using <command>traceroute</command>, include the
548
	address of the remote host to connect to.  The output will
548
	address of the remote host to connect to.  The output will
549
	show the gateway hosts along the path of the attempt,
549
	show the gateway hosts along the path of the attempt,
550
	eventually either reaching the target host, or terminating
550
	eventually either reaching the target host, or terminating
551
	because of a lack of connection.  For more information, refer
551
	because of a lack of connection.  For more information, refer
552
	to &man.traceroute.8;.</para>
552
	to &man.traceroute.8;.</para>
553
    </sect2>
553
    </sect2>
554
554
555
    <sect2 xml:id="network-routing-multicast">
555
    <sect2 xml:id="network-routing-multicast">
556
      <title>Multicast Considerations</title>
556
      <title>Multicast Considerations</title>
557
557
558
      <indexterm>
558
      <indexterm>
559
	<primary>multicast routing</primary>
559
	<primary>multicast routing</primary>
560
      </indexterm>
560
      </indexterm>
561
      <indexterm>
561
      <indexterm>
562
	<primary>kernel options</primary>
562
	<primary>kernel options</primary>
563
	<secondary>MROUTING</secondary>
563
	<secondary>MROUTING</secondary>
564
      </indexterm>
564
      </indexterm>
565
565
566
      <para>&os; natively supports both multicast applications and
566
      <para>&os; natively supports both multicast applications and
567
	multicast routing.  Multicast applications do not require any
567
	multicast routing.  Multicast applications do not require any
568
	special configuration in order to run on &os;.  Support for
568
	special configuration in order to run on &os;.  Support for
569
	multicast routing requires that the following option be
569
	multicast routing requires that the following option be
570
	compiled into a custom kernel:</para>
570
	compiled into a custom kernel:</para>
571
571
572
      <programlisting>options MROUTING</programlisting>
572
      <programlisting>options MROUTING</programlisting>
573
573
574
      <para>The multicast routing daemon,
574
      <para>The multicast routing daemon,
575
	<application>mrouted</application> can be installed using the
575
	<application>mrouted</application> can be installed using the
576
	<package>net/mrouted</package> package or port.  This daemon
576
	<package>net/mrouted</package> package or port.  This daemon
577
	implements the <acronym>DVMRP</acronym> multicast routing
577
	implements the <acronym>DVMRP</acronym> multicast routing
578
	protocol and is configured by editing
578
	protocol and is configured by editing
579
	<filename>/usr/local/etc/mrouted.conf</filename> in order to
579
	<filename>/usr/local/etc/mrouted.conf</filename> in order to
580
	set up the tunnels and <acronym>DVMRP</acronym>.  The
580
	set up the tunnels and <acronym>DVMRP</acronym>.  The
581
	installation of <application>mrouted</application> also
581
	installation of <application>mrouted</application> also
582
	installs <application>map-mbone</application> and
582
	installs <application>map-mbone</application> and
583
	<application>mrinfo</application>, as well as their associated
583
	<application>mrinfo</application>, as well as their associated
584
	man pages.  Refer to these for configuration examples.</para>
584
	man pages.  Refer to these for configuration examples.</para>
585
585
586
      <note>
586
      <note>
587
	<para><acronym>DVMRP</acronym> has largely been replaced by
587
	<para><acronym>DVMRP</acronym> has largely been replaced by
588
	  the <acronym>PIM</acronym> protocol in many multicast
588
	  the <acronym>PIM</acronym> protocol in many multicast
589
	  installations.  Refer to &man.pim.4; for more
589
	  installations.  Refer to &man.pim.4; for more
590
	  information.</para>
590
	  information.</para>
591
      </note>
591
      </note>
592
    </sect2>
592
    </sect2>
593
  </sect1>
593
  </sect1>
594
594
595
  <sect1 xml:id="network-wireless">
595
  <sect1 xml:id="network-wireless">
596
    <info>
596
    <info>
597
      <title>Wireless Networking</title>
597
      <title>Wireless Networking</title>
598
598
599
      <authorgroup>
599
      <authorgroup>
600
	<author>
600
	<author>
601
	  <personname>
601
	  <personname>
602
	    <othername>Loader</othername>
602
	    <othername>Loader</othername>
603
	  </personname>
603
	  </personname>
604
	</author>
604
	</author>
605
	<author>
605
	<author>
606
	  <personname>
606
	  <personname>
607
	    <firstname>Marc</firstname>
607
	    <firstname>Marc</firstname>
608
	    <surname>Fonvieille</surname>
608
	    <surname>Fonvieille</surname>
609
	  </personname>
609
	  </personname>
610
	</author>
610
	</author>
611
	<author>
611
	<author>
612
	  <personname>
612
	  <personname>
613
	    <firstname>Murray</firstname>
613
	    <firstname>Murray</firstname>
614
	    <surname>Stokely</surname>
614
	    <surname>Stokely</surname>
615
	  </personname>
615
	  </personname>
616
	</author>
616
	</author>
617
      </authorgroup>
617
      </authorgroup>
618
    </info>
618
    </info>
619
619
620
    <indexterm>
620
    <indexterm>
621
      <primary>wireless networking</primary>
621
      <primary>wireless networking</primary>
622
    </indexterm>
622
    </indexterm>
623
    <indexterm>
623
    <indexterm>
624
      <primary>802.11</primary>
624
      <primary>802.11</primary>
625
      <see>wireless networking</see>
625
      <see>wireless networking</see>
626
    </indexterm>
626
    </indexterm>
627
627
628
    <sect2>
628
    <sect2>
629
      <title>Wireless Networking Basics</title>
629
      <title>Wireless Networking Basics</title>
630
630
631
      <para>Most wireless networks are based on the &ieee; 802.11
631
      <para>Most wireless networks are based on the &ieee; 802.11
632
	standards.  A basic wireless network consists of multiple
632
	standards.  A basic wireless network consists of multiple
633
	stations communicating with radios that broadcast in either
633
	stations communicating with radios that broadcast in either
634
	the 2.4GHz or 5GHz band, though this varies according to the
634
	the 2.4GHz or 5GHz band, though this varies according to the
635
	locale and is also changing to enable communication in the
635
	locale and is also changing to enable communication in the
636
	2.3GHz and 4.9GHz ranges.</para>
636
	2.3GHz and 4.9GHz ranges.</para>
637
637
638
      <para>802.11 networks are organized in two ways.  In
638
      <para>802.11 networks are organized in two ways.  In
639
	<emphasis>infrastructure mode</emphasis>, one station acts as
639
	<emphasis>infrastructure mode</emphasis>, one station acts as
640
	a
640
	a
641
	master with all the other stations associating to it, the
641
	master with all the other stations associating to it, the
642
	network is known as a <acronym>BSS</acronym>, and the master
642
	network is known as a <acronym>BSS</acronym>, and the master
643
	station is termed an access point (<acronym>AP</acronym>).
643
	station is termed an access point (<acronym>AP</acronym>).
644
	In a <acronym>BSS</acronym>, all communication passes through
644
	In a <acronym>BSS</acronym>, all communication passes through
645
	the <acronym>AP</acronym>; even when one station wants to
645
	the <acronym>AP</acronym>; even when one station wants to
646
	communicate with another wireless station, messages must go
646
	communicate with another wireless station, messages must go
647
	through the <acronym>AP</acronym>.  In the second form of
647
	through the <acronym>AP</acronym>.  In the second form of
648
	network, there is no master and stations communicate directly.
648
	network, there is no master and stations communicate directly.
649
	This form of network is termed an <acronym>IBSS</acronym>
649
	This form of network is termed an <acronym>IBSS</acronym>
650
	and is commonly known as an <emphasis>ad-hoc
650
	and is commonly known as an <emphasis>ad-hoc
651
	  network</emphasis>.</para>
651
	  network</emphasis>.</para>
652
652
653
      <para>802.11 networks were first deployed in the 2.4GHz band
653
      <para>802.11 networks were first deployed in the 2.4GHz band
654
	using protocols defined by the &ieee; 802.11 and 802.11b
654
	using protocols defined by the &ieee; 802.11 and 802.11b
655
	standard.  These specifications include the operating
655
	standard.  These specifications include the operating
656
	frequencies and the <acronym>MAC</acronym> layer
656
	frequencies and the <acronym>MAC</acronym> layer
657
	characteristics, including framing and transmission rates,
657
	characteristics, including framing and transmission rates,
658
	as communication can occur at various rates.  Later, the
658
	as communication can occur at various rates.  Later, the
659
	802.11a standard defined operation in the 5GHz band, including
659
	802.11a standard defined operation in the 5GHz band, including
660
	different signaling mechanisms and higher transmission rates.
660
	different signaling mechanisms and higher transmission rates.
661
	Still later, the 802.11g standard defined the use of 802.11a
661
	Still later, the 802.11g standard defined the use of 802.11a
662
	signaling and transmission mechanisms in the 2.4GHz band in
662
	signaling and transmission mechanisms in the 2.4GHz band in
663
	such a way as to be backwards compatible with 802.11b
663
	such a way as to be backwards compatible with 802.11b
664
	networks.</para>
664
	networks.</para>
665
665
666
      <para>Separate from the underlying transmission techniques,
666
      <para>Separate from the underlying transmission techniques,
667
	802.11 networks have a variety of security mechanisms.  The
667
	802.11 networks have a variety of security mechanisms.  The
668
	original 802.11 specifications defined a simple security
668
	original 802.11 specifications defined a simple security
669
	protocol called <acronym>WEP</acronym>.  This protocol uses a
669
	protocol called <acronym>WEP</acronym>.  This protocol uses a
670
	fixed pre-shared key and the RC4 cryptographic cipher to
670
	fixed pre-shared key and the RC4 cryptographic cipher to
671
	encode data transmitted on a network.  Stations must all
671
	encode data transmitted on a network.  Stations must all
672
	agree on the fixed key in order to communicate.  This scheme
672
	agree on the fixed key in order to communicate.  This scheme
673
	was shown to be easily broken and is now rarely used except
673
	was shown to be easily broken and is now rarely used except
674
	to discourage transient users from joining networks.  Current
674
	to discourage transient users from joining networks.  Current
675
	security practice is given by the &ieee; 802.11i specification
675
	security practice is given by the &ieee; 802.11i specification
676
	that defines new cryptographic ciphers and an additional
676
	that defines new cryptographic ciphers and an additional
677
	protocol to authenticate stations to an access point and
677
	protocol to authenticate stations to an access point and
678
	exchange keys for data communication.  Cryptographic keys
678
	exchange keys for data communication.  Cryptographic keys
679
	are periodically refreshed and there are mechanisms for
679
	are periodically refreshed and there are mechanisms for
680
	detecting and countering intrusion attempts.  Another
680
	detecting and countering intrusion attempts.  Another
681
	security protocol specification commonly used in wireless
681
	security protocol specification commonly used in wireless
682
	networks is termed <acronym>WPA</acronym>, which was a
682
	networks is termed <acronym>WPA</acronym>, which was a
683
	precursor to 802.11i.  <acronym>WPA</acronym> specifies a
683
	precursor to 802.11i.  <acronym>WPA</acronym> specifies a
684
	subset of the requirements found in 802.11i and is designed
684
	subset of the requirements found in 802.11i and is designed
685
	for implementation on legacy hardware.  Specifically,
685
	for implementation on legacy hardware.  Specifically,
686
	<acronym>WPA</acronym> requires only the
686
	<acronym>WPA</acronym> requires only the
687
	<acronym>TKIP</acronym> cipher that is derived from the
687
	<acronym>TKIP</acronym> cipher that is derived from the
688
	original <acronym>WEP</acronym> cipher.  802.11i permits use
688
	original <acronym>WEP</acronym> cipher.  802.11i permits use
689
	of <acronym>TKIP</acronym> but also requires support for a
689
	of <acronym>TKIP</acronym> but also requires support for a
690
	stronger cipher, AES-CCM, for encrypting data.  The
690
	stronger cipher, AES-CCM, for encrypting data.  The
691
	<acronym>AES</acronym> cipher was not required in
691
	<acronym>AES</acronym> cipher was not required in
692
	<acronym>WPA</acronym> because it was deemed too
692
	<acronym>WPA</acronym> because it was deemed too
693
	computationally costly to be implemented on legacy
693
	computationally costly to be implemented on legacy
694
	hardware.</para>
694
	hardware.</para>
695
695
696
      <para>The other standard to be aware of is 802.11e.  It defines
696
      <para>The other standard to be aware of is 802.11e.  It defines
697
	protocols for deploying multimedia applications, such as
697
	protocols for deploying multimedia applications, such as
698
	streaming video and voice over IP (<acronym>VoIP</acronym>),
698
	streaming video and voice over IP (<acronym>VoIP</acronym>),
699
	in an 802.11 network.  Like 802.11i, 802.11e also has a
699
	in an 802.11 network.  Like 802.11i, 802.11e also has a
700
	precursor specification termed <acronym>WME</acronym> (later
700
	precursor specification termed <acronym>WME</acronym> (later
701
	renamed <acronym>WMM</acronym>) that has been defined by an
701
	renamed <acronym>WMM</acronym>) that has been defined by an
702
	industry group as a subset of 802.11e that can be deployed now
702
	industry group as a subset of 802.11e that can be deployed now
703
	to enable multimedia applications while waiting for the final
703
	to enable multimedia applications while waiting for the final
704
	ratification of 802.11e.  The most important thing to know
704
	ratification of 802.11e.  The most important thing to know
705
	about 802.11e and
705
	about 802.11e and
706
	<acronym>WME</acronym>/<acronym>WMM</acronym> is that it
706
	<acronym>WME</acronym>/<acronym>WMM</acronym> is that it
707
	enables prioritized traffic over a wireless network through
707
	enables prioritized traffic over a wireless network through
708
	Quality of Service (<acronym>QoS</acronym>) protocols and
708
	Quality of Service (<acronym>QoS</acronym>) protocols and
709
	enhanced media access protocols.  Proper implementation of
709
	enhanced media access protocols.  Proper implementation of
710
	these protocols enables high speed bursting of data and
710
	these protocols enables high speed bursting of data and
711
	prioritized traffic flow.</para>
711
	prioritized traffic flow.</para>
712
712
713
      <para>&os; supports networks that operate using 802.11a,
713
      <para>&os; supports networks that operate using 802.11a,
714
	802.11b, and 802.11g.  The <acronym>WPA</acronym> and 802.11i
714
	802.11b, and 802.11g.  The <acronym>WPA</acronym> and 802.11i
715
	security protocols are likewise supported (in conjunction with
715
	security protocols are likewise supported (in conjunction with
716
	any of 11a, 11b, and 11g) and <acronym>QoS</acronym> and
716
	any of 11a, 11b, and 11g) and <acronym>QoS</acronym> and
717
	traffic prioritization required by the
717
	traffic prioritization required by the
718
	<acronym>WME</acronym>/<acronym>WMM</acronym> protocols are
718
	<acronym>WME</acronym>/<acronym>WMM</acronym> protocols are
719
	supported for a limited set of wireless devices.</para>
719
	supported for a limited set of wireless devices.</para>
720
    </sect2>
720
    </sect2>
721
721
722
    <sect2 xml:id="network-wireless-quick-start">
722
    <sect2 xml:id="network-wireless-quick-start">
723
      <title>Quick Start</title>
723
      <title>Quick Start</title>
724
724
725
      <para>Connecting a computer to an existing wireless network is
725
      <para>Connecting a computer to an existing wireless network is
726
	a very common situation.  This procedure shows the steps
726
	a very common situation.  This procedure shows the steps
727
	required.</para>
727
	required.</para>
728
728
729
      <procedure>
729
      <procedure>
730
	<step>
730
	<step>
731
	  <para>Obtain the <acronym>SSID</acronym> (Service Set
731
	  <para>Obtain the <acronym>SSID</acronym> (Service Set
732
	    Identifier) and <acronym>PSK</acronym> (Pre-Shared Key)
732
	    Identifier) and <acronym>PSK</acronym> (Pre-Shared Key)
733
	    for the wireless network from the network
733
	    for the wireless network from the network
734
	    administrator.</para>
734
	    administrator.</para>
735
	</step>
735
	</step>
736
736
737
	<step>
737
	<step>
738
	  <para>Identify the wireless adapter.  The &os;
738
	  <para>Identify the wireless adapter.  The &os;
739
	    <filename>GENERIC</filename> kernel includes drivers for
739
	    <filename>GENERIC</filename> kernel includes drivers for
740
	    many common wireless adapters.  If the wireless adapter is
740
	    many common wireless adapters.  If the wireless adapter is
741
	    one of those models, it will be shown in the output from
741
	    one of those models, it will be shown in the output from
742
	    &man.ifconfig.8;:</para>
742
	    &man.ifconfig.8;:</para>
743
743
744
	  <screen>&prompt.user; <userinput>ifconfig | grep -B3 -i wireless</userinput></screen>
744
	  <screen>&prompt.user; <userinput>ifconfig | grep -B3 -i wireless</userinput></screen>
745
745
746
	  <para>On &os;&nbsp;11 or higher, use this command
746
	  <para>On &os;&nbsp;11 or higher, use this command
747
	    instead:</para>
747
	    instead:</para>
748
748
749
	  <screen>&prompt.user; <userinput>sysctl net.wlan.devices</userinput></screen>
749
	  <screen>&prompt.user; <userinput>sysctl net.wlan.devices</userinput></screen>
750
750
751
	  <para>If a wireless adapter is not listed, an additional
751
	  <para>If a wireless adapter is not listed, an additional
752
	    kernel module might be required, or it might be a model
752
	    kernel module might be required, or it might be a model
753
	    not supported by &os;.</para>
753
	    not supported by &os;.</para>
754
	  <!-- WB: refer to section that shows how to identify a
754
	  <!-- WB: refer to section that shows how to identify a
755
	  wireless adapter and load the kernel modules for it. -->
755
	  wireless adapter and load the kernel modules for it. -->
756
756
757
	  <para>This example shows the Atheros <literal>ath0</literal>
757
	  <para>This example shows the Atheros <literal>ath0</literal>
758
	    wireless adapter.</para>
758
	    wireless adapter.</para>
759
	</step>
759
	</step>
760
760
761
	<step>
761
	<step>
762
	  <para>Add an entry for this network to
762
	  <para>Add an entry for this network to
763
	    <filename>/etc/wpa_supplicant.conf</filename>.  If the
763
	    <filename>/etc/wpa_supplicant.conf</filename>.  If the
764
	    file does not exist, create it.  Replace
764
	    file does not exist, create it.  Replace
765
	    <replaceable>myssid</replaceable> and
765
	    <replaceable>myssid</replaceable> and
766
	    <replaceable>mypsk</replaceable> with the
766
	    <replaceable>mypsk</replaceable> with the
767
	    <acronym>SSID</acronym> and <acronym>PSK</acronym>
767
	    <acronym>SSID</acronym> and <acronym>PSK</acronym>
768
	    provided by the network administrator.</para>
768
	    provided by the network administrator.</para>
769
769
770
	  <programlisting>network={
770
	  <programlisting>network={
771
	ssid="<replaceable>myssid</replaceable>"
771
	ssid="<replaceable>myssid</replaceable>"
772
	psk="<replaceable>mypsk</replaceable>"
772
	psk="<replaceable>mypsk</replaceable>"
773
}</programlisting>
773
}</programlisting>
774
	</step>
774
	</step>
775
775
776
	<step>
776
	<step>
777
	  <para>Add entries to <filename>/etc/rc.conf</filename> to
777
	  <para>Add entries to <filename>/etc/rc.conf</filename> to
778
	    configure the network on startup:</para>
778
	    configure the network on startup:</para>
779
779
780
	  <programlisting>wlans_<replaceable>ath0</replaceable>="wlan0"
780
	  <programlisting>wlans_<replaceable>ath0</replaceable>="wlan0"
781
ifconfig_wlan0="WPA SYNCDHCP"</programlisting>
781
ifconfig_wlan0="WPA SYNCDHCP"</programlisting>
782
	</step>
782
	</step>
783
783
784
	<step>
784
	<step>
785
	  <para>Restart the computer, or restart the network service
785
	  <para>Restart the computer, or restart the network service
786
	    to connect to the network:</para>
786
	    to connect to the network:</para>
787
787
788
	  <screen>&prompt.root; <userinput>service netif restart</userinput></screen>
788
	  <screen>&prompt.root; <userinput>service netif restart</userinput></screen>
789
	</step>
789
	</step>
790
      </procedure>
790
      </procedure>
791
    </sect2>
791
    </sect2>
792
792
793
    <sect2 xml:id="network-wireless-basic">
793
    <sect2 xml:id="network-wireless-basic">
794
      <title>Basic Setup</title>
794
      <title>Basic Setup</title>
795
795
796
      <sect3>
796
      <sect3>
797
	<title>Kernel Configuration</title>
797
	<title>Kernel Configuration</title>
798
798
799
	<para>To use wireless networking, a wireless networking card
799
	<para>To use wireless networking, a wireless networking card
800
	  is needed and the kernel needs to be configured with the
800
	  is needed and the kernel needs to be configured with the
801
	  appropriate wireless networking support.  The kernel is
801
	  appropriate wireless networking support.  The kernel is
802
	  separated into multiple modules so that only the required
802
	  separated into multiple modules so that only the required
803
	  support needs to be configured.</para>
803
	  support needs to be configured.</para>
804
804
805
	<para>The most
805
	<para>The most
806
	  commonly used wireless devices are those that use parts made
806
	  commonly used wireless devices are those that use parts made
807
	  by Atheros.  These devices are supported by &man.ath.4;
807
	  by Atheros.  These devices are supported by &man.ath.4;
808
	  and require the following line to be added to
808
	  and require the following line to be added to
809
	  <filename>/boot/loader.conf</filename>:</para>
809
	  <filename>/boot/loader.conf</filename>:</para>
810
810
811
	<programlisting>if_ath_load="YES"</programlisting>
811
	<programlisting>if_ath_load="YES"</programlisting>
812
812
813
	<para>The Atheros driver is split up into three separate
813
	<para>The Atheros driver is split up into three separate
814
	  pieces: the driver (&man.ath.4;), the hardware support
814
	  pieces: the driver (&man.ath.4;), the hardware support
815
	  layer that handles chip-specific functions
815
	  layer that handles chip-specific functions
816
	  (&man.ath.hal.4;), and an algorithm for selecting the
816
	  (&man.ath.hal.4;), and an algorithm for selecting the
817
	  rate for transmitting frames.  When this support is loaded
817
	  rate for transmitting frames.  When this support is loaded
818
	  as kernel modules, any dependencies are automatically
818
	  as kernel modules, any dependencies are automatically
819
	  handled.  To load support for a different type of wireless
819
	  handled.  To load support for a different type of wireless
820
	  device, specify the module for that device.  This example
820
	  device, specify the module for that device.  This example
821
	  is for devices based on the Intersil Prism parts
821
	  is for devices based on the Intersil Prism parts
822
	  (&man.wi.4;) driver:</para>
822
	  (&man.wi.4;) driver:</para>
823
823
824
	<programlisting>if_wi_load="YES"</programlisting>
824
	<programlisting>if_wi_load="YES"</programlisting>
825
825
826
	<note>
826
	<note>
827
	  <para>The examples in this section use an &man.ath.4;
827
	  <para>The examples in this section use an &man.ath.4;
828
	    device and the device name in the examples must be
828
	    device and the device name in the examples must be
829
	    changed according to the configuration.  A list of
829
	    changed according to the configuration.  A list of
830
	    available wireless drivers and supported adapters can be
830
	    available wireless drivers and supported adapters can be
831
	    found in the &os; Hardware Notes, available on
831
	    found in the &os; Hardware Notes, available on
832
	    the <link
832
	    the <link
833
	      xlink:href="http://www.FreeBSD.org/releases/index.html">Release
833
	      xlink:href="http://www.FreeBSD.org/releases/index.html">Release
834
	      Information</link> page of the &os; website.  If a
834
	      Information</link> page of the &os; website.  If a
835
	    native &os; driver for the wireless device does not
835
	    native &os; driver for the wireless device does not
836
	    exist, it may be possible to use the &windows; driver
836
	    exist, it may be possible to use the &windows; driver
837
	    with the help of the <link
837
	    with the help of the <link
838
	      linkend="config-network-ndis">NDIS</link> driver
838
	      linkend="config-network-ndis">NDIS</link> driver
839
	    wrapper.</para>
839
	    wrapper.</para>
840
	</note>
840
	</note>
841
841
842
	<para>In addition, the modules that implement cryptographic
842
	<para>In addition, the modules that implement cryptographic
843
	  support for the security protocols to use must be loaded.
843
	  support for the security protocols to use must be loaded.
844
	  These are intended to be dynamically loaded on demand by
844
	  These are intended to be dynamically loaded on demand by
845
	  the &man.wlan.4; module, but for now they must be manually
845
	  the &man.wlan.4; module, but for now they must be manually
846
	  configured.  The following modules are available:
846
	  configured.  The following modules are available:
847
	  &man.wlan.wep.4;, &man.wlan.ccmp.4;, and &man.wlan.tkip.4;.
847
	  &man.wlan.wep.4;, &man.wlan.ccmp.4;, and &man.wlan.tkip.4;.
848
	  The &man.wlan.ccmp.4; and &man.wlan.tkip.4; drivers are
848
	  The &man.wlan.ccmp.4; and &man.wlan.tkip.4; drivers are
849
	  only needed when using the <acronym>WPA</acronym> or
849
	  only needed when using the <acronym>WPA</acronym> or
850
	  802.11i security protocols.  If the network does not use
850
	  802.11i security protocols.  If the network does not use
851
	  encryption, &man.wlan.wep.4; support is not needed.  To
851
	  encryption, &man.wlan.wep.4; support is not needed.  To
852
	  load these modules at boot time, add the following lines to
852
	  load these modules at boot time, add the following lines to
853
	  <filename>/boot/loader.conf</filename>:</para>
853
	  <filename>/boot/loader.conf</filename>:</para>
854
854
855
	<programlisting>wlan_wep_load="YES"
855
	<programlisting>wlan_wep_load="YES"
856
wlan_ccmp_load="YES"
856
wlan_ccmp_load="YES"
857
wlan_tkip_load="YES"</programlisting>
857
wlan_tkip_load="YES"</programlisting>
858
858
859
	<para>Once this information has been added to
859
	<para>Once this information has been added to
860
	  <filename>/boot/loader.conf</filename>, reboot the &os;
860
	  <filename>/boot/loader.conf</filename>, reboot the &os;
861
	  box.  Alternately, load the modules by hand using
861
	  box.  Alternately, load the modules by hand using
862
	  &man.kldload.8;.</para>
862
	  &man.kldload.8;.</para>
863
863
864
	<note>
864
	<note>
865
	  <para>For users who do not want to use modules, it is
865
	  <para>For users who do not want to use modules, it is
866
	    possible to compile these drivers into the kernel by
866
	    possible to compile these drivers into the kernel by
867
	    adding the following lines to a custom kernel
867
	    adding the following lines to a custom kernel
868
	    configuration file:</para>
868
	    configuration file:</para>
869
869
870
	  <programlisting>device wlan              # 802.11 support
870
	  <programlisting>device wlan              # 802.11 support
871
device wlan_wep          # 802.11 WEP support
871
device wlan_wep          # 802.11 WEP support
872
device wlan_ccmp         # 802.11 CCMP support
872
device wlan_ccmp         # 802.11 CCMP support
873
device wlan_tkip         # 802.11 TKIP support
873
device wlan_tkip         # 802.11 TKIP support
874
device wlan_amrr         # AMRR transmit rate control algorithm
874
device wlan_amrr         # AMRR transmit rate control algorithm
875
device ath               # Atheros pci/cardbus NIC's
875
device ath               # Atheros pci/cardbus NIC's
876
device ath_hal           # pci/cardbus chip support
876
device ath_hal           # pci/cardbus chip support
877
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
877
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
878
device ath_rate_sample   # SampleRate tx rate control for ath</programlisting>
878
device ath_rate_sample   # SampleRate tx rate control for ath</programlisting>
879
879
880
	  <para>With this information in the kernel configuration
880
	  <para>With this information in the kernel configuration
881
	    file, recompile the kernel and reboot the &os;
881
	    file, recompile the kernel and reboot the &os;
882
	    machine.</para>
882
	    machine.</para>
883
	</note>
883
	</note>
884
884
885
	<para>Information about the wireless device should appear
885
	<para>Information about the wireless device should appear
886
	  in the boot messages, like this:</para>
886
	  in the boot messages, like this:</para>
887
887
888
	<screen>ath0: &lt;Atheros 5212&gt; mem 0x88000000-0x8800ffff irq 11 at device 0.0 on cardbus1
888
	<screen>ath0: &lt;Atheros 5212&gt; mem 0x88000000-0x8800ffff irq 11 at device 0.0 on cardbus1
889
ath0: [ITHREAD]
889
ath0: [ITHREAD]
890
ath0: AR2413 mac 7.9 RF2413 phy 4.5</screen>
890
ath0: AR2413 mac 7.9 RF2413 phy 4.5</screen>
891
      </sect3>
891
      </sect3>
892
    </sect2>
892
    </sect2>
893
893
894
    <sect2>
894
    <sect2>
895
      <title>Infrastructure Mode</title>
895
      <title>Infrastructure Mode</title>
896
896
897
      <para>Infrastructure (<acronym>BSS</acronym>) mode is the
897
      <para>Infrastructure (<acronym>BSS</acronym>) mode is the
898
	mode that is typically used.  In this mode, a number of
898
	mode that is typically used.  In this mode, a number of
899
	wireless access points are connected to a wired network.
899
	wireless access points are connected to a wired network.
900
	Each wireless network has its own name, called the
900
	Each wireless network has its own name, called the
901
	<acronym>SSID</acronym>.  Wireless clients connect to the
901
	<acronym>SSID</acronym>.  Wireless clients connect to the
902
	wireless access points.</para>
902
	wireless access points.</para>
903
903
904
      <sect3>
904
      <sect3>
905
	<title>&os; Clients</title>
905
	<title>&os; Clients</title>
906
906
907
	<sect4>
907
	<sect4>
908
	  <title>How to Find Access Points</title>
908
	  <title>How to Find Access Points</title>
909
909
910
	  <para>To scan for available networks, use &man.ifconfig.8;.
910
	  <para>To scan for available networks, use &man.ifconfig.8;.
911
	    This request may take a few moments to complete as it
911
	    This request may take a few moments to complete as it
912
	    requires the system to switch to each available wireless
912
	    requires the system to switch to each available wireless
913
	    frequency and probe for available access points.  Only
913
	    frequency and probe for available access points.  Only
914
	    the superuser can initiate a scan:</para>
914
	    the superuser can initiate a scan:</para>
915
915
916
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
916
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
917
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
917
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
918
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
918
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
919
dlinkap         00:13:46:49:41:76   11   54M -90:96   100 EPS  WPA WME
919
dlinkap         00:13:46:49:41:76   11   54M -90:96   100 EPS  WPA WME
920
freebsdap       00:11:95:c3:0d:ac    1   54M -83:96   100 EPS  WPA</screen>
920
freebsdap       00:11:95:c3:0d:ac    1   54M -83:96   100 EPS  WPA</screen>
921
921
922
	  <note>
922
	  <note>
923
	    <para>The interface must be <option>up</option> before
923
	    <para>The interface must be <option>up</option> before
924
	      it can scan.  Subsequent scan requests do not require
924
	      it can scan.  Subsequent scan requests do not require
925
	      the interface to be marked as up again.</para>
925
	      the interface to be marked as up again.</para>
926
	  </note>
926
	  </note>
927
927
928
	  <para>The output of a scan request lists each
928
	  <para>The output of a scan request lists each
929
	    <acronym>BSS</acronym>/<acronym>IBSS</acronym> network
929
	    <acronym>BSS</acronym>/<acronym>IBSS</acronym> network
930
	    found.  Besides listing the name of the network, the
930
	    found.  Besides listing the name of the network, the
931
	    <literal>SSID</literal>, the output also shows the
931
	    <literal>SSID</literal>, the output also shows the
932
	    <literal>BSSID</literal>, which is the
932
	    <literal>BSSID</literal>, which is the
933
	    <acronym>MAC</acronym> address of the access point.  The
933
	    <acronym>MAC</acronym> address of the access point.  The
934
	    <literal>CAPS</literal> field identifies the type of
934
	    <literal>CAPS</literal> field identifies the type of
935
	    each network and the capabilities of the stations
935
	    each network and the capabilities of the stations
936
	    operating there:</para>
936
	    operating there:</para>
937
937
938
	  <table frame="none" pgwide="0">
938
	  <table frame="none" pgwide="0">
939
	    <title>Station Capability Codes</title>
939
	    <title>Station Capability Codes</title>
940
940
941
	    <tgroup cols="2">
941
	    <tgroup cols="2">
942
	      <thead>
942
	      <thead>
943
		<row>
943
		<row>
944
		  <entry>Capability Code</entry>
944
		  <entry>Capability Code</entry>
945
		  <entry>Meaning</entry>
945
		  <entry>Meaning</entry>
946
		</row>
946
		</row>
947
	      </thead>
947
	      </thead>
948
948
949
	      <tbody>
949
	      <tbody>
950
		<row>
950
		<row>
951
		  <entry><literal>E</literal></entry>
951
		  <entry><literal>E</literal></entry>
952
		  <entry>Extended Service Set
952
		  <entry>Extended Service Set
953
		    (<acronym>ESS</acronym>).  Indicates that
953
		    (<acronym>ESS</acronym>).  Indicates that
954
		    the station is part of an infrastructure network
954
		    the station is part of an infrastructure network
955
		    rather than an <acronym>IBSS</acronym>/ad-hoc
955
		    rather than an <acronym>IBSS</acronym>/ad-hoc
956
		    network.</entry>
956
		    network.</entry>
957
		</row>
957
		</row>
958
958
959
		<row>
959
		<row>
960
		  <entry><literal>I</literal></entry>
960
		  <entry><literal>I</literal></entry>
961
		  <entry><acronym>IBSS</acronym>/ad-hoc network.
961
		  <entry><acronym>IBSS</acronym>/ad-hoc network.
962
		    Indicates that the station is part of an ad-hoc
962
		    Indicates that the station is part of an ad-hoc
963
		    network rather than an <acronym>ESS</acronym>
963
		    network rather than an <acronym>ESS</acronym>
964
		    network.</entry>
964
		    network.</entry>
965
		</row>
965
		</row>
966
966
967
		<row>
967
		<row>
968
		  <entry><literal>P</literal></entry>
968
		  <entry><literal>P</literal></entry>
969
		  <entry>Privacy.  Encryption is required for all
969
		  <entry>Privacy.  Encryption is required for all
970
		    data frames exchanged within the
970
		    data frames exchanged within the
971
		    <acronym>BSS</acronym> using cryptographic means
971
		    <acronym>BSS</acronym> using cryptographic means
972
		    such as <acronym>WEP</acronym>,
972
		    such as <acronym>WEP</acronym>,
973
		    <acronym>TKIP</acronym> or
973
		    <acronym>TKIP</acronym> or
974
		    <acronym>AES</acronym>-<acronym>CCMP</acronym>.</entry>
974
		    <acronym>AES</acronym>-<acronym>CCMP</acronym>.</entry>
975
		</row>
975
		</row>
976
976
977
		<row>
977
		<row>
978
		  <entry><literal>S</literal></entry>
978
		  <entry><literal>S</literal></entry>
979
		  <entry>Short Preamble.  Indicates that the network
979
		  <entry>Short Preamble.  Indicates that the network
980
		    is using short preambles, defined in 802.11b High
980
		    is using short preambles, defined in 802.11b High
981
		    Rate/DSSS PHY, and utilizes a 56 bit sync field
981
		    Rate/DSSS PHY, and utilizes a 56 bit sync field
982
		    rather than the 128 bit field used in long
982
		    rather than the 128 bit field used in long
983
		    preamble mode.</entry>
983
		    preamble mode.</entry>
984
		</row>
984
		</row>
985
985
986
		<row>
986
		<row>
987
		  <entry><literal>s</literal></entry>
987
		  <entry><literal>s</literal></entry>
988
		  <entry>Short slot time.  Indicates that the 802.11g
988
		  <entry>Short slot time.  Indicates that the 802.11g
989
		    network is using a short slot time because there
989
		    network is using a short slot time because there
990
		    are no legacy (802.11b) stations present.</entry>
990
		    are no legacy (802.11b) stations present.</entry>
991
		</row>
991
		</row>
992
	      </tbody>
992
	      </tbody>
993
	    </tgroup>
993
	    </tgroup>
994
	  </table>
994
	  </table>
995
995
996
	  <para>One can also display the current list of known
996
	  <para>One can also display the current list of known
997
	    networks with:</para>
997
	    networks with:</para>
998
998
999
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> list scan</userinput></screen>
999
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> list scan</userinput></screen>
1000
1000
1001
	  <para>This information may be updated automatically by the
1001
	  <para>This information may be updated automatically by the
1002
	    adapter or manually with a <option>scan</option> request.
1002
	    adapter or manually with a <option>scan</option> request.
1003
	    Old data is automatically removed from the cache, so over
1003
	    Old data is automatically removed from the cache, so over
1004
	    time this list may shrink unless more scans are
1004
	    time this list may shrink unless more scans are
1005
	    done.</para>
1005
	    done.</para>
1006
	</sect4>
1006
	</sect4>
1007
1007
1008
	<sect4>
1008
	<sect4>
1009
	  <title>Basic Settings</title>
1009
	  <title>Basic Settings</title>
1010
1010
1011
	  <para>This section provides a simple example of how to make
1011
	  <para>This section provides a simple example of how to make
1012
	    the wireless network adapter work in &os; without
1012
	    the wireless network adapter work in &os; without
1013
	    encryption.  Once familiar with these concepts, it is
1013
	    encryption.  Once familiar with these concepts, it is
1014
	    strongly recommend to use <link
1014
	    strongly recommend to use <link
1015
	      linkend="network-wireless-wpa">WPA</link> to set up
1015
	      linkend="network-wireless-wpa">WPA</link> to set up
1016
	    the wireless network.</para>
1016
	    the wireless network.</para>
1017
1017
1018
	  <para>There are three basic steps to configure a wireless
1018
	  <para>There are three basic steps to configure a wireless
1019
	    network: select an access point, authenticate the
1019
	    network: select an access point, authenticate the
1020
	    station, and configure an <acronym>IP</acronym> address.
1020
	    station, and configure an <acronym>IP</acronym> address.
1021
	    The following sections discuss each step.</para>
1021
	    The following sections discuss each step.</para>
1022
1022
1023
	  <sect5>
1023
	  <sect5>
1024
	    <title>Selecting an Access Point</title>
1024
	    <title>Selecting an Access Point</title>
1025
1025
1026
	    <para>Most of the time, it is sufficient to let the system
1026
	    <para>Most of the time, it is sufficient to let the system
1027
	      choose an access point using the builtin heuristics.
1027
	      choose an access point using the builtin heuristics.
1028
	      This is the default behavior when an interface is
1028
	      This is the default behavior when an interface is
1029
	      marked as up or it is listed in
1029
	      marked as up or it is listed in
1030
	      <filename>/etc/rc.conf</filename>:</para>
1030
	      <filename>/etc/rc.conf</filename>:</para>
1031
1031
1032
	    <programlisting>wlans_ath0="wlan0"
1032
	    <programlisting>wlans_ath0="wlan0"
1033
ifconfig_wlan0="DHCP"</programlisting>
1033
ifconfig_wlan0="DHCP"</programlisting>
1034
1034
1035
	    <para>If there are multiple access points, a specific
1035
	    <para>If there are multiple access points, a specific
1036
	      one can be selected by its
1036
	      one can be selected by its
1037
	      <acronym>SSID</acronym>:</para>
1037
	      <acronym>SSID</acronym>:</para>
1038
1038
1039
	    <programlisting>wlans_ath0="wlan0"
1039
	    <programlisting>wlans_ath0="wlan0"
1040
ifconfig_wlan0="ssid <replaceable>your_ssid_here</replaceable> DHCP"</programlisting>
1040
ifconfig_wlan0="ssid <replaceable>your_ssid_here</replaceable> DHCP"</programlisting>
1041
1041
1042
	    <para>In an environment where there are multiple access
1042
	    <para>In an environment where there are multiple access
1043
	      points with the same <acronym>SSID</acronym>, which
1043
	      points with the same <acronym>SSID</acronym>, which
1044
	      is often done to simplify roaming, it may be necessary
1044
	      is often done to simplify roaming, it may be necessary
1045
	      to associate to one specific device.  In this case, the
1045
	      to associate to one specific device.  In this case, the
1046
	      <acronym>BSSID</acronym> of the access point can be
1046
	      <acronym>BSSID</acronym> of the access point can be
1047
	      specified, with or without the
1047
	      specified, with or without the
1048
	      <acronym>SSID</acronym>:</para>
1048
	      <acronym>SSID</acronym>:</para>
1049
1049
1050
	    <programlisting>wlans_ath0="wlan0"
1050
	    <programlisting>wlans_ath0="wlan0"
1051
ifconfig_wlan0="ssid <replaceable>your_ssid_here</replaceable> bssid <replaceable>xx:xx:xx:xx:xx:xx</replaceable> DHCP"</programlisting>
1051
ifconfig_wlan0="ssid <replaceable>your_ssid_here</replaceable> bssid <replaceable>xx:xx:xx:xx:xx:xx</replaceable> DHCP"</programlisting>
1052
1052
1053
	    <para>There are other ways to constrain the choice of an
1053
	    <para>There are other ways to constrain the choice of an
1054
	      access point, such as limiting the set of frequencies
1054
	      access point, such as limiting the set of frequencies
1055
	      the system will scan on.  This may be useful for a
1055
	      the system will scan on.  This may be useful for a
1056
	      multi-band wireless card as scanning all the possible
1056
	      multi-band wireless card as scanning all the possible
1057
	      channels can be time-consuming.  To limit operation to a
1057
	      channels can be time-consuming.  To limit operation to a
1058
	      specific band, use the <option>mode</option>
1058
	      specific band, use the <option>mode</option>
1059
	      parameter:</para>
1059
	      parameter:</para>
1060
1060
1061
	    <programlisting>wlans_ath0="wlan0"
1061
	    <programlisting>wlans_ath0="wlan0"
1062
ifconfig_wlan0="mode <replaceable>11g</replaceable> ssid <replaceable>your_ssid_here</replaceable> DHCP"</programlisting>
1062
ifconfig_wlan0="mode <replaceable>11g</replaceable> ssid <replaceable>your_ssid_here</replaceable> DHCP"</programlisting>
1063
1063
1064
	    <para>This example will force the card to operate in
1064
	    <para>This example will force the card to operate in
1065
	      802.11g, which is defined only for 2.4GHz frequencies
1065
	      802.11g, which is defined only for 2.4GHz frequencies
1066
	      so any 5GHz channels will not be considered.  This can
1066
	      so any 5GHz channels will not be considered.  This can
1067
	      also be achieved with the
1067
	      also be achieved with the
1068
	      <option>channel</option> parameter, which locks
1068
	      <option>channel</option> parameter, which locks
1069
	      operation to one specific frequency, and the
1069
	      operation to one specific frequency, and the
1070
	      <option>chanlist</option> parameter, to specify a list
1070
	      <option>chanlist</option> parameter, to specify a list
1071
	      of channels for scanning.  More information about these
1071
	      of channels for scanning.  More information about these
1072
	      parameters can be found in &man.ifconfig.8;.</para>
1072
	      parameters can be found in &man.ifconfig.8;.</para>
1073
	  </sect5>
1073
	  </sect5>
1074
1074
1075
	  <sect5>
1075
	  <sect5>
1076
	    <title>Authentication</title>
1076
	    <title>Authentication</title>
1077
1077
1078
	    <para>Once an access point is selected, the station
1078
	    <para>Once an access point is selected, the station
1079
	      needs to authenticate before it can pass data.
1079
	      needs to authenticate before it can pass data.
1080
	      Authentication can happen in several ways.  The most
1080
	      Authentication can happen in several ways.  The most
1081
	      common scheme, open authentication, allows any station
1081
	      common scheme, open authentication, allows any station
1082
	      to join the network and communicate.  This is the
1082
	      to join the network and communicate.  This is the
1083
	      authentication to use for test purposes the first time
1083
	      authentication to use for test purposes the first time
1084
	      a wireless network is setup.  Other schemes require
1084
	      a wireless network is setup.  Other schemes require
1085
	      cryptographic handshakes to be completed before data
1085
	      cryptographic handshakes to be completed before data
1086
	      traffic can flow, either using pre-shared keys or
1086
	      traffic can flow, either using pre-shared keys or
1087
	      secrets, or more complex schemes that involve backend
1087
	      secrets, or more complex schemes that involve backend
1088
	      services such as <acronym>RADIUS</acronym>.  Open
1088
	      services such as <acronym>RADIUS</acronym>.  Open
1089
	      authentication is the default setting.  The next most
1089
	      authentication is the default setting.  The next most
1090
	      common setup is <acronym>WPA-PSK</acronym>, also
1090
	      common setup is <acronym>WPA-PSK</acronym>, also
1091
	      known as <acronym>WPA</acronym> Personal, which is
1091
	      known as <acronym>WPA</acronym> Personal, which is
1092
	      described in <xref
1092
	      described in <xref
1093
		linkend="network-wireless-wpa-wpa-psk"/>.</para>
1093
		linkend="network-wireless-wpa-wpa-psk"/>.</para>
1094
1094
1095
	    <note>
1095
	    <note>
1096
	      <para>If using an &apple; &airport; Extreme base
1096
	      <para>If using an &apple; &airport; Extreme base
1097
		station for an access point, shared-key authentication
1097
		station for an access point, shared-key authentication
1098
		together with a <acronym>WEP</acronym> key needs to
1098
		together with a <acronym>WEP</acronym> key needs to
1099
		be configured.  This can be configured in
1099
		be configured.  This can be configured in
1100
		<filename>/etc/rc.conf</filename> or by using
1100
		<filename>/etc/rc.conf</filename> or by using
1101
		&man.wpa.supplicant.8;.  For a single &airport; base
1101
		&man.wpa.supplicant.8;.  For a single &airport; base
1102
		station, access can be configured with:</para>
1102
		station, access can be configured with:</para>
1103
1103
1104
	      <programlisting>wlans_ath0="wlan0"
1104
	      <programlisting>wlans_ath0="wlan0"
1105
ifconfig_wlan0="authmode shared wepmode on weptxkey <replaceable>1</replaceable> wepkey <replaceable>01234567</replaceable> DHCP"</programlisting>
1105
ifconfig_wlan0="authmode shared wepmode on weptxkey <replaceable>1</replaceable> wepkey <replaceable>01234567</replaceable> DHCP"</programlisting>
1106
1106
1107
	      <para>In general, shared key authentication should be
1107
	      <para>In general, shared key authentication should be
1108
		avoided because it uses the <acronym>WEP</acronym> key
1108
		avoided because it uses the <acronym>WEP</acronym> key
1109
		material in a highly-constrained manner, making it
1109
		material in a highly-constrained manner, making it
1110
		even easier to crack the key.  If
1110
		even easier to crack the key.  If
1111
		<acronym>WEP</acronym> must be used for compatibility
1111
		<acronym>WEP</acronym> must be used for compatibility
1112
		with legacy devices, it is better to use
1112
		with legacy devices, it is better to use
1113
		<acronym>WEP</acronym> with <literal>open</literal>
1113
		<acronym>WEP</acronym> with <literal>open</literal>
1114
		authentication.  More information regarding
1114
		authentication.  More information regarding
1115
		<acronym>WEP</acronym> can be found in <xref
1115
		<acronym>WEP</acronym> can be found in <xref
1116
		  linkend="network-wireless-wep"/>.</para>
1116
		  linkend="network-wireless-wep"/>.</para>
1117
	    </note>
1117
	    </note>
1118
	  </sect5>
1118
	  </sect5>
1119
1119
1120
	  <sect5>
1120
	  <sect5>
1121
	    <title>Getting an <acronym>IP</acronym> Address with
1121
	    <title>Getting an <acronym>IP</acronym> Address with
1122
	      <acronym>DHCP</acronym></title>
1122
	      <acronym>DHCP</acronym></title>
1123
1123
1124
	    <para>Once an access point is selected and the
1124
	    <para>Once an access point is selected and the
1125
	      authentication parameters are set, an
1125
	      authentication parameters are set, an
1126
	      <acronym>IP</acronym> address must be obtained in
1126
	      <acronym>IP</acronym> address must be obtained in
1127
	      order to communicate.  Most of the time, the
1127
	      order to communicate.  Most of the time, the
1128
	      <acronym>IP</acronym> address is obtained via
1128
	      <acronym>IP</acronym> address is obtained via
1129
	      <acronym>DHCP</acronym>.  To achieve that, edit
1129
	      <acronym>DHCP</acronym>.  To achieve that, edit
1130
	      <filename>/etc/rc.conf</filename> and add
1130
	      <filename>/etc/rc.conf</filename> and add
1131
	      <literal>DHCP</literal> to the configuration for the
1131
	      <literal>DHCP</literal> to the configuration for the
1132
	      device:</para>
1132
	      device:</para>
1133
1133
1134
	    <programlisting>wlans_ath0="wlan0"
1134
	    <programlisting>wlans_ath0="wlan0"
1135
ifconfig_wlan0="DHCP"</programlisting>
1135
ifconfig_wlan0="DHCP"</programlisting>
1136
1136
1137
	    <para>The
1137
	    <para>The
1138
	      wireless interface is now ready to bring up:</para>
1138
	      wireless interface is now ready to bring up:</para>
1139
1139
1140
	    <screen>&prompt.root; <userinput>service netif start</userinput></screen>
1140
	    <screen>&prompt.root; <userinput>service netif start</userinput></screen>
1141
1141
1142
	    <para>Once the interface is running, use &man.ifconfig.8;
1142
	    <para>Once the interface is running, use &man.ifconfig.8;
1143
	      to see the status of the interface
1143
	      to see the status of the interface
1144
	      <filename>ath0</filename>:</para>
1144
	      <filename>ath0</filename>:</para>
1145
1145
1146
	    <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1146
	    <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1147
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1147
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1148
        ether 00:11:95:d5:43:62
1148
        ether 00:11:95:d5:43:62
1149
        inet 192.168.1.100 netmask 0xffffff00 broadcast 192.168.1.255
1149
        inet 192.168.1.100 netmask 0xffffff00 broadcast 192.168.1.255
1150
        media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
1150
        media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
1151
        status: associated
1151
        status: associated
1152
        ssid dlinkap channel 11 (2462 Mhz 11g) bssid 00:13:46:49:41:76
1152
        ssid dlinkap channel 11 (2462 Mhz 11g) bssid 00:13:46:49:41:76
1153
        country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
1153
        country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
1154
        scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
1154
        scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
1155
        roam:rate 5 protmode CTS wme burst</screen>
1155
        roam:rate 5 protmode CTS wme burst</screen>
1156
1156
1157
	    <para>The <literal>status: associated</literal> line means
1157
	    <para>The <literal>status: associated</literal> line means
1158
	      that it is connected to the wireless network.  The
1158
	      that it is connected to the wireless network.  The
1159
	      <literal>bssid 00:13:46:49:41:76</literal> is the
1159
	      <literal>bssid 00:13:46:49:41:76</literal> is the
1160
	      <acronym>MAC</acronym> address of the access point and
1160
	      <acronym>MAC</acronym> address of the access point and
1161
	      <literal>authmode OPEN</literal> indicates that the
1161
	      <literal>authmode OPEN</literal> indicates that the
1162
	      communication is not encrypted.</para>
1162
	      communication is not encrypted.</para>
1163
	  </sect5>
1163
	  </sect5>
1164
1164
1165
	  <sect5>
1165
	  <sect5>
1166
	    <title>Static <acronym>IP</acronym> Address</title>
1166
	    <title>Static <acronym>IP</acronym> Address</title>
1167
1167
1168
	    <para>If an <acronym>IP</acronym> address cannot be
1168
	    <para>If an <acronym>IP</acronym> address cannot be
1169
	      obtained from a <acronym>DHCP</acronym> server, set a
1169
	      obtained from a <acronym>DHCP</acronym> server, set a
1170
	      fixed <acronym>IP</acronym> address.  Replace the
1170
	      fixed <acronym>IP</acronym> address.  Replace the
1171
	      <literal>DHCP</literal> keyword shown above with the
1171
	      <literal>DHCP</literal> keyword shown above with the
1172
	      address information.  Be sure to retain any other
1172
	      address information.  Be sure to retain any other
1173
	      parameters for selecting the access point:</para>
1173
	      parameters for selecting the access point:</para>
1174
1174
1175
	    <programlisting>wlans_ath0="wlan0"
1175
	    <programlisting>wlans_ath0="wlan0"
1176
ifconfig_wlan0="inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>your_ssid_here</replaceable>"</programlisting>
1176
ifconfig_wlan0="inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>your_ssid_here</replaceable>"</programlisting>
1177
	  </sect5>
1177
	  </sect5>
1178
	</sect4>
1178
	</sect4>
1179
1179
1180
	<sect4 xml:id="network-wireless-wpa">
1180
	<sect4 xml:id="network-wireless-wpa">
1181
	  <title><acronym>WPA</acronym></title>
1181
	  <title><acronym>WPA</acronym></title>
1182
1182
1183
	  <para>Wi-Fi Protected Access (<acronym>WPA</acronym>) is a
1183
	  <para>Wi-Fi Protected Access (<acronym>WPA</acronym>) is a
1184
	    security protocol used together with 802.11 networks to
1184
	    security protocol used together with 802.11 networks to
1185
	    address the lack of proper authentication and the weakness
1185
	    address the lack of proper authentication and the weakness
1186
	    of <acronym>WEP</acronym>.  WPA leverages the 802.1X
1186
	    of <acronym>WEP</acronym>.  WPA leverages the 802.1X
1187
	    authentication protocol and uses one of several ciphers
1187
	    authentication protocol and uses one of several ciphers
1188
	    instead of <acronym>WEP</acronym> for data integrity.
1188
	    instead of <acronym>WEP</acronym> for data integrity.
1189
	    The only cipher required by <acronym>WPA</acronym> is the
1189
	    The only cipher required by <acronym>WPA</acronym> is the
1190
	    Temporary Key Integrity Protocol
1190
	    Temporary Key Integrity Protocol
1191
	    (<acronym>TKIP</acronym>).  <acronym>TKIP</acronym> is a
1191
	    (<acronym>TKIP</acronym>).  <acronym>TKIP</acronym> is a
1192
	    cipher that extends the basic RC4 cipher used by
1192
	    cipher that extends the basic RC4 cipher used by
1193
	    <acronym>WEP</acronym> by adding integrity checking,
1193
	    <acronym>WEP</acronym> by adding integrity checking,
1194
	    tamper detection, and measures for responding to detected
1194
	    tamper detection, and measures for responding to detected
1195
	    intrusions.  <acronym>TKIP</acronym> is designed to work
1195
	    intrusions.  <acronym>TKIP</acronym> is designed to work
1196
	    on legacy hardware with only software modification.  It
1196
	    on legacy hardware with only software modification.  It
1197
	    represents a compromise that improves security but is
1197
	    represents a compromise that improves security but is
1198
	    still not entirely immune to attack.
1198
	    still not entirely immune to attack.
1199
	    <acronym>WPA</acronym> also specifies the
1199
	    <acronym>WPA</acronym> also specifies the
1200
	    <acronym>AES-CCMP</acronym> cipher as an alternative to
1200
	    <acronym>AES-CCMP</acronym> cipher as an alternative to
1201
	    <acronym>TKIP</acronym>, and that is preferred when
1201
	    <acronym>TKIP</acronym>, and that is preferred when
1202
	    possible.  For this specification, the term
1202
	    possible.  For this specification, the term
1203
	    <acronym>WPA2</acronym> or <acronym>RSN</acronym> is
1203
	    <acronym>WPA2</acronym> or <acronym>RSN</acronym> is
1204
	    commonly used.</para>
1204
	    commonly used.</para>
1205
1205
1206
	  <para><acronym>WPA</acronym> defines authentication and
1206
	  <para><acronym>WPA</acronym> defines authentication and
1207
	    encryption protocols.  Authentication is most commonly
1207
	    encryption protocols.  Authentication is most commonly
1208
	    done using one of two techniques: by 802.1X and a backend
1208
	    done using one of two techniques: by 802.1X and a backend
1209
	    authentication service such as <acronym>RADIUS</acronym>,
1209
	    authentication service such as <acronym>RADIUS</acronym>,
1210
	    or by a minimal handshake between the station and the
1210
	    or by a minimal handshake between the station and the
1211
	    access point using a pre-shared secret.  The former is
1211
	    access point using a pre-shared secret.  The former is
1212
	    commonly termed <acronym>WPA</acronym> Enterprise and the
1212
	    commonly termed <acronym>WPA</acronym> Enterprise and the
1213
	    latter is known as <acronym>WPA</acronym> Personal.  Since
1213
	    latter is known as <acronym>WPA</acronym> Personal.  Since
1214
	    most people will not set up a <acronym>RADIUS</acronym>
1214
	    most people will not set up a <acronym>RADIUS</acronym>
1215
	    backend server for their wireless network,
1215
	    backend server for their wireless network,
1216
	    <acronym>WPA-PSK</acronym> is by far the most commonly
1216
	    <acronym>WPA-PSK</acronym> is by far the most commonly
1217
	    encountered configuration for
1217
	    encountered configuration for
1218
	    <acronym>WPA</acronym>.</para>
1218
	    <acronym>WPA</acronym>.</para>
1219
1219
1220
	  <para>The control of the wireless connection and the key
1220
	  <para>The control of the wireless connection and the key
1221
	    negotiation or authentication with a server is done using
1221
	    negotiation or authentication with a server is done using
1222
	    &man.wpa.supplicant.8;.  This program requires a
1222
	    &man.wpa.supplicant.8;.  This program requires a
1223
	    configuration file,
1223
	    configuration file,
1224
	    <filename>/etc/wpa_supplicant.conf</filename>, to run.
1224
	    <filename>/etc/wpa_supplicant.conf</filename>, to run.
1225
	    More information regarding this file can be found in
1225
	    More information regarding this file can be found in
1226
	    &man.wpa.supplicant.conf.5;.</para>
1226
	    &man.wpa.supplicant.conf.5;.</para>
1227
1227
1228
	  <sect5 xml:id="network-wireless-wpa-wpa-psk">
1228
	  <sect5 xml:id="network-wireless-wpa-wpa-psk">
1229
	    <title><acronym>WPA-PSK</acronym></title>
1229
	    <title><acronym>WPA-PSK</acronym></title>
1230
1230
1231
	    <para><acronym>WPA-PSK</acronym>, also known as
1231
	    <para><acronym>WPA-PSK</acronym>, also known as
1232
	      <acronym>WPA</acronym> Personal, is based on a
1232
	      <acronym>WPA</acronym> Personal, is based on a
1233
	      pre-shared key (<acronym>PSK</acronym>) which is
1233
	      pre-shared key (<acronym>PSK</acronym>) which is
1234
	      generated from a given password and used as the master
1234
	      generated from a given password and used as the master
1235
	      key in the wireless network.  This means every wireless
1235
	      key in the wireless network.  This means every wireless
1236
	      user will share the same key.
1236
	      user will share the same key.
1237
	      <acronym>WPA-PSK</acronym> is intended for small
1237
	      <acronym>WPA-PSK</acronym> is intended for small
1238
	      networks where the use of an authentication server is
1238
	      networks where the use of an authentication server is
1239
	      not possible or desired.</para>
1239
	      not possible or desired.</para>
1240
1240
1241
	    <warning>
1241
	    <warning>
1242
	      <para>Always use strong passwords that are sufficiently
1242
	      <para>Always use strong passwords that are sufficiently
1243
		long and made from a rich alphabet so that they will
1243
		long and made from a rich alphabet so that they will
1244
		not be easily guessed or attacked.</para>
1244
		not be easily guessed or attacked.</para>
1245
	    </warning>
1245
	    </warning>
1246
1246
1247
	    <para>The first step is the configuration of
1247
	    <para>The first step is the configuration of
1248
	      <filename>/etc/wpa_supplicant.conf</filename> with
1248
	      <filename>/etc/wpa_supplicant.conf</filename> with
1249
	      the <acronym>SSID</acronym> and the pre-shared key of
1249
	      the <acronym>SSID</acronym> and the pre-shared key of
1250
	      the network:</para>
1250
	      the network:</para>
1251
1251
1252
	    <programlisting>network={
1252
	    <programlisting>network={
1253
  ssid="freebsdap"
1253
  ssid="freebsdap"
1254
  psk="freebsdmall"
1254
  psk="freebsdmall"
1255
}</programlisting>
1255
}</programlisting>
1256
1256
1257
	    <para>Then, in <filename>/etc/rc.conf</filename>,
1257
	    <para>Then, in <filename>/etc/rc.conf</filename>,
1258
	      indicate that the wireless device configuration will be
1258
	      indicate that the wireless device configuration will be
1259
	      done with <acronym>WPA</acronym> and the
1259
	      done with <acronym>WPA</acronym> and the
1260
	      <acronym>IP</acronym> address will be obtained with
1260
	      <acronym>IP</acronym> address will be obtained with
1261
	      <acronym>DHCP</acronym>:</para>
1261
	      <acronym>DHCP</acronym>:</para>
1262
1262
1263
	    <programlisting>wlans_ath0="wlan0"
1263
	    <programlisting>wlans_ath0="wlan0"
1264
ifconfig_wlan0="WPA DHCP"</programlisting>
1264
ifconfig_wlan0="WPA DHCP"</programlisting>
1265
1265
1266
	    <para>Then, bring up the interface:</para>
1266
	    <para>Then, bring up the interface:</para>
1267
1267
1268
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1268
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1269
Starting wpa_supplicant.
1269
Starting wpa_supplicant.
1270
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
1270
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
1271
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
1271
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
1272
DHCPOFFER from 192.168.0.1
1272
DHCPOFFER from 192.168.0.1
1273
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
1273
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
1274
DHCPACK from 192.168.0.1
1274
DHCPACK from 192.168.0.1
1275
bound to 192.168.0.254 -- renewal in 300 seconds.
1275
bound to 192.168.0.254 -- renewal in 300 seconds.
1276
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1276
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1277
      ether 00:11:95:d5:43:62
1277
      ether 00:11:95:d5:43:62
1278
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1278
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1279
      media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
1279
      media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
1280
      status: associated
1280
      status: associated
1281
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1281
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1282
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1282
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1283
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1283
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1284
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1284
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1285
      wme burst roaming MANUAL</screen>
1285
      wme burst roaming MANUAL</screen>
1286
1286
1287
	    <para>Or, try to configure the interface manually using
1287
	    <para>Or, try to configure the interface manually using
1288
	      the information in
1288
	      the information in
1289
	      <filename>/etc/wpa_supplicant.conf</filename>:</para>
1289
	      <filename>/etc/wpa_supplicant.conf</filename>:</para>
1290
1290
1291
	    <screen>&prompt.root; <userinput>wpa_supplicant -i <replaceable>wlan0</replaceable> -c /etc/wpa_supplicant.conf</userinput>
1291
	    <screen>&prompt.root; <userinput>wpa_supplicant -i <replaceable>wlan0</replaceable> -c /etc/wpa_supplicant.conf</userinput>
1292
Trying to associate with 00:11:95:c3:0d:ac (SSID='freebsdap' freq=2412 MHz)
1292
Trying to associate with 00:11:95:c3:0d:ac (SSID='freebsdap' freq=2412 MHz)
1293
Associated with 00:11:95:c3:0d:ac
1293
Associated with 00:11:95:c3:0d:ac
1294
WPA: Key negotiation completed with 00:11:95:c3:0d:ac [PTK=CCMP GTK=CCMP]
1294
WPA: Key negotiation completed with 00:11:95:c3:0d:ac [PTK=CCMP GTK=CCMP]
1295
CTRL-EVENT-CONNECTED - Connection to 00:11:95:c3:0d:ac completed (auth) [id=0 id_str=]</screen>
1295
CTRL-EVENT-CONNECTED - Connection to 00:11:95:c3:0d:ac completed (auth) [id=0 id_str=]</screen>
1296
1296
1297
	    <para>The next operation is to launch &man.dhclient.8;
1297
	    <para>The next operation is to launch &man.dhclient.8;
1298
	      to get the <acronym>IP</acronym> address from the
1298
	      to get the <acronym>IP</acronym> address from the
1299
	      <acronym>DHCP</acronym> server:</para>
1299
	      <acronym>DHCP</acronym> server:</para>
1300
1300
1301
	    <screen>&prompt.root; <userinput>dhclient <replaceable>wlan0</replaceable></userinput>
1301
	    <screen>&prompt.root; <userinput>dhclient <replaceable>wlan0</replaceable></userinput>
1302
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
1302
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
1303
DHCPACK from 192.168.0.1
1303
DHCPACK from 192.168.0.1
1304
bound to 192.168.0.254 -- renewal in 300 seconds.
1304
bound to 192.168.0.254 -- renewal in 300 seconds.
1305
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1305
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1306
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1306
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1307
      ether 00:11:95:d5:43:62
1307
      ether 00:11:95:d5:43:62
1308
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1308
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1309
      media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
1309
      media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
1310
      status: associated
1310
      status: associated
1311
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1311
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1312
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1312
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1313
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1313
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1314
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1314
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1315
      wme burst roaming MANUAL</screen>
1315
      wme burst roaming MANUAL</screen>
1316
1316
1317
	    <note>
1317
	    <note>
1318
	      <para>If <filename>/etc/rc.conf</filename> has an
1318
	      <para>If <filename>/etc/rc.conf</filename> has an
1319
		<literal>ifconfig_wlan0="DHCP"</literal> entry,
1319
		<literal>ifconfig_wlan0="DHCP"</literal> entry,
1320
		&man.dhclient.8; will be launched automatically after
1320
		&man.dhclient.8; will be launched automatically after
1321
		&man.wpa.supplicant.8; associates with the access
1321
		&man.wpa.supplicant.8; associates with the access
1322
		point.</para>
1322
		point.</para>
1323
	    </note>
1323
	    </note>
1324
1324
1325
	    <para>If <acronym>DHCP</acronym> is not possible or
1325
	    <para>If <acronym>DHCP</acronym> is not possible or
1326
	      desired, set a static <acronym>IP</acronym> address
1326
	      desired, set a static <acronym>IP</acronym> address
1327
	      after &man.wpa.supplicant.8; has authenticated the
1327
	      after &man.wpa.supplicant.8; has authenticated the
1328
	      station:</para>
1328
	      station:</para>
1329
1329
1330
	    <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.100</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput>
1330
	    <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.100</replaceable> netmask <replaceable>255.255.255.0</replaceable></userinput>
1331
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1331
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1332
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1332
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1333
      ether 00:11:95:d5:43:62
1333
      ether 00:11:95:d5:43:62
1334
      inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255
1334
      inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255
1335
      media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
1335
      media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
1336
      status: associated
1336
      status: associated
1337
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1337
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1338
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1338
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1339
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1339
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1340
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1340
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1341
      wme burst roaming MANUAL</screen>
1341
      wme burst roaming MANUAL</screen>
1342
1342
1343
	    <para>When <acronym>DHCP</acronym> is not used, the
1343
	    <para>When <acronym>DHCP</acronym> is not used, the
1344
	      default gateway and the nameserver also have to be
1344
	      default gateway and the nameserver also have to be
1345
	      manually set:</para>
1345
	      manually set:</para>
1346
1346
1347
	    <screen>&prompt.root; <userinput>route add default <replaceable>your_default_router</replaceable></userinput>
1347
	    <screen>&prompt.root; <userinput>route add default <replaceable>your_default_router</replaceable></userinput>
1348
&prompt.root; <userinput>echo "nameserver <replaceable>your_DNS_server</replaceable>" &gt;&gt; /etc/resolv.conf</userinput></screen>
1348
&prompt.root; <userinput>echo "nameserver <replaceable>your_DNS_server</replaceable>" &gt;&gt; /etc/resolv.conf</userinput></screen>
1349
	  </sect5>
1349
	  </sect5>
1350
1350
1351
	  <sect5 xml:id="network-wireless-wpa-eap-tls">
1351
	  <sect5 xml:id="network-wireless-wpa-eap-tls">
1352
	    <title><acronym>WPA</acronym> with
1352
	    <title><acronym>WPA</acronym> with
1353
	      <acronym>EAP-TLS</acronym></title>
1353
	      <acronym>EAP-TLS</acronym></title>
1354
1354
1355
	    <para>The second way to use <acronym>WPA</acronym> is with
1355
	    <para>The second way to use <acronym>WPA</acronym> is with
1356
	      an 802.1X backend authentication server.  In this case,
1356
	      an 802.1X backend authentication server.  In this case,
1357
	      <acronym>WPA</acronym> is called
1357
	      <acronym>WPA</acronym> is called
1358
	      <acronym>WPA</acronym> Enterprise to differentiate it
1358
	      <acronym>WPA</acronym> Enterprise to differentiate it
1359
	      from the less secure <acronym>WPA</acronym> Personal.
1359
	      from the less secure <acronym>WPA</acronym> Personal.
1360
	      Authentication in <acronym>WPA</acronym> Enterprise is
1360
	      Authentication in <acronym>WPA</acronym> Enterprise is
1361
	      based on the Extensible Authentication Protocol
1361
	      based on the Extensible Authentication Protocol
1362
	      (<acronym>EAP</acronym>).</para>
1362
	      (<acronym>EAP</acronym>).</para>
1363
1363
1364
	    <para><acronym>EAP</acronym> does not come with an
1364
	    <para><acronym>EAP</acronym> does not come with an
1365
	      encryption method.  Instead, <acronym>EAP</acronym> is
1365
	      encryption method.  Instead, <acronym>EAP</acronym> is
1366
	      embedded inside an encrypted tunnel.  There are many
1366
	      embedded inside an encrypted tunnel.  There are many
1367
	      <acronym>EAP</acronym> authentication methods, but
1367
	      <acronym>EAP</acronym> authentication methods, but
1368
	      <acronym>EAP-TLS</acronym>, <acronym>EAP-TTLS</acronym>,
1368
	      <acronym>EAP-TLS</acronym>, <acronym>EAP-TTLS</acronym>,
1369
	      and <acronym>EAP-PEAP</acronym> are the most
1369
	      and <acronym>EAP-PEAP</acronym> are the most
1370
	      common.</para>
1370
	      common.</para>
1371
1371
1372
	    <para>EAP with Transport Layer Security
1372
	    <para>EAP with Transport Layer Security
1373
	      (<acronym>EAP-TLS</acronym>) is a well-supported
1373
	      (<acronym>EAP-TLS</acronym>) is a well-supported
1374
	      wireless authentication protocol since it was the
1374
	      wireless authentication protocol since it was the
1375
	      first <acronym>EAP</acronym> method to be certified
1375
	      first <acronym>EAP</acronym> method to be certified
1376
	      by the <link
1376
	      by the <link
1377
		xlink:href="http://www.wi-fi.org/">Wi-Fi
1377
		xlink:href="http://www.wi-fi.org/">Wi-Fi
1378
		Alliance</link>.  <acronym>EAP-TLS</acronym> requires
1378
		Alliance</link>.  <acronym>EAP-TLS</acronym> requires
1379
	      three certificates to run: the certificate of the
1379
	      three certificates to run: the certificate of the
1380
	      Certificate Authority (<acronym>CA</acronym>) installed
1380
	      Certificate Authority (<acronym>CA</acronym>) installed
1381
	      on all machines, the server certificate for the
1381
	      on all machines, the server certificate for the
1382
	      authentication server, and one client certificate for
1382
	      authentication server, and one client certificate for
1383
	      each wireless client.  In this <acronym>EAP</acronym>
1383
	      each wireless client.  In this <acronym>EAP</acronym>
1384
	      method, both the authentication server and wireless
1384
	      method, both the authentication server and wireless
1385
	      client authenticate each other by presenting their
1385
	      client authenticate each other by presenting their
1386
	      respective certificates, and then verify that these
1386
	      respective certificates, and then verify that these
1387
	      certificates were signed by the organization's
1387
	      certificates were signed by the organization's
1388
	      <acronym>CA</acronym>.</para>
1388
	      <acronym>CA</acronym>.</para>
1389
1389
1390
	    <para>As previously, the configuration is done via
1390
	    <para>As previously, the configuration is done via
1391
	      <filename>/etc/wpa_supplicant.conf</filename>:</para>
1391
	      <filename>/etc/wpa_supplicant.conf</filename>:</para>
1392
1392
1393
	    <programlisting>network={
1393
	    <programlisting>network={
1394
  ssid="freebsdap" <co xml:id="co-tls-ssid"/>
1394
  ssid="freebsdap" <co xml:id="co-tls-ssid"/>
1395
  proto=RSN  <co xml:id="co-tls-proto"/>
1395
  proto=RSN  <co xml:id="co-tls-proto"/>
1396
  key_mgmt=WPA-EAP <co xml:id="co-tls-kmgmt"/>
1396
  key_mgmt=WPA-EAP <co xml:id="co-tls-kmgmt"/>
1397
  eap=TLS <co xml:id="co-tls-eap"/>
1397
  eap=TLS <co xml:id="co-tls-eap"/>
1398
  identity="loader" <co xml:id="co-tls-id"/>
1398
  identity="loader" <co xml:id="co-tls-id"/>
1399
  ca_cert="/etc/certs/cacert.pem" <co xml:id="co-tls-cacert"/>
1399
  ca_cert="/etc/certs/cacert.pem" <co xml:id="co-tls-cacert"/>
1400
  client_cert="/etc/certs/clientcert.pem" <co xml:id="co-tls-clientcert"/>
1400
  client_cert="/etc/certs/clientcert.pem" <co xml:id="co-tls-clientcert"/>
1401
  private_key="/etc/certs/clientkey.pem" <co xml:id="co-tls-pkey"/>
1401
  private_key="/etc/certs/clientkey.pem" <co xml:id="co-tls-pkey"/>
1402
  private_key_passwd="freebsdmallclient" <co xml:id="co-tls-pwd"/>
1402
  private_key_passwd="freebsdmallclient" <co xml:id="co-tls-pwd"/>
1403
}</programlisting>
1403
}</programlisting>
1404
1404
1405
	    <calloutlist>
1405
	    <calloutlist>
1406
	      <callout arearefs="co-tls-ssid">
1406
	      <callout arearefs="co-tls-ssid">
1407
		<para>This field indicates the network name
1407
		<para>This field indicates the network name
1408
		  (<acronym>SSID</acronym>).</para>
1408
		  (<acronym>SSID</acronym>).</para>
1409
	      </callout>
1409
	      </callout>
1410
1410
1411
	      <callout arearefs="co-tls-proto">
1411
	      <callout arearefs="co-tls-proto">
1412
		<para>This example uses the <acronym>RSN</acronym>
1412
		<para>This example uses the <acronym>RSN</acronym>
1413
		  &ieee; 802.11i protocol, also known as
1413
		  &ieee; 802.11i protocol, also known as
1414
		  <acronym>WPA2</acronym>.</para>
1414
		  <acronym>WPA2</acronym>.</para>
1415
	      </callout>
1415
	      </callout>
1416
1416
1417
	      <callout arearefs="co-tls-kmgmt">
1417
	      <callout arearefs="co-tls-kmgmt">
1418
		<para>The <literal>key_mgmt</literal> line refers to
1418
		<para>The <literal>key_mgmt</literal> line refers to
1419
		  the key management protocol to use.  In this
1419
		  the key management protocol to use.  In this
1420
		  example, it is <acronym>WPA</acronym> using
1420
		  example, it is <acronym>WPA</acronym> using
1421
		  <acronym>EAP</acronym> authentication.</para>
1421
		  <acronym>EAP</acronym> authentication.</para>
1422
	      </callout>
1422
	      </callout>
1423
1423
1424
	      <callout arearefs="co-tls-eap">
1424
	      <callout arearefs="co-tls-eap">
1425
		<para>This field indicates the <acronym>EAP</acronym>
1425
		<para>This field indicates the <acronym>EAP</acronym>
1426
		  method for the connection.</para>
1426
		  method for the connection.</para>
1427
	      </callout>
1427
	      </callout>
1428
1428
1429
	      <callout arearefs="co-tls-id">
1429
	      <callout arearefs="co-tls-id">
1430
		<para>The <literal>identity</literal> field contains
1430
		<para>The <literal>identity</literal> field contains
1431
		  the identity string for
1431
		  the identity string for
1432
		  <acronym>EAP</acronym>.</para>
1432
		  <acronym>EAP</acronym>.</para>
1433
	      </callout>
1433
	      </callout>
1434
1434
1435
	      <callout arearefs="co-tls-cacert">
1435
	      <callout arearefs="co-tls-cacert">
1436
		<para>The <literal>ca_cert</literal> field indicates
1436
		<para>The <literal>ca_cert</literal> field indicates
1437
		  the pathname of the <acronym>CA</acronym>
1437
		  the pathname of the <acronym>CA</acronym>
1438
		  certificate file.  This file is needed to verify
1438
		  certificate file.  This file is needed to verify
1439
		  the server certificate.</para>
1439
		  the server certificate.</para>
1440
	      </callout>
1440
	      </callout>
1441
1441
1442
	      <callout arearefs="co-tls-clientcert">
1442
	      <callout arearefs="co-tls-clientcert">
1443
		<para>The <literal>client_cert</literal> line gives
1443
		<para>The <literal>client_cert</literal> line gives
1444
		  the pathname to the client certificate file.  This
1444
		  the pathname to the client certificate file.  This
1445
		  certificate is unique to each wireless client of the
1445
		  certificate is unique to each wireless client of the
1446
		  network.</para>
1446
		  network.</para>
1447
	      </callout>
1447
	      </callout>
1448
1448
1449
	      <callout arearefs="co-tls-pkey">
1449
	      <callout arearefs="co-tls-pkey">
1450
		<para>The <literal>private_key</literal> field is the
1450
		<para>The <literal>private_key</literal> field is the
1451
		  pathname to the client certificate private key
1451
		  pathname to the client certificate private key
1452
		  file.</para>
1452
		  file.</para>
1453
	      </callout>
1453
	      </callout>
1454
1454
1455
	      <callout arearefs="co-tls-pwd">
1455
	      <callout arearefs="co-tls-pwd">
1456
		<para>The <literal>private_key_passwd</literal> field
1456
		<para>The <literal>private_key_passwd</literal> field
1457
		  contains the passphrase for the private key.</para>
1457
		  contains the passphrase for the private key.</para>
1458
	      </callout>
1458
	      </callout>
1459
	    </calloutlist>
1459
	    </calloutlist>
1460
1460
1461
	    <para>Then, add the following lines to
1461
	    <para>Then, add the following lines to
1462
	      <filename>/etc/rc.conf</filename>:</para>
1462
	      <filename>/etc/rc.conf</filename>:</para>
1463
1463
1464
	    <programlisting>wlans_ath0="wlan0"
1464
	    <programlisting>wlans_ath0="wlan0"
1465
ifconfig_wlan0="WPA DHCP"</programlisting>
1465
ifconfig_wlan0="WPA DHCP"</programlisting>
1466
1466
1467
	    <para>The next step is to bring up the interface:</para>
1467
	    <para>The next step is to bring up the interface:</para>
1468
1468
1469
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1469
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1470
Starting wpa_supplicant.
1470
Starting wpa_supplicant.
1471
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
1471
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
1472
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
1472
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
1473
DHCPACK from 192.168.0.20
1473
DHCPACK from 192.168.0.20
1474
bound to 192.168.0.254 -- renewal in 300 seconds.
1474
bound to 192.168.0.254 -- renewal in 300 seconds.
1475
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1475
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1476
      ether 00:11:95:d5:43:62
1476
      ether 00:11:95:d5:43:62
1477
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1477
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1478
      media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
1478
      media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
1479
      status: associated
1479
      status: associated
1480
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1480
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1481
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1481
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1482
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1482
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1483
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1483
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1484
      wme burst roaming MANUAL</screen>
1484
      wme burst roaming MANUAL</screen>
1485
1485
1486
	    <para>It is also possible to bring up the interface
1486
	    <para>It is also possible to bring up the interface
1487
	      manually using &man.wpa.supplicant.8; and
1487
	      manually using &man.wpa.supplicant.8; and
1488
	      &man.ifconfig.8;.</para>
1488
	      &man.ifconfig.8;.</para>
1489
	  </sect5>
1489
	  </sect5>
1490
1490
1491
	  <sect5 xml:id="network-wireless-wpa-eap-ttls">
1491
	  <sect5 xml:id="network-wireless-wpa-eap-ttls">
1492
	    <title><acronym>WPA</acronym> with
1492
	    <title><acronym>WPA</acronym> with
1493
	      <acronym>EAP-TTLS</acronym></title>
1493
	      <acronym>EAP-TTLS</acronym></title>
1494
1494
1495
	    <para>With <acronym>EAP-TLS</acronym>, both the
1495
	    <para>With <acronym>EAP-TLS</acronym>, both the
1496
	      authentication server and the client need a certificate.
1496
	      authentication server and the client need a certificate.
1497
	      With <acronym>EAP-TTLS</acronym>, a client certificate
1497
	      With <acronym>EAP-TTLS</acronym>, a client certificate
1498
	      is optional.  This method is similar to a web server
1498
	      is optional.  This method is similar to a web server
1499
	      which creates a secure <acronym>SSL</acronym> tunnel
1499
	      which creates a secure <acronym>SSL</acronym> tunnel
1500
	      even if visitors do not have client-side certificates.
1500
	      even if visitors do not have client-side certificates.
1501
	      <acronym>EAP-TTLS</acronym> uses an encrypted
1501
	      <acronym>EAP-TTLS</acronym> uses an encrypted
1502
	      <acronym>TLS</acronym> tunnel for safe transport of
1502
	      <acronym>TLS</acronym> tunnel for safe transport of
1503
	      the authentication data.</para>
1503
	      the authentication data.</para>
1504
1504
1505
	    <para>The required configuration can be added to
1505
	    <para>The required configuration can be added to
1506
	      <filename>/etc/wpa_supplicant.conf</filename>:</para>
1506
	      <filename>/etc/wpa_supplicant.conf</filename>:</para>
1507
1507
1508
	    <programlisting>network={
1508
	    <programlisting>network={
1509
  ssid="freebsdap"
1509
  ssid="freebsdap"
1510
  proto=RSN
1510
  proto=RSN
1511
  key_mgmt=WPA-EAP
1511
  key_mgmt=WPA-EAP
1512
  eap=TTLS <co xml:id="co-ttls-eap"/>
1512
  eap=TTLS <co xml:id="co-ttls-eap"/>
1513
  identity="test" <co xml:id="co-ttls-id"/>
1513
  identity="test" <co xml:id="co-ttls-id"/>
1514
  password="test" <co xml:id="co-ttls-passwd"/>
1514
  password="test" <co xml:id="co-ttls-passwd"/>
1515
  ca_cert="/etc/certs/cacert.pem" <co xml:id="co-ttls-cacert"/>
1515
  ca_cert="/etc/certs/cacert.pem" <co xml:id="co-ttls-cacert"/>
1516
  phase2="auth=MD5" <co xml:id="co-ttls-pha2"/>
1516
  phase2="auth=MD5" <co xml:id="co-ttls-pha2"/>
1517
}</programlisting>
1517
}</programlisting>
1518
1518
1519
	    <calloutlist>
1519
	    <calloutlist>
1520
	      <callout arearefs="co-ttls-eap">
1520
	      <callout arearefs="co-ttls-eap">
1521
		<para>This field specifies the <acronym>EAP</acronym>
1521
		<para>This field specifies the <acronym>EAP</acronym>
1522
		  method for the connection.</para>
1522
		  method for the connection.</para>
1523
	      </callout>
1523
	      </callout>
1524
1524
1525
	      <callout arearefs="co-ttls-id">
1525
	      <callout arearefs="co-ttls-id">
1526
		<para>The <literal>identity</literal> field contains
1526
		<para>The <literal>identity</literal> field contains
1527
		  the identity string for <acronym>EAP</acronym>
1527
		  the identity string for <acronym>EAP</acronym>
1528
		  authentication inside the encrypted
1528
		  authentication inside the encrypted
1529
		  <acronym>TLS</acronym> tunnel.</para>
1529
		  <acronym>TLS</acronym> tunnel.</para>
1530
	      </callout>
1530
	      </callout>
1531
1531
1532
	      <callout arearefs="co-ttls-passwd">
1532
	      <callout arearefs="co-ttls-passwd">
1533
		<para>The <literal>password</literal> field contains
1533
		<para>The <literal>password</literal> field contains
1534
		  the passphrase for the <acronym>EAP</acronym>
1534
		  the passphrase for the <acronym>EAP</acronym>
1535
		  authentication.</para>
1535
		  authentication.</para>
1536
	      </callout>
1536
	      </callout>
1537
1537
1538
	      <callout arearefs="co-ttls-cacert">
1538
	      <callout arearefs="co-ttls-cacert">
1539
		<para>The <literal>ca_cert</literal> field indicates
1539
		<para>The <literal>ca_cert</literal> field indicates
1540
		  the pathname of the <acronym>CA</acronym>
1540
		  the pathname of the <acronym>CA</acronym>
1541
		  certificate file.  This file is needed to verify
1541
		  certificate file.  This file is needed to verify
1542
		  the server certificate.</para>
1542
		  the server certificate.</para>
1543
	      </callout>
1543
	      </callout>
1544
1544
1545
	      <callout arearefs="co-ttls-pha2">
1545
	      <callout arearefs="co-ttls-pha2">
1546
		<para>This field specifies the authentication
1546
		<para>This field specifies the authentication
1547
		  method used in the encrypted <acronym>TLS</acronym>
1547
		  method used in the encrypted <acronym>TLS</acronym>
1548
		  tunnel.  In this example,
1548
		  tunnel.  In this example,
1549
		  <acronym>EAP</acronym> with MD5-Challenge is used.
1549
		  <acronym>EAP</acronym> with MD5-Challenge is used.
1550
		  The <quote>inner authentication</quote> phase is
1550
		  The <quote>inner authentication</quote> phase is
1551
		  often called <quote>phase2</quote>.</para>
1551
		  often called <quote>phase2</quote>.</para>
1552
	      </callout>
1552
	      </callout>
1553
	    </calloutlist>
1553
	    </calloutlist>
1554
1554
1555
	    <para>Next, add the following lines to
1555
	    <para>Next, add the following lines to
1556
	      <filename>/etc/rc.conf</filename>:</para>
1556
	      <filename>/etc/rc.conf</filename>:</para>
1557
1557
1558
	    <programlisting>wlans_ath0="wlan0"
1558
	    <programlisting>wlans_ath0="wlan0"
1559
ifconfig_wlan0="WPA DHCP"</programlisting>
1559
ifconfig_wlan0="WPA DHCP"</programlisting>
1560
1560
1561
	    <para>The next step is to bring up the interface:</para>
1561
	    <para>The next step is to bring up the interface:</para>
1562
1562
1563
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1563
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1564
Starting wpa_supplicant.
1564
Starting wpa_supplicant.
1565
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
1565
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
1566
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
1566
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
1567
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
1567
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
1568
DHCPACK from 192.168.0.20
1568
DHCPACK from 192.168.0.20
1569
bound to 192.168.0.254 -- renewal in 300 seconds.
1569
bound to 192.168.0.254 -- renewal in 300 seconds.
1570
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1570
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1571
      ether 00:11:95:d5:43:62
1571
      ether 00:11:95:d5:43:62
1572
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1572
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1573
      media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
1573
      media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
1574
      status: associated
1574
      status: associated
1575
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1575
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1576
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1576
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1577
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1577
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1578
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1578
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1579
      wme burst roaming MANUAL</screen>
1579
      wme burst roaming MANUAL</screen>
1580
	  </sect5>
1580
	  </sect5>
1581
1581
1582
	  <sect5 xml:id="network-wireless-wpa-eap-peap">
1582
	  <sect5 xml:id="network-wireless-wpa-eap-peap">
1583
	    <title><acronym>WPA</acronym> with
1583
	    <title><acronym>WPA</acronym> with
1584
	      <acronym>EAP-PEAP</acronym></title>
1584
	      <acronym>EAP-PEAP</acronym></title>
1585
1585
1586
	    <note>
1586
	    <note>
1587
	      <para><acronym>PEAPv0/EAP-MSCHAPv2</acronym> is the most
1587
	      <para><acronym>PEAPv0/EAP-MSCHAPv2</acronym> is the most
1588
		common <acronym>PEAP</acronym> method.  In this
1588
		common <acronym>PEAP</acronym> method.  In this
1589
		chapter, the term <acronym>PEAP</acronym> is used to
1589
		chapter, the term <acronym>PEAP</acronym> is used to
1590
		refer to that method.</para>
1590
		refer to that method.</para>
1591
	    </note>
1591
	    </note>
1592
1592
1593
	    <para>Protected EAP (<acronym>PEAP</acronym>) is designed
1593
	    <para>Protected EAP (<acronym>PEAP</acronym>) is designed
1594
	      as an alternative to <acronym>EAP-TTLS</acronym> and
1594
	      as an alternative to <acronym>EAP-TTLS</acronym> and
1595
	      is the most used <acronym>EAP</acronym> standard after
1595
	      is the most used <acronym>EAP</acronym> standard after
1596
	      <acronym>EAP-TLS</acronym>.  In a network with mixed
1596
	      <acronym>EAP-TLS</acronym>.  In a network with mixed
1597
	      operating systems, <acronym>PEAP</acronym> should be
1597
	      operating systems, <acronym>PEAP</acronym> should be
1598
	      the most supported standard after
1598
	      the most supported standard after
1599
	      <acronym>EAP-TLS</acronym>.</para>
1599
	      <acronym>EAP-TLS</acronym>.</para>
1600
1600
1601
	    <para><acronym>PEAP</acronym> is similar to
1601
	    <para><acronym>PEAP</acronym> is similar to
1602
	      <acronym>EAP-TTLS</acronym> as it uses a server-side
1602
	      <acronym>EAP-TTLS</acronym> as it uses a server-side
1603
	      certificate to authenticate clients by creating an
1603
	      certificate to authenticate clients by creating an
1604
	      encrypted <acronym>TLS</acronym> tunnel between the
1604
	      encrypted <acronym>TLS</acronym> tunnel between the
1605
	      client and the authentication server, which protects
1605
	      client and the authentication server, which protects
1606
	      the ensuing exchange of authentication information.
1606
	      the ensuing exchange of authentication information.
1607
	      <acronym>PEAP</acronym> authentication differs from
1607
	      <acronym>PEAP</acronym> authentication differs from
1608
	      <acronym>EAP-TTLS</acronym> as it broadcasts the
1608
	      <acronym>EAP-TTLS</acronym> as it broadcasts the
1609
	      username in the clear and only the password is sent
1609
	      username in the clear and only the password is sent
1610
	      in the encrypted <acronym>TLS</acronym> tunnel.
1610
	      in the encrypted <acronym>TLS</acronym> tunnel.
1611
	      <acronym>EAP-TTLS</acronym> will use the
1611
	      <acronym>EAP-TTLS</acronym> will use the
1612
	      <acronym>TLS</acronym> tunnel for both the username
1612
	      <acronym>TLS</acronym> tunnel for both the username
1613
	      and password.</para>
1613
	      and password.</para>
1614
1614
1615
	    <para>Add the following lines to
1615
	    <para>Add the following lines to
1616
	      <filename>/etc/wpa_supplicant.conf</filename> to
1616
	      <filename>/etc/wpa_supplicant.conf</filename> to
1617
	      configure the <acronym>EAP-PEAP</acronym> related
1617
	      configure the <acronym>EAP-PEAP</acronym> related
1618
	      settings:</para>
1618
	      settings:</para>
1619
1619
1620
	    <programlisting>network={
1620
	    <programlisting>network={
1621
  ssid="freebsdap"
1621
  ssid="freebsdap"
1622
  proto=RSN
1622
  proto=RSN
1623
  key_mgmt=WPA-EAP
1623
  key_mgmt=WPA-EAP
1624
  eap=PEAP <co xml:id="co-peap-eap"/>
1624
  eap=PEAP <co xml:id="co-peap-eap"/>
1625
  identity="test" <co xml:id="co-peap-id"/>
1625
  identity="test" <co xml:id="co-peap-id"/>
1626
  password="test" <co xml:id="co-peap-passwd"/>
1626
  password="test" <co xml:id="co-peap-passwd"/>
1627
  ca_cert="/etc/certs/cacert.pem" <co xml:id="co-peap-cacert"/>
1627
  ca_cert="/etc/certs/cacert.pem" <co xml:id="co-peap-cacert"/>
1628
  phase1="peaplabel=0" <co xml:id="co-peap-pha1"/>
1628
  phase1="peaplabel=0" <co xml:id="co-peap-pha1"/>
1629
  phase2="auth=MSCHAPV2" <co xml:id="co-peap-pha2"/>
1629
  phase2="auth=MSCHAPV2" <co xml:id="co-peap-pha2"/>
1630
}</programlisting>
1630
}</programlisting>
1631
1631
1632
	    <calloutlist>
1632
	    <calloutlist>
1633
	      <callout arearefs="co-peap-eap">
1633
	      <callout arearefs="co-peap-eap">
1634
		<para>This field specifies the <acronym>EAP</acronym>
1634
		<para>This field specifies the <acronym>EAP</acronym>
1635
		  method for the connection.</para>
1635
		  method for the connection.</para>
1636
	      </callout>
1636
	      </callout>
1637
1637
1638
	      <callout arearefs="co-peap-id">
1638
	      <callout arearefs="co-peap-id">
1639
		<para>The <literal>identity</literal> field contains
1639
		<para>The <literal>identity</literal> field contains
1640
		  the identity string for <acronym>EAP</acronym>
1640
		  the identity string for <acronym>EAP</acronym>
1641
		  authentication inside the encrypted
1641
		  authentication inside the encrypted
1642
		  <acronym>TLS</acronym> tunnel.</para>
1642
		  <acronym>TLS</acronym> tunnel.</para>
1643
	      </callout>
1643
	      </callout>
1644
1644
1645
	      <callout arearefs="co-peap-passwd">
1645
	      <callout arearefs="co-peap-passwd">
1646
		<para>The <literal>password</literal> field contains
1646
		<para>The <literal>password</literal> field contains
1647
		  the passphrase for the <acronym>EAP</acronym>
1647
		  the passphrase for the <acronym>EAP</acronym>
1648
		  authentication.</para>
1648
		  authentication.</para>
1649
	      </callout>
1649
	      </callout>
1650
1650
1651
	      <callout arearefs="co-peap-cacert">
1651
	      <callout arearefs="co-peap-cacert">
1652
		<para>The <literal>ca_cert</literal> field indicates
1652
		<para>The <literal>ca_cert</literal> field indicates
1653
		  the pathname of the <acronym>CA</acronym>
1653
		  the pathname of the <acronym>CA</acronym>
1654
		  certificate file.  This file is needed to verify
1654
		  certificate file.  This file is needed to verify
1655
		  the server certificate.</para>
1655
		  the server certificate.</para>
1656
	      </callout>
1656
	      </callout>
1657
1657
1658
	      <callout arearefs="co-peap-pha1">
1658
	      <callout arearefs="co-peap-pha1">
1659
		<para>This field contains the parameters for the
1659
		<para>This field contains the parameters for the
1660
		  first phase of authentication, the
1660
		  first phase of authentication, the
1661
		  <acronym>TLS</acronym> tunnel.  According to the
1661
		  <acronym>TLS</acronym> tunnel.  According to the
1662
		  authentication server used, specify a specific
1662
		  authentication server used, specify a specific
1663
		  label for authentication.  Most of the time, the
1663
		  label for authentication.  Most of the time, the
1664
		  label will be <quote>client <acronym>EAP</acronym>
1664
		  label will be <quote>client <acronym>EAP</acronym>
1665
		    encryption</quote> which is set by using
1665
		    encryption</quote> which is set by using
1666
		  <literal>peaplabel=0</literal>.  More information
1666
		  <literal>peaplabel=0</literal>.  More information
1667
		  can be found in  &man.wpa.supplicant.conf.5;.</para>
1667
		  can be found in  &man.wpa.supplicant.conf.5;.</para>
1668
	      </callout>
1668
	      </callout>
1669
1669
1670
	      <callout arearefs="co-peap-pha2">
1670
	      <callout arearefs="co-peap-pha2">
1671
		<para>This field specifies the authentication
1671
		<para>This field specifies the authentication
1672
		  protocol used in the encrypted
1672
		  protocol used in the encrypted
1673
		  <acronym>TLS</acronym> tunnel.  In the
1673
		  <acronym>TLS</acronym> tunnel.  In the
1674
		  case of <acronym>PEAP</acronym>, it is
1674
		  case of <acronym>PEAP</acronym>, it is
1675
		  <literal>auth=MSCHAPV2</literal>.</para>
1675
		  <literal>auth=MSCHAPV2</literal>.</para>
1676
	      </callout>
1676
	      </callout>
1677
	    </calloutlist>
1677
	    </calloutlist>
1678
1678
1679
	    <para>Add the following to
1679
	    <para>Add the following to
1680
	      <filename>/etc/rc.conf</filename>:</para>
1680
	      <filename>/etc/rc.conf</filename>:</para>
1681
1681
1682
	    <programlisting>wlans_ath0="wlan0"
1682
	    <programlisting>wlans_ath0="wlan0"
1683
ifconfig_wlan0="WPA DHCP"</programlisting>
1683
ifconfig_wlan0="WPA DHCP"</programlisting>
1684
1684
1685
	    <para>Then, bring up the interface:</para>
1685
	    <para>Then, bring up the interface:</para>
1686
1686
1687
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1687
	    <screen>&prompt.root; <userinput>service netif start</userinput>
1688
Starting wpa_supplicant.
1688
Starting wpa_supplicant.
1689
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
1689
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 7
1690
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
1690
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 15
1691
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
1691
DHCPREQUEST on wlan0 to 255.255.255.255 port 67 interval 21
1692
DHCPACK from 192.168.0.20
1692
DHCPACK from 192.168.0.20
1693
bound to 192.168.0.254 -- renewal in 300 seconds.
1693
bound to 192.168.0.254 -- renewal in 300 seconds.
1694
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1694
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
1695
      ether 00:11:95:d5:43:62
1695
      ether 00:11:95:d5:43:62
1696
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1696
      inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
1697
      media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
1697
      media: IEEE 802.11 Wireless Ethernet DS/11Mbps mode 11g
1698
      status: associated
1698
      status: associated
1699
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1699
      ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1700
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1700
      country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
1701
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1701
      AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
1702
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1702
      bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
1703
      wme burst roaming MANUAL</screen>
1703
      wme burst roaming MANUAL</screen>
1704
	  </sect5>
1704
	  </sect5>
1705
	</sect4>
1705
	</sect4>
1706
1706
1707
	<sect4 xml:id="network-wireless-wep">
1707
	<sect4 xml:id="network-wireless-wep">
1708
	  <title><acronym>WEP</acronym></title>
1708
	  <title><acronym>WEP</acronym></title>
1709
1709
1710
	  <para>Wired Equivalent Privacy (<acronym>WEP</acronym>) is
1710
	  <para>Wired Equivalent Privacy (<acronym>WEP</acronym>) is
1711
	    part of the original 802.11 standard.  There is no
1711
	    part of the original 802.11 standard.  There is no
1712
	    authentication mechanism, only a weak form of access
1712
	    authentication mechanism, only a weak form of access
1713
	    control which is easily cracked.</para>
1713
	    control which is easily cracked.</para>
1714
1714
1715
	  <para><acronym>WEP</acronym> can be set up using
1715
	  <para><acronym>WEP</acronym> can be set up using
1716
	    &man.ifconfig.8;:</para>
1716
	    &man.ifconfig.8;:</para>
1717
1717
1718
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
1718
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
1719
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable> \
1719
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.1.100</replaceable> netmask <replaceable>255.255.255.0</replaceable> \
1720
	    ssid <replaceable>my_net</replaceable> wepmode on weptxkey <replaceable>3</replaceable> wepkey <replaceable>3:0x3456789012</replaceable></userinput></screen>
1720
	    ssid <replaceable>my_net</replaceable> wepmode on weptxkey <replaceable>3</replaceable> wepkey <replaceable>3:0x3456789012</replaceable></userinput></screen>
1721
1721
1722
	  <itemizedlist>
1722
	  <itemizedlist>
1723
	    <listitem>
1723
	    <listitem>
1724
1724
1725
	      <para>The <literal>weptxkey</literal> specifies which
1725
	      <para>The <literal>weptxkey</literal> specifies which
1726
		<acronym>WEP</acronym> key will be used in the
1726
		<acronym>WEP</acronym> key will be used in the
1727
		transmission.  This example uses the third key.
1727
		transmission.  This example uses the third key.
1728
		This must match the setting on the access point.
1728
		This must match the setting on the access point.
1729
		When unsure which key is used by the access point,
1729
		When unsure which key is used by the access point,
1730
		try <literal>1</literal> (the first key) for this
1730
		try <literal>1</literal> (the first key) for this
1731
		value.</para>
1731
		value.</para>
1732
	    </listitem>
1732
	    </listitem>
1733
1733
1734
	    <listitem>
1734
	    <listitem>
1735
	      <para>The <literal>wepkey</literal> selects one of the
1735
	      <para>The <literal>wepkey</literal> selects one of the
1736
		<acronym>WEP</acronym> keys.  It should be in the
1736
		<acronym>WEP</acronym> keys.  It should be in the
1737
		format <replaceable>index:key</replaceable>.  Key
1737
		format <replaceable>index:key</replaceable>.  Key
1738
		<literal>1</literal> is used by default; the index
1738
		<literal>1</literal> is used by default; the index
1739
		only needs to be set when using a key other than the
1739
		only needs to be set when using a key other than the
1740
		first key.</para>
1740
		first key.</para>
1741
1741
1742
	      <note>
1742
	      <note>
1743
		<para>Replace the <literal>0x3456789012</literal>
1743
		<para>Replace the <literal>0x3456789012</literal>
1744
		  with the key configured for use on the access
1744
		  with the key configured for use on the access
1745
		  point.</para>
1745
		  point.</para>
1746
	      </note>
1746
	      </note>
1747
	    </listitem>
1747
	    </listitem>
1748
	  </itemizedlist>
1748
	  </itemizedlist>
1749
1749
1750
	  <para>Refer to &man.ifconfig.8; for further
1750
	  <para>Refer to &man.ifconfig.8; for further
1751
	    information.</para>
1751
	    information.</para>
1752
1752
1753
	  <para>The &man.wpa.supplicant.8; facility can be used to
1753
	  <para>The &man.wpa.supplicant.8; facility can be used to
1754
	    configure a wireless interface with
1754
	    configure a wireless interface with
1755
	    <acronym>WEP</acronym>.  The example above can be set up
1755
	    <acronym>WEP</acronym>.  The example above can be set up
1756
	    by adding the following lines to
1756
	    by adding the following lines to
1757
	    <filename>/etc/wpa_supplicant.conf</filename>:</para>
1757
	    <filename>/etc/wpa_supplicant.conf</filename>:</para>
1758
1758
1759
	  <programlisting>network={
1759
	  <programlisting>network={
1760
  ssid="my_net"
1760
  ssid="my_net"
1761
  key_mgmt=NONE
1761
  key_mgmt=NONE
1762
  wep_key3=3456789012
1762
  wep_key3=3456789012
1763
  wep_tx_keyidx=3
1763
  wep_tx_keyidx=3
1764
}</programlisting>
1764
}</programlisting>
1765
1765
1766
	  <para>Then:</para>
1766
	  <para>Then:</para>
1767
1767
1768
	  <screen>&prompt.root; <userinput>wpa_supplicant -i <replaceable>wlan0</replaceable> -c /etc/wpa_supplicant.conf</userinput>
1768
	  <screen>&prompt.root; <userinput>wpa_supplicant -i <replaceable>wlan0</replaceable> -c /etc/wpa_supplicant.conf</userinput>
1769
Trying to associate with 00:13:46:49:41:76 (SSID='dlinkap' freq=2437 MHz)
1769
Trying to associate with 00:13:46:49:41:76 (SSID='dlinkap' freq=2437 MHz)
1770
Associated with 00:13:46:49:41:76</screen>
1770
Associated with 00:13:46:49:41:76</screen>
1771
	</sect4>
1771
	</sect4>
1772
      </sect3>
1772
      </sect3>
1773
    </sect2>
1773
    </sect2>
1774
1774
1775
    <sect2>
1775
    <sect2>
1776
      <title>Ad-hoc Mode</title>
1776
      <title>Ad-hoc Mode</title>
1777
1777
1778
      <para><acronym>IBSS</acronym> mode, also called ad-hoc mode, is
1778
      <para><acronym>IBSS</acronym> mode, also called ad-hoc mode, is
1779
	designed for point to point connections.  For example, to
1779
	designed for point to point connections.  For example, to
1780
	establish an ad-hoc network between the machines
1780
	establish an ad-hoc network between the machines
1781
	<systemitem>A</systemitem> and <systemitem>B</systemitem>,
1781
	<systemitem>A</systemitem> and <systemitem>B</systemitem>,
1782
	choose two <acronym>IP</acronym> addresses and a
1782
	choose two <acronym>IP</acronym> addresses and a
1783
	<acronym>SSID</acronym>.</para>
1783
	<acronym>SSID</acronym>.</para>
1784
1784
1785
      <para>On <systemitem>A</systemitem>:</para>
1785
      <para>On <systemitem>A</systemitem>:</para>
1786
1786
1787
      <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode adhoc</userinput>
1787
      <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode adhoc</userinput>
1788
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable></userinput>
1788
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable></userinput>
1789
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1789
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1790
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1790
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1791
	  ether 00:11:95:c3:0d:ac
1791
	  ether 00:11:95:c3:0d:ac
1792
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
1792
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
1793
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;adhoc&gt;
1793
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;adhoc&gt;
1794
	  status: running
1794
	  status: running
1795
	  ssid freebsdap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
1795
	  ssid freebsdap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
1796
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
1796
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
1797
	  protmode CTS wme burst</screen>
1797
	  protmode CTS wme burst</screen>
1798
1798
1799
      <para>The <literal>adhoc</literal> parameter indicates that the
1799
      <para>The <literal>adhoc</literal> parameter indicates that the
1800
	interface is running in <acronym>IBSS</acronym> mode.</para>
1800
	interface is running in <acronym>IBSS</acronym> mode.</para>
1801
1801
1802
      <para><systemitem>B</systemitem> should now be able to detect
1802
      <para><systemitem>B</systemitem> should now be able to detect
1803
	<systemitem>A</systemitem>:</para>
1803
	<systemitem>A</systemitem>:</para>
1804
1804
1805
      <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode adhoc</userinput>
1805
      <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode adhoc</userinput>
1806
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
1806
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
1807
  SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
1807
  SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
1808
  freebsdap       02:11:95:c3:0d:ac    2   54M -64:-96  100 IS   WME</screen>
1808
  freebsdap       02:11:95:c3:0d:ac    2   54M -64:-96  100 IS   WME</screen>
1809
1809
1810
      <para>The <literal>I</literal> in the output confirms that
1810
      <para>The <literal>I</literal> in the output confirms that
1811
	<systemitem>A</systemitem> is in ad-hoc mode.  Now, configure
1811
	<systemitem>A</systemitem> is in ad-hoc mode.  Now, configure
1812
	<systemitem>B</systemitem> with a different
1812
	<systemitem>B</systemitem> with a different
1813
	<acronym>IP</acronym> address:</para>
1813
	<acronym>IP</acronym> address:</para>
1814
1814
1815
      <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable></userinput>
1815
      <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable></userinput>
1816
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1816
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1817
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1817
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1818
	  ether 00:11:95:d5:43:62
1818
	  ether 00:11:95:d5:43:62
1819
	  inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
1819
	  inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
1820
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;adhoc&gt;
1820
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;adhoc&gt;
1821
	  status: running
1821
	  status: running
1822
	  ssid freebsdap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
1822
	  ssid freebsdap channel 2 (2417 Mhz 11g) bssid 02:11:95:c3:0d:ac
1823
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
1823
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
1824
	  protmode CTS wme burst</screen>
1824
	  protmode CTS wme burst</screen>
1825
1825
1826
      <para>Both <systemitem>A</systemitem> and
1826
      <para>Both <systemitem>A</systemitem> and
1827
	<systemitem>B</systemitem> are now ready to exchange
1827
	<systemitem>B</systemitem> are now ready to exchange
1828
	information.</para>
1828
	information.</para>
1829
    </sect2>
1829
    </sect2>
1830
1830
1831
    <sect2 xml:id="network-wireless-ap">
1831
    <sect2 xml:id="network-wireless-ap">
1832
      <title>&os; Host Access Points</title>
1832
      <title>&os; Host Access Points</title>
1833
1833
1834
      <para>&os; can act as an Access Point (<acronym>AP</acronym>)
1834
      <para>&os; can act as an Access Point (<acronym>AP</acronym>)
1835
	which eliminates the need to buy a hardware
1835
	which eliminates the need to buy a hardware
1836
	<acronym>AP</acronym> or run an ad-hoc network.  This can
1836
	<acronym>AP</acronym> or run an ad-hoc network.  This can
1837
	be particularly useful when a &os; machine is acting as a
1837
	be particularly useful when a &os; machine is acting as a
1838
	gateway to another network such as the Internet.</para>
1838
	gateway to another network such as the Internet.</para>
1839
1839
1840
      <sect3 xml:id="network-wireless-ap-basic">
1840
      <sect3 xml:id="network-wireless-ap-basic">
1841
	<title>Basic Settings</title>
1841
	<title>Basic Settings</title>
1842
1842
1843
	<para>Before configuring a &os; machine as an
1843
	<para>Before configuring a &os; machine as an
1844
	  <acronym>AP</acronym>, the kernel must be configured with
1844
	  <acronym>AP</acronym>, the kernel must be configured with
1845
	  the appropriate networking support for the wireless card
1845
	  the appropriate networking support for the wireless card
1846
	  as well as the security protocols being used.  For more
1846
	  as well as the security protocols being used.  For more
1847
	  details, see <xref
1847
	  details, see <xref
1848
	    linkend="network-wireless-basic"/>.</para>
1848
	    linkend="network-wireless-basic"/>.</para>
1849
1849
1850
	<note>
1850
	<note>
1851
	  <para>The <acronym>NDIS</acronym> driver wrapper for
1851
	  <para>The <acronym>NDIS</acronym> driver wrapper for
1852
	    &windows; drivers does not currently support
1852
	    &windows; drivers does not currently support
1853
	    <acronym>AP</acronym> operation.  Only native &os;
1853
	    <acronym>AP</acronym> operation.  Only native &os;
1854
	    wireless drivers support <acronym>AP</acronym>
1854
	    wireless drivers support <acronym>AP</acronym>
1855
	    mode.</para>
1855
	    mode.</para>
1856
	</note>
1856
	</note>
1857
1857
1858
	<para>Once wireless networking support is loaded, check if
1858
	<para>Once wireless networking support is loaded, check if
1859
	  the wireless device supports the host-based access point
1859
	  the wireless device supports the host-based access point
1860
	  mode, also known as hostap mode:</para>
1860
	  mode, also known as hostap mode:</para>
1861
1861
1862
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
1862
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
1863
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> list caps</userinput>
1863
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> list caps</userinput>
1864
drivercaps=6f85edc1&lt;STA,FF,TURBOP,IBSS,HOSTAP,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,BURST,WME,WDS,BGSCAN,TXFRAG&gt;
1864
drivercaps=6f85edc1&lt;STA,FF,TURBOP,IBSS,HOSTAP,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,BURST,WME,WDS,BGSCAN,TXFRAG&gt;
1865
cryptocaps=1f&lt;WEP,TKIP,AES,AES_CCM,TKIPMIC&gt;</screen>
1865
cryptocaps=1f&lt;WEP,TKIP,AES,AES_CCM,TKIPMIC&gt;</screen>
1866
1866
1867
	<para>This output displays the card's capabilities.  The
1867
	<para>This output displays the card's capabilities.  The
1868
	  <literal>HOSTAP</literal> word confirms that this wireless
1868
	  <literal>HOSTAP</literal> word confirms that this wireless
1869
	  card can act as an <acronym>AP</acronym>.  Various supported
1869
	  card can act as an <acronym>AP</acronym>.  Various supported
1870
	  ciphers are also listed: <acronym>WEP</acronym>,
1870
	  ciphers are also listed: <acronym>WEP</acronym>,
1871
	  <acronym>TKIP</acronym>, and <acronym>AES</acronym>.  This
1871
	  <acronym>TKIP</acronym>, and <acronym>AES</acronym>.  This
1872
	  information indicates which security protocols can be used
1872
	  information indicates which security protocols can be used
1873
	  on the <acronym>AP</acronym>.</para>
1873
	  on the <acronym>AP</acronym>.</para>
1874
1874
1875
	<para>The wireless device can only be put into hostap mode
1875
	<para>The wireless device can only be put into hostap mode
1876
	  during the creation of the network pseudo-device, so a
1876
	  during the creation of the network pseudo-device, so a
1877
	  previously created device must be destroyed first:</para>
1877
	  previously created device must be destroyed first:</para>
1878
1878
1879
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> destroy</userinput></screen>
1879
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> destroy</userinput></screen>
1880
1880
1881
	<para>then regenerated with the correct option before setting
1881
	<para>then regenerated with the correct option before setting
1882
	  the other parameters:</para>
1882
	  the other parameters:</para>
1883
1883
1884
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode hostap</userinput>
1884
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode hostap</userinput>
1885
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable> mode 11g channel 1</userinput></screen>
1885
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable> mode 11g channel 1</userinput></screen>
1886
1886
1887
	<para>Use &man.ifconfig.8; again to see the status of the
1887
	<para>Use &man.ifconfig.8; again to see the status of the
1888
	  <filename>wlan0</filename> interface:</para>
1888
	  <filename>wlan0</filename> interface:</para>
1889
1889
1890
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1890
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1891
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1891
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1892
	  ether 00:11:95:c3:0d:ac
1892
	  ether 00:11:95:c3:0d:ac
1893
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
1893
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
1894
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;hostap&gt;
1894
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;hostap&gt;
1895
	  status: running
1895
	  status: running
1896
	  ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1896
	  ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1897
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
1897
	  country US ecm authmode OPEN privacy OFF txpower 21.5 scanvalid 60
1898
	  protmode CTS wme burst dtimperiod 1 -dfs</screen>
1898
	  protmode CTS wme burst dtimperiod 1 -dfs</screen>
1899
1899
1900
	<para>The <literal>hostap</literal> parameter indicates the
1900
	<para>The <literal>hostap</literal> parameter indicates the
1901
	  interface is running in the host-based access point
1901
	  interface is running in the host-based access point
1902
	  mode.</para>
1902
	  mode.</para>
1903
1903
1904
	<para>The interface configuration can be done automatically at
1904
	<para>The interface configuration can be done automatically at
1905
	  boot time by adding the following lines to
1905
	  boot time by adding the following lines to
1906
	  <filename>/etc/rc.conf</filename>:</para>
1906
	  <filename>/etc/rc.conf</filename>:</para>
1907
1907
1908
	<programlisting>wlans_ath0="wlan0"
1908
	<programlisting>wlans_ath0="wlan0"
1909
create_args_wlan0="wlanmode hostap"
1909
create_args_wlan0="wlanmode hostap"
1910
ifconfig_wlan0="inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable> mode 11g channel <replaceable>1</replaceable>"</programlisting>
1910
ifconfig_wlan0="inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable> mode 11g channel <replaceable>1</replaceable>"</programlisting>
1911
      </sect3>
1911
      </sect3>
1912
1912
1913
      <sect3>
1913
      <sect3>
1914
	<title>Host-based Access Point Without Authentication or
1914
	<title>Host-based Access Point Without Authentication or
1915
	  Encryption</title>
1915
	  Encryption</title>
1916
1916
1917
	<para>Although it is not recommended to run an
1917
	<para>Although it is not recommended to run an
1918
	  <acronym>AP</acronym> without any authentication or
1918
	  <acronym>AP</acronym> without any authentication or
1919
	  encryption, this is a simple way to check if the
1919
	  encryption, this is a simple way to check if the
1920
	  <acronym>AP</acronym> is working.  This configuration is
1920
	  <acronym>AP</acronym> is working.  This configuration is
1921
	  also important for debugging client issues.</para>
1921
	  also important for debugging client issues.</para>
1922
1922
1923
	<para>Once the <acronym>AP</acronym> is configured, initiate
1923
	<para>Once the <acronym>AP</acronym> is configured, initiate
1924
	  a scan from another wireless machine to find the
1924
	  a scan from another wireless machine to find the
1925
	  <acronym>AP</acronym>:</para>
1925
	  <acronym>AP</acronym>:</para>
1926
1926
1927
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
1927
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
1928
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
1928
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
1929
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
1929
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
1930
freebsdap       00:11:95:c3:0d:ac    1   54M -66:-96  100 ES   WME</screen>
1930
freebsdap       00:11:95:c3:0d:ac    1   54M -66:-96  100 ES   WME</screen>
1931
1931
1932
	<para>The client machine found the <acronym>AP</acronym> and
1932
	<para>The client machine found the <acronym>AP</acronym> and
1933
	  can be associated with it:</para>
1933
	  can be associated with it:</para>
1934
1934
1935
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable></userinput>
1935
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.2</replaceable> netmask <replaceable>255.255.255.0</replaceable> ssid <replaceable>freebsdap</replaceable></userinput>
1936
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1936
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
1937
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1937
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
1938
	  ether 00:11:95:d5:43:62
1938
	  ether 00:11:95:d5:43:62
1939
	  inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
1939
	  inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
1940
	  media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
1940
	  media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
1941
	  status: associated
1941
	  status: associated
1942
	  ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1942
	  ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
1943
	  country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
1943
	  country US ecm authmode OPEN privacy OFF txpower 21.5 bmiss 7
1944
	  scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
1944
	  scanvalid 60 bgscan bgscanintvl 300 bgscanidle 250 roam:rssi 7
1945
	  roam:rate 5 protmode CTS wme burst</screen>
1945
	  roam:rate 5 protmode CTS wme burst</screen>
1946
      </sect3>
1946
      </sect3>
1947
1947
1948
      <sect3 xml:id="network-wireless-ap-wpa">
1948
      <sect3 xml:id="network-wireless-ap-wpa">
1949
	<title><acronym>WPA2</acronym> Host-based Access Point</title>
1949
	<title><acronym>WPA2</acronym> Host-based Access Point</title>
1950
1950
1951
	<para>This section focuses on setting up a &os;
1951
	<para>This section focuses on setting up a &os;
1952
	  access point using the <acronym>WPA2</acronym>
1952
	  access point using the <acronym>WPA2</acronym>
1953
	  security protocol.  More details regarding
1953
	  security protocol.  More details regarding
1954
	  <acronym>WPA</acronym> and the configuration of
1954
	  <acronym>WPA</acronym> and the configuration of
1955
	  <acronym>WPA</acronym>-based wireless clients can be found
1955
	  <acronym>WPA</acronym>-based wireless clients can be found
1956
	  in <xref linkend="network-wireless-wpa"/>.</para>
1956
	  in <xref linkend="network-wireless-wpa"/>.</para>
1957
1957
1958
	<para>The &man.hostapd.8; daemon is used to deal with client
1958
	<para>The &man.hostapd.8; daemon is used to deal with client
1959
	  authentication and key management on the
1959
	  authentication and key management on the
1960
	  <acronym>WPA2</acronym>-enabled
1960
	  <acronym>WPA2</acronym>-enabled
1961
	  <acronym>AP</acronym>.</para>
1961
	  <acronym>AP</acronym>.</para>
1962
1962
1963
	<para>The following configuration operations are performed
1963
	<para>The following configuration operations are performed
1964
	  on the &os; machine acting as the <acronym>AP</acronym>.
1964
	  on the &os; machine acting as the <acronym>AP</acronym>.
1965
	  Once the <acronym>AP</acronym> is correctly working,
1965
	  Once the <acronym>AP</acronym> is correctly working,
1966
	  &man.hostapd.8; can be automatically started at boot
1966
	  &man.hostapd.8; can be automatically started at boot
1967
	  with this line in
1967
	  with this line in
1968
	  <filename>/etc/rc.conf</filename>:</para>
1968
	  <filename>/etc/rc.conf</filename>:</para>
1969
1969
1970
	<programlisting>hostapd_enable="YES"</programlisting>
1970
	<programlisting>hostapd_enable="YES"</programlisting>
1971
1971
1972
	<para>Before trying to configure &man.hostapd.8;, first
1972
	<para>Before trying to configure &man.hostapd.8;, first
1973
	  configure the basic settings introduced in <xref
1973
	  configure the basic settings introduced in <xref
1974
	    linkend="network-wireless-ap-basic"/>.</para>
1974
	    linkend="network-wireless-ap-basic"/>.</para>
1975
1975
1976
	<sect4>
1976
	<sect4>
1977
	  <title><acronym>WPA2-PSK</acronym></title>
1977
	  <title><acronym>WPA2-PSK</acronym></title>
1978
1978
1979
	  <para><acronym>WPA2-PSK</acronym> is intended for small
1979
	  <para><acronym>WPA2-PSK</acronym> is intended for small
1980
	    networks where the use of a backend authentication server
1980
	    networks where the use of a backend authentication server
1981
	    is not possible or desired.</para>
1981
	    is not possible or desired.</para>
1982
1982
1983
	  <para>The configuration is done in
1983
	  <para>The configuration is done in
1984
	    <filename>/etc/hostapd.conf</filename>:</para>
1984
	    <filename>/etc/hostapd.conf</filename>:</para>
1985
1985
1986
	  <programlisting>interface=wlan0                  <co xml:id="co-ap-wpapsk-iface"/>
1986
	  <programlisting>interface=wlan0                  <co xml:id="co-ap-wpapsk-iface"/>
1987
debug=1                          <co xml:id="co-ap-wpapsk-dbug"/>
1987
debug=1                          <co xml:id="co-ap-wpapsk-dbug"/>
1988
ctrl_interface=/var/run/hostapd  <co xml:id="co-ap-wpapsk-ciface"/>
1988
ctrl_interface=/var/run/hostapd  <co xml:id="co-ap-wpapsk-ciface"/>
1989
ctrl_interface_group=wheel       <co xml:id="co-ap-wpapsk-cifacegrp"/>
1989
ctrl_interface_group=wheel       <co xml:id="co-ap-wpapsk-cifacegrp"/>
1990
ssid=freebsdap                   <co xml:id="co-ap-wpapsk-ssid"/>
1990
ssid=freebsdap                   <co xml:id="co-ap-wpapsk-ssid"/>
1991
wpa=2                            <co xml:id="co-ap-wpapsk-wpa"/>
1991
wpa=2                            <co xml:id="co-ap-wpapsk-wpa"/>
1992
wpa_passphrase=freebsdmall       <co xml:id="co-ap-wpapsk-pass"/>
1992
wpa_passphrase=freebsdmall       <co xml:id="co-ap-wpapsk-pass"/>
1993
wpa_key_mgmt=WPA-PSK             <co xml:id="co-ap-wpapsk-kmgmt"/>
1993
wpa_key_mgmt=WPA-PSK             <co xml:id="co-ap-wpapsk-kmgmt"/>
1994
wpa_pairwise=CCMP                <co xml:id="co-ap-wpapsk-pwise"/></programlisting>
1994
wpa_pairwise=CCMP                <co xml:id="co-ap-wpapsk-pwise"/></programlisting>
1995
1995
1996
	  <calloutlist>
1996
	  <calloutlist>
1997
	    <callout arearefs="co-ap-wpapsk-iface">
1997
	    <callout arearefs="co-ap-wpapsk-iface">
1998
	      <para>Wireless interface used
1998
	      <para>Wireless interface used
1999
		for the access point.</para>
1999
		for the access point.</para>
2000
	    </callout>
2000
	    </callout>
2001
2001
2002
	    <callout arearefs="co-ap-wpapsk-dbug">
2002
	    <callout arearefs="co-ap-wpapsk-dbug">
2003
	      <para>Level of verbosity used during the
2003
	      <para>Level of verbosity used during the
2004
		execution of &man.hostapd.8;.  A value of
2004
		execution of &man.hostapd.8;.  A value of
2005
		<literal>1</literal> represents the minimal
2005
		<literal>1</literal> represents the minimal
2006
		level.</para>
2006
		level.</para>
2007
	    </callout>
2007
	    </callout>
2008
2008
2009
	    <callout arearefs="co-ap-wpapsk-ciface">
2009
	    <callout arearefs="co-ap-wpapsk-ciface">
2010
	      <para>Pathname of the directory used by &man.hostapd.8;
2010
	      <para>Pathname of the directory used by &man.hostapd.8;
2011
		to store domain socket files for communication
2011
		to store domain socket files for communication
2012
		with external programs such as &man.hostapd.cli.8;.
2012
		with external programs such as &man.hostapd.cli.8;.
2013
		The default value is used in this example.</para>
2013
		The default value is used in this example.</para>
2014
	    </callout>
2014
	    </callout>
2015
2015
2016
	    <callout arearefs="co-ap-wpapsk-cifacegrp">
2016
	    <callout arearefs="co-ap-wpapsk-cifacegrp">
2017
	      <para>The group allowed to access the control
2017
	      <para>The group allowed to access the control
2018
		interface files.</para>
2018
		interface files.</para>
2019
	    </callout>
2019
	    </callout>
2020
2020
2021
	    <callout arearefs="co-ap-wpapsk-ssid">
2021
	    <callout arearefs="co-ap-wpapsk-ssid">
2022
	      <para>The wireless network name, or
2022
	      <para>The wireless network name, or
2023
		<acronym>SSID</acronym>, that will appear in wireless
2023
		<acronym>SSID</acronym>, that will appear in wireless
2024
		scans.</para>
2024
		scans.</para>
2025
	    </callout>
2025
	    </callout>
2026
2026
2027
	    <callout arearefs="co-ap-wpapsk-wpa">
2027
	    <callout arearefs="co-ap-wpapsk-wpa">
2028
	      <para>Enable
2028
	      <para>Enable
2029
		<acronym>WPA</acronym> and specify which
2029
		<acronym>WPA</acronym> and specify which
2030
		<acronym>WPA</acronym> authentication protocol will
2030
		<acronym>WPA</acronym> authentication protocol will
2031
		be required.  A value of <literal>2</literal>
2031
		be required.  A value of <literal>2</literal>
2032
		configures the <acronym>AP</acronym> for
2032
		configures the <acronym>AP</acronym> for
2033
		<acronym>WPA2</acronym> and is recommended.
2033
		<acronym>WPA2</acronym> and is recommended.
2034
		Set to <literal>1</literal> only if the obsolete
2034
		Set to <literal>1</literal> only if the obsolete
2035
		<acronym>WPA</acronym> is required.</para>
2035
		<acronym>WPA</acronym> is required.</para>
2036
	    </callout>
2036
	    </callout>
2037
2037
2038
	    <callout arearefs="co-ap-wpapsk-pass">
2038
	    <callout arearefs="co-ap-wpapsk-pass">
2039
	      <para>ASCII passphrase for
2039
	      <para>ASCII passphrase for
2040
		<acronym>WPA</acronym> authentication.</para>
2040
		<acronym>WPA</acronym> authentication.</para>
2041
2041
2042
	      <warning>
2042
	      <warning>
2043
		<para>Always use strong passwords that are at least
2043
		<para>Always use strong passwords that are at least
2044
		  8 characters long and made from a rich alphabet so
2044
		  8 characters long and made from a rich alphabet so
2045
		  that they will not be easily guessed or
2045
		  that they will not be easily guessed or
2046
		  attacked.</para>
2046
		  attacked.</para>
2047
	      </warning>
2047
	      </warning>
2048
	    </callout>
2048
	    </callout>
2049
2049
2050
	    <callout arearefs="co-ap-wpapsk-kmgmt">
2050
	    <callout arearefs="co-ap-wpapsk-kmgmt">
2051
	      <para>The
2051
	      <para>The
2052
		key management protocol to use.  This example
2052
		key management protocol to use.  This example
2053
		sets <acronym>WPA-PSK</acronym>.</para>
2053
		sets <acronym>WPA-PSK</acronym>.</para>
2054
	    </callout>
2054
	    </callout>
2055
2055
2056
	    <callout arearefs="co-ap-wpapsk-pwise">
2056
	    <callout arearefs="co-ap-wpapsk-pwise">
2057
	      <para>Encryption algorithms accepted by
2057
	      <para>Encryption algorithms accepted by
2058
		the access point.  In this example, only
2058
		the access point.  In this example, only
2059
		the
2059
		the
2060
		<acronym>CCMP</acronym> (<acronym>AES</acronym>)
2060
		<acronym>CCMP</acronym> (<acronym>AES</acronym>)
2061
		cipher is accepted.  <acronym>CCMP</acronym>
2061
		cipher is accepted.  <acronym>CCMP</acronym>
2062
		is an alternative to <acronym>TKIP</acronym>
2062
		is an alternative to <acronym>TKIP</acronym>
2063
		and is strongly preferred when possible.
2063
		and is strongly preferred when possible.
2064
		<acronym>TKIP</acronym> should be allowed only when
2064
		<acronym>TKIP</acronym> should be allowed only when
2065
		there are stations incapable of using
2065
		there are stations incapable of using
2066
		<acronym>CCMP</acronym>.</para>
2066
		<acronym>CCMP</acronym>.</para>
2067
	    </callout>
2067
	    </callout>
2068
	  </calloutlist>
2068
	  </calloutlist>
2069
2069
2070
	  <para>The next step is to start &man.hostapd.8;:</para>
2070
	  <para>The next step is to start &man.hostapd.8;:</para>
2071
2071
2072
	  <screen>&prompt.root; <userinput>service hostapd forcestart</userinput></screen>
2072
	  <screen>&prompt.root; <userinput>service hostapd forcestart</userinput></screen>
2073
2073
2074
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
2074
	  <screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
2075
wlan0: flags=8943&lt;UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
2075
wlan0: flags=8943&lt;UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
2076
	ether 04:f0:21:16:8e:10
2076
	ether 04:f0:21:16:8e:10
2077
	inet6 fe80::6f0:21ff:fe16:8e10%wlan0 prefixlen 64 scopeid 0x9
2077
	inet6 fe80::6f0:21ff:fe16:8e10%wlan0 prefixlen 64 scopeid 0x9
2078
	nd6 options=21&lt;PERFORMNUD,AUTO_LINKLOCAL&gt;
2078
	nd6 options=21&lt;PERFORMNUD,AUTO_LINKLOCAL&gt;
2079
	media: IEEE 802.11 Wireless Ethernet autoselect mode 11na &lt;hostap&gt;
2079
	media: IEEE 802.11 Wireless Ethernet autoselect mode 11na &lt;hostap&gt;
2080
	status: running
2080
	status: running
2081
	ssid No5ignal channel 36 (5180 MHz 11a ht/40+) bssid 04:f0:21:16:8e:10
2081
	ssid No5ignal channel 36 (5180 MHz 11a ht/40+) bssid 04:f0:21:16:8e:10
2082
	country US ecm authmode WPA2/802.11i privacy MIXED deftxkey 2
2082
	country US ecm authmode WPA2/802.11i privacy MIXED deftxkey 2
2083
	AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 17 mcastrate 6 mgmtrate 6
2083
	AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 17 mcastrate 6 mgmtrate 6
2084
	scanvalid 60 ampdulimit 64k ampdudensity 8 shortgi wme burst
2084
	scanvalid 60 ampdulimit 64k ampdudensity 8 shortgi wme burst
2085
	dtimperiod 1 -dfs
2085
	dtimperiod 1 -dfs
2086
	groups: wlan</screen>
2086
	groups: wlan</screen>
2087
2087
2088
	  <para>Once the <acronym>AP</acronym> is running, the
2088
	  <para>Once the <acronym>AP</acronym> is running, the
2089
	    clients can associate with it.  See <xref
2089
	    clients can associate with it.  See <xref
2090
	      linkend="network-wireless-wpa"/> for more details.  It
2090
	      linkend="network-wireless-wpa"/> for more details.  It
2091
	    is possible to see the stations associated with the
2091
	    is possible to see the stations associated with the
2092
	    <acronym>AP</acronym> using <command>ifconfig
2092
	    <acronym>AP</acronym> using <command>ifconfig
2093
	      <replaceable>wlan0</replaceable> list
2093
	      <replaceable>wlan0</replaceable> list
2094
	      sta</command>.</para>
2094
	      sta</command>.</para>
2095
	</sect4>
2095
	</sect4>
2096
      </sect3>
2096
      </sect3>
2097
2097
2098
      <sect3>
2098
      <sect3>
2099
	<title><acronym>WEP</acronym> Host-based Access Point</title>
2099
	<title><acronym>WEP</acronym> Host-based Access Point</title>
2100
2100
2101
	<para>It is not recommended to use <acronym>WEP</acronym> for
2101
	<para>It is not recommended to use <acronym>WEP</acronym> for
2102
	  setting up an <acronym>AP</acronym> since there is no
2102
	  setting up an <acronym>AP</acronym> since there is no
2103
	  authentication mechanism and the encryption is easily
2103
	  authentication mechanism and the encryption is easily
2104
	  cracked.  Some legacy wireless cards only support
2104
	  cracked.  Some legacy wireless cards only support
2105
	  <acronym>WEP</acronym> and these cards will only support
2105
	  <acronym>WEP</acronym> and these cards will only support
2106
	  an <acronym>AP</acronym> without authentication or
2106
	  an <acronym>AP</acronym> without authentication or
2107
	  encryption.</para>
2107
	  encryption.</para>
2108
2108
2109
	<para>The wireless device can now be put into hostap mode and
2109
	<para>The wireless device can now be put into hostap mode and
2110
	  configured with the correct <acronym>SSID</acronym> and
2110
	  configured with the correct <acronym>SSID</acronym> and
2111
	  <acronym>IP</acronym> address:</para>
2111
	  <acronym>IP</acronym> address:</para>
2112
2112
2113
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode hostap</userinput>
2113
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable> wlanmode hostap</userinput>
2114
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> \
2114
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> inet <replaceable>192.168.0.1</replaceable> netmask <replaceable>255.255.255.0</replaceable> \
2115
	ssid <replaceable>freebsdap</replaceable> wepmode on weptxkey <replaceable>3</replaceable> wepkey <replaceable>3:0x3456789012</replaceable> mode 11g</userinput></screen>
2115
	ssid <replaceable>freebsdap</replaceable> wepmode on weptxkey <replaceable>3</replaceable> wepkey <replaceable>3:0x3456789012</replaceable> mode 11g</userinput></screen>
2116
2116
2117
	<itemizedlist>
2117
	<itemizedlist>
2118
	  <listitem>
2118
	  <listitem>
2119
	    <para>The <literal>weptxkey</literal> indicates which
2119
	    <para>The <literal>weptxkey</literal> indicates which
2120
	      <acronym>WEP</acronym> key will be used in the
2120
	      <acronym>WEP</acronym> key will be used in the
2121
	      transmission.  This example uses the third key as key
2121
	      transmission.  This example uses the third key as key
2122
	      numbering starts with <literal>1</literal>.  This
2122
	      numbering starts with <literal>1</literal>.  This
2123
	      parameter must be specified in order to encrypt the
2123
	      parameter must be specified in order to encrypt the
2124
	      data.</para>
2124
	      data.</para>
2125
	  </listitem>
2125
	  </listitem>
2126
2126
2127
	  <listitem>
2127
	  <listitem>
2128
	    <para>The <literal>wepkey</literal> sets the selected
2128
	    <para>The <literal>wepkey</literal> sets the selected
2129
	      <acronym>WEP</acronym> key.  It should be in the format
2129
	      <acronym>WEP</acronym> key.  It should be in the format
2130
	      <replaceable>index:key</replaceable>.  If the index is
2130
	      <replaceable>index:key</replaceable>.  If the index is
2131
	      not given, key <literal>1</literal> is set.  The index
2131
	      not given, key <literal>1</literal> is set.  The index
2132
	      needs to be set when using keys other than the first
2132
	      needs to be set when using keys other than the first
2133
	      key.</para>
2133
	      key.</para>
2134
	  </listitem>
2134
	  </listitem>
2135
	</itemizedlist>
2135
	</itemizedlist>
2136
2136
2137
	<para>Use &man.ifconfig.8; to see the status of the
2137
	<para>Use &man.ifconfig.8; to see the status of the
2138
	  <filename>wlan0</filename> interface:</para>
2138
	  <filename>wlan0</filename> interface:</para>
2139
2139
2140
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
2140
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable></userinput>
2141
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
2141
  wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
2142
	  ether 00:11:95:c3:0d:ac
2142
	  ether 00:11:95:c3:0d:ac
2143
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
2143
	  inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
2144
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;hostap&gt;
2144
	  media: IEEE 802.11 Wireless Ethernet autoselect mode 11g &lt;hostap&gt;
2145
	  status: running
2145
	  status: running
2146
	  ssid freebsdap channel 4 (2427 Mhz 11g) bssid 00:11:95:c3:0d:ac
2146
	  ssid freebsdap channel 4 (2427 Mhz 11g) bssid 00:11:95:c3:0d:ac
2147
	  country US ecm authmode OPEN privacy ON deftxkey 3 wepkey 3:40-bit
2147
	  country US ecm authmode OPEN privacy ON deftxkey 3 wepkey 3:40-bit
2148
	  txpower 21.5 scanvalid 60 protmode CTS wme burst dtimperiod 1 -dfs</screen>
2148
	  txpower 21.5 scanvalid 60 protmode CTS wme burst dtimperiod 1 -dfs</screen>
2149
2149
2150
	<para>From another wireless machine, it is now possible to
2150
	<para>From another wireless machine, it is now possible to
2151
	  initiate a scan to find the <acronym>AP</acronym>:</para>
2151
	  initiate a scan to find the <acronym>AP</acronym>:</para>
2152
2152
2153
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
2153
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>ath0</replaceable></userinput>
2154
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
2154
&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> up scan</userinput>
2155
SSID            BSSID              CHAN RATE  S:N   INT CAPS
2155
SSID            BSSID              CHAN RATE  S:N   INT CAPS
2156
freebsdap       00:11:95:c3:0d:ac    1   54M 22:1   100 EPS</screen>
2156
freebsdap       00:11:95:c3:0d:ac    1   54M 22:1   100 EPS</screen>
2157
2157
2158
	<para>In this example, the client machine found the
2158
	<para>In this example, the client machine found the
2159
	  <acronym>AP</acronym> and can associate with it using the
2159
	  <acronym>AP</acronym> and can associate with it using the
2160
	  correct parameters.  See <xref
2160
	  correct parameters.  See <xref
2161
	    linkend="network-wireless-wep"/> for more details.</para>
2161
	    linkend="network-wireless-wep"/> for more details.</para>
2162
      </sect3>
2162
      </sect3>
2163
    </sect2>
2163
    </sect2>
2164
2164
2165
    <sect2>
2165
    <sect2>
2166
      <title>Using Both Wired and Wireless Connections</title>
2166
      <title>Using Both Wired and Wireless Connections</title>
2167
2167
2168
      <para>A wired connection provides better performance and
2168
      <para>A wired connection provides better performance and
2169
	reliability, while a wireless connection provides flexibility
2169
	reliability, while a wireless connection provides flexibility
2170
	and mobility.  Laptop users typically want to roam seamlessly
2170
	and mobility.  Laptop users typically want to roam seamlessly
2171
	between the two types of connections.</para>
2171
	between the two types of connections.</para>
2172
2172
2173
      <para>On &os;, it is possible to combine two or even more
2173
      <para>On &os;, it is possible to combine two or even more
2174
	network interfaces together in a <quote>failover</quote>
2174
	network interfaces together in a <quote>failover</quote>
2175
	fashion.  This type of configuration uses the most preferred
2175
	fashion.  This type of configuration uses the most preferred
2176
	and available connection from a group of network interfaces,
2176
	and available connection from a group of network interfaces,
2177
	and the operating system switches automatically when the link
2177
	and the operating system switches automatically when the link
2178
	state changes.</para>
2178
	state changes.</para>
2179
2179
2180
      <para>Link aggregation and failover is covered in <xref
2180
      <para>Link aggregation and failover is covered in <xref
2181
	  linkend="network-aggregation"/> and an example for using
2181
	  linkend="network-aggregation"/> and an example for using
2182
	both wired and wireless connections is provided at <xref
2182
	both wired and wireless connections is provided at <xref
2183
	  linkend="networking-lagg-wired-and-wireless"/>.</para>
2183
	  linkend="networking-lagg-wired-and-wireless"/>.</para>
2184
    </sect2>
2184
    </sect2>
2185
2185
2186
    <sect2>
2186
    <sect2>
2187
      <title>Troubleshooting</title>
2187
      <title>Troubleshooting</title>
2188
2188
2189
      <para>This section describes
2189
      <para>This section describes
2190
	a number of steps to help troubleshoot common wireless
2190
	a number of steps to help troubleshoot common wireless
2191
	networking problems.</para>
2191
	networking problems.</para>
2192
2192
2193
      <itemizedlist>
2193
      <itemizedlist>
2194
	<listitem>
2194
	<listitem>
2195
	  <para>If the access point is not listed when scanning,
2195
	  <para>If the access point is not listed when scanning,
2196
	    check that the configuration has not limited the wireless
2196
	    check that the configuration has not limited the wireless
2197
	    device to a limited set of channels.</para>
2197
	    device to a limited set of channels.</para>
2198
	</listitem>
2198
	</listitem>
2199
2199
2200
	<listitem>
2200
	<listitem>
2201
	  <para>If the device cannot associate with an access point,
2201
	  <para>If the device cannot associate with an access point,
2202
	    verify that the configuration matches the settings on the
2202
	    verify that the configuration matches the settings on the
2203
	    access point.  This includes the authentication scheme and
2203
	    access point.  This includes the authentication scheme and
2204
	    any security protocols.  Simplify the configuration as
2204
	    any security protocols.  Simplify the configuration as
2205
	    much as possible.  If using a security protocol such as
2205
	    much as possible.  If using a security protocol such as
2206
	    <acronym>WPA</acronym> or <acronym>WEP</acronym>,
2206
	    <acronym>WPA</acronym> or <acronym>WEP</acronym>,
2207
	    configure the access point for open authentication and
2207
	    configure the access point for open authentication and
2208
	    no security to see if traffic will pass.</para>
2208
	    no security to see if traffic will pass.</para>
2209
2209
2210
	  <para>Debugging support is provided by
2210
	  <para>Debugging support is provided by
2211
	    &man.wpa.supplicant.8;.  Try running this utility manually
2211
	    &man.wpa.supplicant.8;.  Try running this utility manually
2212
	    with <option>-dd</option> and look at the
2212
	    with <option>-dd</option> and look at the
2213
	    system logs.</para>
2213
	    system logs.</para>
2214
	</listitem>
2214
	</listitem>
2215
2215
2216
	<listitem>
2216
	<listitem>
2217
	  <para>Once the system can associate with the access point,
2217
	  <para>Once the system can associate with the access point,
2218
	    diagnose the network configuration using tools like
2218
	    diagnose the network configuration using tools like
2219
	    &man.ping.8;.</para>
2219
	    &man.ping.8;.</para>
2220
	</listitem>
2220
	</listitem>
2221
2221
2222
	<listitem>
2222
	<listitem>
2223
	  <para>There are many lower-level debugging tools.
2223
	  <para>There are many lower-level debugging tools.
2224
	    Debugging messages can be enabled in the 802.11 protocol
2224
	    Debugging messages can be enabled in the 802.11 protocol
2225
	    support layer using &man.wlandebug.8;.
2225
	    support layer using &man.wlandebug.8;.
2226
	    For example, to enable console messages related to
2226
	    For example, to enable console messages related to
2227
	    scanning for access points and the 802.11 protocol
2227
	    scanning for access points and the 802.11 protocol
2228
	    handshakes required to arrange communication:</para>
2228
	    handshakes required to arrange communication:</para>
2229
2229
2230
	  <screen>&prompt.root; <userinput>wlandebug -i <replaceable>wlan0</replaceable> +scan+auth+debug+assoc</userinput>
2230
	  <screen>&prompt.root; <userinput>wlandebug -i <replaceable>wlan0</replaceable> +scan+auth+debug+assoc</userinput>
2231
  net.wlan.0.debug: 0 =&gt; 0xc80000&lt;assoc,auth,scan&gt;</screen>
2231
  net.wlan.0.debug: 0 =&gt; 0xc80000&lt;assoc,auth,scan&gt;</screen>
2232
2232
2233
	  <para>Many useful statistics are maintained by the 802.11
2233
	  <para>Many useful statistics are maintained by the 802.11
2234
	    layer and <command>wlanstats</command>, found in <filename
2234
	    layer and <command>wlanstats</command>, found in <filename
2235
	      >/usr/src/tools/tools/net80211</filename>,
2235
	      >/usr/src/tools/tools/net80211</filename>,
2236
	    will dump this information.  These statistics should
2236
	    will dump this information.  These statistics should
2237
	    display all errors identified by the 802.11 layer.
2237
	    display all errors identified by the 802.11 layer.
2238
	    However, some errors are identified in the device drivers
2238
	    However, some errors are identified in the device drivers
2239
	    that lie below the 802.11 layer so they may not show up.
2239
	    that lie below the 802.11 layer so they may not show up.
2240
	    To diagnose device-specific problems, refer to the
2240
	    To diagnose device-specific problems, refer to the
2241
	    drivers' documentation.</para>
2241
	    drivers' documentation.</para>
2242
	</listitem>
2242
	</listitem>
2243
      </itemizedlist>
2243
      </itemizedlist>
2244
2244
2245
      <para>If the above information does not help to clarify the
2245
      <para>If the above information does not help to clarify the
2246
	problem, submit a problem report and include output from the
2246
	problem, submit a problem report and include output from the
2247
	above tools.</para>
2247
	above tools.</para>
2248
    </sect2>
2248
    </sect2>
2249
  </sect1>
2249
  </sect1>
2250
2250
2251
  <sect1 xml:id="network-usb-tethering">
2251
  <sect1 xml:id="network-usb-tethering">
2252
    <info>
2252
    <info>
2253
      <title>USB Tethering</title>
2253
      <title>USB Tethering</title>
2254
    </info>
2254
    </info>
2255
2255
2256
    <indexterm>
2256
    <indexterm>
2257
      <primary>tether</primary>
2257
      <primary>tether</primary>
2258
    </indexterm>
2258
    </indexterm>
2259
2259
2260
    <para>Many cellphones provide the option to share their data
2260
    <para>Many cellphones provide the option to share their data
2261
      connection over USB (often called "tethering").  This feature
2261
      connection over USB (often called "tethering").  This feature
2262
      uses either the <acronym>RNDIS</acronym>, <acronym>CDC</acronym>
2262
      uses either the <acronym>RNDIS</acronym>, <acronym>CDC</acronym>
2263
      or a custom &apple; &iphone;/&ipad;
2263
      or a custom &apple; &iphone;/&ipad;
2264
      protocol.</para>
2264
      protocol.</para>
2265
2265
2266
    <itemizedlist>
2266
    <itemizedlist>
2267
      <listitem>
2267
      <listitem>
2268
	<para>&android; devices generally use the &man.urndis.4;
2268
	<para>&android; devices generally use the &man.urndis.4;
2269
	  driver.</para>
2269
	  driver.</para>
2270
      </listitem>
2270
      </listitem>
2271
2271
2272
      <listitem>
2272
      <listitem>
2273
	<para>&apple; devices use the &man.ipheth.4; driver.</para>
2273
	<para>&apple; devices use the &man.ipheth.4; driver.</para>
2274
      </listitem>
2274
      </listitem>
2275
2275
2276
      <listitem>
2276
      <listitem>
2277
	<para>Older devices will often use the &man.cdce.4;
2277
	<para>Older devices will often use the &man.cdce.4;
2278
	  driver.</para>
2278
	  driver.</para>
2279
      </listitem>
2279
      </listitem>
2280
    </itemizedlist>
2280
    </itemizedlist>
2281
2281
2282
    <para>Before attaching a device, load the appropriate driver
2282
    <para>Before attaching a device, load the appropriate driver
2283
      into the kernel:</para>
2283
      into the kernel:</para>
2284
2284
2285
    <screen>&prompt.root; <userinput>kldload if_urndis
2285
    <screen>&prompt.root; <userinput>kldload if_urndis
2286
&prompt.root; kldload if_cdce
2286
&prompt.root; kldload if_cdce
2287
&prompt.root; kldload if_ipheth</userinput></screen>
2287
&prompt.root; kldload if_ipheth</userinput></screen>
2288
2288
2289
    <para>Once the device is attached
2289
    <para>Once the device is attached
2290
      <literal>ue</literal><replaceable>0</replaceable> will be
2290
      <literal>ue</literal><replaceable>0</replaceable> will be
2291
      available for use like a normal network device.  Be sure that
2291
      available for use like a normal network device.  Be sure that
2292
      the <quote>USB tethering</quote> option is enabled on the
2292
      the <quote>USB tethering</quote> option is enabled on the
2293
      device.</para>
2293
      device.</para>
2294
  </sect1>
2294
  </sect1>
2295
2295
2296
  <sect1 xml:id="network-bluetooth">
2296
  <sect1 xml:id="network-bluetooth">
2297
    <info>
2297
    <info>
2298
      <title>Bluetooth</title>
2298
      <title>Bluetooth</title>
2299
2299
2300
      <authorgroup>
2300
      <authorgroup>
2301
	<author>
2301
	<author>
2302
	  <personname>
2302
	  <personname>
2303
	    <firstname>Pav</firstname>
2303
	    <firstname>Pav</firstname>
2304
	    <surname>Lucistnik</surname>
2304
	    <surname>Lucistnik</surname>
2305
	  </personname>
2305
	  </personname>
2306
	  <contrib>Written by </contrib>
2306
	  <contrib>Written by </contrib>
2307
	  <email>pav@FreeBSD.org</email>
2307
	  <email>pav@FreeBSD.org</email>
2308
	</author>
2308
	</author>
2309
      </authorgroup>
2309
      </authorgroup>
2310
    </info>
2310
    </info>
2311
2311
2312
    <indexterm>
2312
    <indexterm>
2313
      <primary>Bluetooth</primary>
2313
      <primary>Bluetooth</primary>
2314
    </indexterm>
2314
    </indexterm>
2315
2315
2316
    <para>Bluetooth is a wireless technology for creating personal
2316
    <para>Bluetooth is a wireless technology for creating personal
2317
      networks operating in the 2.4 GHz unlicensed band, with a
2317
      networks operating in the 2.4 GHz unlicensed band, with a
2318
      range of 10 meters.  Networks are usually formed ad-hoc from
2318
      range of 10 meters.  Networks are usually formed ad-hoc from
2319
      portable devices such as cellular phones, handhelds, and
2319
      portable devices such as cellular phones, handhelds, and
2320
      laptops.  Unlike Wi-Fi wireless technology, Bluetooth offers
2320
      laptops.  Unlike Wi-Fi wireless technology, Bluetooth offers
2321
      higher level service profiles, such as
2321
      higher level service profiles, such as
2322
      <acronym>FTP</acronym>-like file servers, file pushing, voice
2322
      <acronym>FTP</acronym>-like file servers, file pushing, voice
2323
      transport, serial line emulation, and more.</para>
2323
      transport, serial line emulation, and more.</para>
2324
2324
2325
    <para>This section describes the use of a <acronym>USB</acronym>
2325
    <para>This section describes the use of a <acronym>USB</acronym>
2326
      Bluetooth dongle on a &os; system.  It then describes the
2326
      Bluetooth dongle on a &os; system.  It then describes the
2327
      various Bluetooth protocols and utilities.</para>
2327
      various Bluetooth protocols and utilities.</para>
2328
2328
2329
    <sect2>
2329
    <sect2>
2330
      <title>Loading Bluetooth Support</title>
2330
      <title>Loading Bluetooth Support</title>
2331
2331
2332
      <para>The Bluetooth stack in &os; is implemented using the
2332
      <para>The Bluetooth stack in &os; is implemented using the
2333
	&man.netgraph.4; framework.  A broad variety of Bluetooth
2333
	&man.netgraph.4; framework.  A broad variety of Bluetooth
2334
	<acronym>USB</acronym> dongles is supported by &man.ng.ubt.4;.
2334
	<acronym>USB</acronym> dongles is supported by &man.ng.ubt.4;.
2335
	Broadcom BCM2033 based Bluetooth devices are supported by the
2335
	Broadcom BCM2033 based Bluetooth devices are supported by the
2336
	&man.ubtbcmfw.4; and &man.ng.ubt.4; drivers.  The 3Com
2336
	&man.ubtbcmfw.4; and &man.ng.ubt.4; drivers.  The 3Com
2337
	Bluetooth PC Card 3CRWB60-A is supported by the
2337
	Bluetooth PC Card 3CRWB60-A is supported by the
2338
	&man.ng.bt3c.4; driver.  Serial and UART based Bluetooth
2338
	&man.ng.bt3c.4; driver.  Serial and UART based Bluetooth
2339
	devices are supported by &man.sio.4;, &man.ng.h4.4;, and
2339
	devices are supported by &man.sio.4;, &man.ng.h4.4;, and
2340
	&man.hcseriald.8;.</para>
2340
	&man.hcseriald.8;.</para>
2341
2341
2342
      <para>Before attaching a device, determine which of the above
2342
      <para>Before attaching a device, determine which of the above
2343
	drivers it uses, then load the driver.  For example, if the
2343
	drivers it uses, then load the driver.  For example, if the
2344
	device uses the &man.ng.ubt.4; driver:</para>
2344
	device uses the &man.ng.ubt.4; driver:</para>
2345
2345
2346
      <screen>&prompt.root; <userinput>kldload ng_ubt</userinput></screen>
2346
      <screen>&prompt.root; <userinput>kldload ng_ubt</userinput></screen>
2347
2347
2348
      <para>If the Bluetooth device will be attached to the system
2348
      <para>If the Bluetooth device will be attached to the system
2349
	during system startup, the system can be configured to load
2349
	during system startup, the system can be configured to load
2350
	the module at boot time by adding the driver to
2350
	the module at boot time by adding the driver to
2351
	<filename>/boot/loader.conf</filename>:</para>
2351
	<filename>/boot/loader.conf</filename>:</para>
2352
2352
2353
      <programlisting>ng_ubt_load="YES"</programlisting>
2353
      <programlisting>ng_ubt_load="YES"</programlisting>
2354
2354
2355
      <para>Once the driver is loaded, plug in the
2355
      <para>Once the driver is loaded, plug in the
2356
	<acronym>USB</acronym> dongle.  If the driver load was
2356
	<acronym>USB</acronym> dongle.  If the driver load was
2357
	successful, output similar to the following should appear on
2357
	successful, output similar to the following should appear on
2358
	the console and in
2358
	the console and in
2359
	<filename>/var/log/messages</filename>:</para>
2359
	<filename>/var/log/messages</filename>:</para>
2360
2360
2361
      <screen>ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
2361
      <screen>ubt0: vendor 0x0a12 product 0x0001, rev 1.10/5.25, addr 2
2362
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
2362
ubt0: Interface 0 endpoints: interrupt=0x81, bulk-in=0x82, bulk-out=0x2
2363
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
2363
ubt0: Interface 1 (alt.config 5) endpoints: isoc-in=0x83, isoc-out=0x3,
2364
      wMaxPacketSize=49, nframes=6, buffer size=294</screen>
2364
      wMaxPacketSize=49, nframes=6, buffer size=294</screen>
2365
2365
2366
      <para>To start and stop the Bluetooth stack, use its startup
2366
      <para>To start and stop the Bluetooth stack, use its startup
2367
	script.  It is a good idea to stop the stack before unplugging
2367
	script.  It is a good idea to stop the stack before unplugging
2368
	the device.  When starting the stack, the output should be
2368
	the device.  When starting the stack, the output should be
2369
	similar to the following:</para>
2369
	similar to the following:</para>
2370
2370
2371
      <screen>&prompt.root; <userinput>service bluetooth start ubt0</userinput>
2371
      <screen>&prompt.root; <userinput>service bluetooth start ubt0</userinput>
2372
BD_ADDR: 00:02:72:00:d4:1a
2372
BD_ADDR: 00:02:72:00:d4:1a
2373
Features: 0xff 0xff 0xf 00 00 00 00 00
2373
Features: 0xff 0xff 0xf 00 00 00 00 00
2374
&lt;3-Slot&gt; &lt;5-Slot&gt; &lt;Encryption&gt; &lt;Slot offset&gt;
2374
&lt;3-Slot&gt; &lt;5-Slot&gt; &lt;Encryption&gt; &lt;Slot offset&gt;
2375
&lt;Timing accuracy&gt; &lt;Switch&gt; &lt;Hold mode&gt; &lt;Sniff mode&gt;
2375
&lt;Timing accuracy&gt; &lt;Switch&gt; &lt;Hold mode&gt; &lt;Sniff mode&gt;
2376
&lt;Park mode&gt; &lt;RSSI&gt; &lt;Channel quality&gt; &lt;SCO link&gt;
2376
&lt;Park mode&gt; &lt;RSSI&gt; &lt;Channel quality&gt; &lt;SCO link&gt;
2377
&lt;HV2 packets&gt; &lt;HV3 packets&gt; &lt;u-law log&gt; &lt;A-law log&gt; &lt;CVSD&gt;
2377
&lt;HV2 packets&gt; &lt;HV3 packets&gt; &lt;u-law log&gt; &lt;A-law log&gt; &lt;CVSD&gt;
2378
&lt;Paging scheme&gt; &lt;Power control&gt; &lt;Transparent SCO data&gt;
2378
&lt;Paging scheme&gt; &lt;Power control&gt; &lt;Transparent SCO data&gt;
2379
Max. ACL packet size: 192 bytes
2379
Max. ACL packet size: 192 bytes
2380
Number of ACL packets: 8
2380
Number of ACL packets: 8
2381
Max. SCO packet size: 64 bytes
2381
Max. SCO packet size: 64 bytes
2382
Number of SCO packets: 8</screen>
2382
Number of SCO packets: 8</screen>
2383
    </sect2>
2383
    </sect2>
2384
2384
2385
    <sect2>
2385
    <sect2>
2386
      <title>Finding Other Bluetooth Devices</title>
2386
      <title>Finding Other Bluetooth Devices</title>
2387
2387
2388
      <indexterm>
2388
      <indexterm>
2389
	<primary>HCI</primary>
2389
	<primary>HCI</primary>
2390
      </indexterm>
2390
      </indexterm>
2391
2391
2392
      <para>The Host Controller Interface (<acronym>HCI</acronym>)
2392
      <para>The Host Controller Interface (<acronym>HCI</acronym>)
2393
	provides a uniform method for accessing Bluetooth baseband
2393
	provides a uniform method for accessing Bluetooth baseband
2394
	capabilities.  In &os;, a netgraph <acronym>HCI</acronym> node
2394
	capabilities.  In &os;, a netgraph <acronym>HCI</acronym> node
2395
	is created for each Bluetooth device.  For more details, refer
2395
	is created for each Bluetooth device.  For more details, refer
2396
	to &man.ng.hci.4;.</para>
2396
	to &man.ng.hci.4;.</para>
2397
2397
2398
      <para>One of the most common tasks is discovery of Bluetooth
2398
      <para>One of the most common tasks is discovery of Bluetooth
2399
	devices within <acronym>RF</acronym> proximity.  This
2399
	devices within <acronym>RF</acronym> proximity.  This
2400
	operation is called <emphasis>inquiry</emphasis>.  Inquiry and
2400
	operation is called <emphasis>inquiry</emphasis>.  Inquiry and
2401
	other <acronym>HCI</acronym> related operations are done using
2401
	other <acronym>HCI</acronym> related operations are done using
2402
	&man.hccontrol.8;.  The example below shows how to find out
2402
	&man.hccontrol.8;.  The example below shows how to find out
2403
	which Bluetooth devices are in range.  The list of devices
2403
	which Bluetooth devices are in range.  The list of devices
2404
	should be displayed in a few seconds.  Note that a remote
2404
	should be displayed in a few seconds.  Note that a remote
2405
	device will only answer the inquiry if it is set to
2405
	device will only answer the inquiry if it is set to
2406
	<emphasis>discoverable</emphasis> mode.</para>
2406
	<emphasis>discoverable</emphasis> mode.</para>
2407
2407
2408
      <screen>&prompt.user; <userinput>hccontrol -n ubt0hci inquiry</userinput>
2408
      <screen>&prompt.user; <userinput>hccontrol -n ubt0hci inquiry</userinput>
2409
Inquiry result, num_responses=1
2409
Inquiry result, num_responses=1
2410
Inquiry result #0
2410
Inquiry result #0
2411
       BD_ADDR: 00:80:37:29:19:a4
2411
       BD_ADDR: 00:80:37:29:19:a4
2412
       Page Scan Rep. Mode: 0x1
2412
       Page Scan Rep. Mode: 0x1
2413
       Page Scan Period Mode: 00
2413
       Page Scan Period Mode: 00
2414
       Page Scan Mode: 00
2414
       Page Scan Mode: 00
2415
       Class: 52:02:04
2415
       Class: 52:02:04
2416
       Clock offset: 0x78ef
2416
       Clock offset: 0x78ef
2417
Inquiry complete. Status: No error [00]</screen>
2417
Inquiry complete. Status: No error [00]</screen>
2418
2418
2419
      <para>The <literal>BD_ADDR</literal> is the unique address of a
2419
      <para>The <literal>BD_ADDR</literal> is the unique address of a
2420
	Bluetooth device, similar to the <acronym>MAC</acronym>
2420
	Bluetooth device, similar to the <acronym>MAC</acronym>
2421
	address of a network card.  This address is needed for further
2421
	address of a network card.  This address is needed for further
2422
	communication with a device and it is possible to assign a
2422
	communication with a device and it is possible to assign a
2423
	human readable name to a BD_ADDR.  Information regarding the
2423
	human readable name to a BD_ADDR.  Information regarding the
2424
	known Bluetooth hosts is contained in
2424
	known Bluetooth hosts is contained in
2425
	<filename>/etc/bluetooth/hosts</filename>.  The following
2425
	<filename>/etc/bluetooth/hosts</filename>.  The following
2426
	example shows how to obtain the human readable name that was
2426
	example shows how to obtain the human readable name that was
2427
	assigned to the remote device:</para>
2427
	assigned to the remote device:</para>
2428
2428
2429
      <screen>&prompt.user; <userinput>hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4</userinput>
2429
      <screen>&prompt.user; <userinput>hccontrol -n ubt0hci remote_name_request 00:80:37:29:19:a4</userinput>
2430
BD_ADDR: 00:80:37:29:19:a4
2430
BD_ADDR: 00:80:37:29:19:a4
2431
Name: Pav's T39</screen>
2431
Name: Pav's T39</screen>
2432
2432
2433
      <para>If an inquiry is performed on a remote Bluetooth device,
2433
      <para>If an inquiry is performed on a remote Bluetooth device,
2434
	it will find the computer as
2434
	it will find the computer as
2435
	<quote>your.host.name (ubt0)</quote>.  The name assigned to
2435
	<quote>your.host.name (ubt0)</quote>.  The name assigned to
2436
	the local device can be changed at any time.</para>
2436
	the local device can be changed at any time.</para>
2437
2437
2438
      <para>The Bluetooth system provides a point-to-point connection
2438
      <para>The Bluetooth system provides a point-to-point connection
2439
	between two Bluetooth units, or a point-to-multipoint
2439
	between two Bluetooth units, or a point-to-multipoint
2440
	connection which is shared among several Bluetooth devices.
2440
	connection which is shared among several Bluetooth devices.
2441
	The following example shows how to obtain the list of active
2441
	The following example shows how to obtain the list of active
2442
	baseband connections for the local device:</para>
2442
	baseband connections for the local device:</para>
2443
2443
2444
      <screen>&prompt.user; <userinput>hccontrol -n ubt0hci read_connection_list</userinput>
2444
      <screen>&prompt.user; <userinput>hccontrol -n ubt0hci read_connection_list</userinput>
2445
Remote BD_ADDR    Handle Type Mode Role Encrypt Pending Queue State
2445
Remote BD_ADDR    Handle Type Mode Role Encrypt Pending Queue State
2446
00:80:37:29:19:a4     41  ACL    0 MAST    NONE       0     0 OPEN</screen>
2446
00:80:37:29:19:a4     41  ACL    0 MAST    NONE       0     0 OPEN</screen>
2447
2447
2448
      <para>A <emphasis>connection handle</emphasis> is useful when
2448
      <para>A <emphasis>connection handle</emphasis> is useful when
2449
	termination of the baseband connection is required, though
2449
	termination of the baseband connection is required, though
2450
	it is normally not required to do this by hand.  The stack
2450
	it is normally not required to do this by hand.  The stack
2451
	will automatically terminate inactive baseband
2451
	will automatically terminate inactive baseband
2452
	connections.</para>
2452
	connections.</para>
2453
2453
2454
      <screen>&prompt.root; <userinput>hccontrol -n ubt0hci disconnect 41</userinput>
2454
      <screen>&prompt.root; <userinput>hccontrol -n ubt0hci disconnect 41</userinput>
2455
Connection handle: 41
2455
Connection handle: 41
2456
Reason: Connection terminated by local host [0x16]</screen>
2456
Reason: Connection terminated by local host [0x16]</screen>
2457
2457
2458
      <para>Type <command>hccontrol help</command> for a complete
2458
      <para>Type <command>hccontrol help</command> for a complete
2459
	listing of available <acronym>HCI</acronym> commands.  Most
2459
	listing of available <acronym>HCI</acronym> commands.  Most
2460
	of the <acronym>HCI</acronym> commands do not require
2460
	of the <acronym>HCI</acronym> commands do not require
2461
	superuser privileges.</para>
2461
	superuser privileges.</para>
2462
    </sect2>
2462
    </sect2>
2463
2463
2464
    <sect2>
2464
    <sect2>
2465
      <title>Device Pairing</title>
2465
      <title>Device Pairing</title>
2466
2466
2467
      <para>By default, Bluetooth communication is not authenticated,
2467
      <para>By default, Bluetooth communication is not authenticated,
2468
	and any device can talk to any other device.  A Bluetooth
2468
	and any device can talk to any other device.  A Bluetooth
2469
	device, such as a cellular phone, may choose to require
2469
	device, such as a cellular phone, may choose to require
2470
	authentication to provide a particular service.  Bluetooth
2470
	authentication to provide a particular service.  Bluetooth
2471
	authentication is normally done with a
2471
	authentication is normally done with a
2472
	<emphasis><acronym>PIN</acronym> code</emphasis>, an ASCII
2472
	<emphasis><acronym>PIN</acronym> code</emphasis>, an ASCII
2473
	string up to 16 characters in length.  The user is required
2473
	string up to 16 characters in length.  The user is required
2474
	to enter the same <acronym>PIN</acronym> code on both devices.
2474
	to enter the same <acronym>PIN</acronym> code on both devices.
2475
	Once the user has entered the <acronym>PIN</acronym> code,
2475
	Once the user has entered the <acronym>PIN</acronym> code,
2476
	both devices will generate a <emphasis>link key</emphasis>.
2476
	both devices will generate a <emphasis>link key</emphasis>.
2477
	After that, the link key can be stored either in the devices
2477
	After that, the link key can be stored either in the devices
2478
	or in a persistent storage.  Next time, both devices will
2478
	or in a persistent storage.  Next time, both devices will
2479
	use the previously generated link key.  This procedure is
2479
	use the previously generated link key.  This procedure is
2480
	called <emphasis>pairing</emphasis>.  Note that if the link
2480
	called <emphasis>pairing</emphasis>.  Note that if the link
2481
	key is lost by either device, the pairing must be
2481
	key is lost by either device, the pairing must be
2482
	repeated.</para>
2482
	repeated.</para>
2483
2483
2484
      <para>The &man.hcsecd.8; daemon is responsible for handling
2484
      <para>The &man.hcsecd.8; daemon is responsible for handling
2485
	Bluetooth authentication requests.  The default configuration
2485
	Bluetooth authentication requests.  The default configuration
2486
	file is <filename>/etc/bluetooth/hcsecd.conf</filename>.  An
2486
	file is <filename>/etc/bluetooth/hcsecd.conf</filename>.  An
2487
	example section for a cellular phone with the
2487
	example section for a cellular phone with the
2488
	<acronym>PIN</acronym> code set to <literal>1234</literal> is
2488
	<acronym>PIN</acronym> code set to <literal>1234</literal> is
2489
	shown below:</para>
2489
	shown below:</para>
2490
2490
2491
      <programlisting>device {
2491
      <programlisting>device {
2492
        bdaddr  00:80:37:29:19:a4;
2492
        bdaddr  00:80:37:29:19:a4;
2493
        name    "Pav's T39";
2493
        name    "Pav's T39";
2494
        key     nokey;
2494
        key     nokey;
2495
        pin     "1234";
2495
        pin     "1234";
2496
      }</programlisting>
2496
      }</programlisting>
2497
2497
2498
      <para>The only limitation on <acronym>PIN</acronym> codes is
2498
      <para>The only limitation on <acronym>PIN</acronym> codes is
2499
	length.  Some devices, such as Bluetooth headsets, may have
2499
	length.  Some devices, such as Bluetooth headsets, may have
2500
	a fixed <acronym>PIN</acronym> code built in.  The
2500
	a fixed <acronym>PIN</acronym> code built in.  The
2501
	<option>-d</option> switch forces &man.hcsecd.8; to stay in
2501
	<option>-d</option> switch forces &man.hcsecd.8; to stay in
2502
	the foreground, so it is easy to see what is happening.  Set
2502
	the foreground, so it is easy to see what is happening.  Set
2503
	the remote device to receive pairing and initiate the
2503
	the remote device to receive pairing and initiate the
2504
	Bluetooth connection to the remote device.  The remote device
2504
	Bluetooth connection to the remote device.  The remote device
2505
	should indicate that pairing was accepted and request the
2505
	should indicate that pairing was accepted and request the
2506
	<acronym>PIN</acronym> code.  Enter the same
2506
	<acronym>PIN</acronym> code.  Enter the same
2507
	<acronym>PIN</acronym> code listed in
2507
	<acronym>PIN</acronym> code listed in
2508
	<filename>hcsecd.conf</filename>.  Now the computer and the
2508
	<filename>hcsecd.conf</filename>.  Now the computer and the
2509
	remote device are paired.  Alternatively, pairing can be
2509
	remote device are paired.  Alternatively, pairing can be
2510
	initiated on the remote device.</para>
2510
	initiated on the remote device.</para>
2511
2511
2512
      <para>The following line can be added to
2512
      <para>The following line can be added to
2513
	<filename>/etc/rc.conf</filename> to configure &man.hcsecd.8;
2513
	<filename>/etc/rc.conf</filename> to configure &man.hcsecd.8;
2514
	to start automatically on system start:</para>
2514
	to start automatically on system start:</para>
2515
2515
2516
      <programlisting>hcsecd_enable="YES"</programlisting>
2516
      <programlisting>hcsecd_enable="YES"</programlisting>
2517
2517
2518
      <para>The following is a sample of the &man.hcsecd.8; daemon
2518
      <para>The following is a sample of the &man.hcsecd.8; daemon
2519
	output:</para>
2519
	output:</para>
2520
2520
2521
      <programlisting>hcsecd[16484]: Got Link_Key_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4
2521
      <programlisting>hcsecd[16484]: Got Link_Key_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4
2522
hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', link key doesn't exist
2522
hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', link key doesn't exist
2523
hcsecd[16484]: Sending Link_Key_Negative_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4
2523
hcsecd[16484]: Sending Link_Key_Negative_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4
2524
hcsecd[16484]: Got PIN_Code_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4
2524
hcsecd[16484]: Got PIN_Code_Request event from 'ubt0hci', remote bdaddr 0:80:37:29:19:a4
2525
hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', PIN code exists
2525
hcsecd[16484]: Found matching entry, remote bdaddr 0:80:37:29:19:a4, name 'Pav's T39', PIN code exists
2526
hcsecd[16484]: Sending PIN_Code_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4</programlisting>
2526
hcsecd[16484]: Sending PIN_Code_Reply to 'ubt0hci' for remote bdaddr 0:80:37:29:19:a4</programlisting>
2527
    </sect2>
2527
    </sect2>
2528
2528
2529
    <sect2>
2529
    <sect2>
2530
      <title>Network Access with
2530
      <title>Network Access with
2531
	<acronym>PPP</acronym> Profiles</title>
2531
	<acronym>PPP</acronym> Profiles</title>
2532
2532
2533
      <para>A Dial-Up Networking (<acronym>DUN</acronym>) profile can
2533
      <para>A Dial-Up Networking (<acronym>DUN</acronym>) profile can
2534
	be used to configure a cellular phone as a wireless modem for
2534
	be used to configure a cellular phone as a wireless modem for
2535
	connecting to a dial-up Internet access server.  It can also
2535
	connecting to a dial-up Internet access server.  It can also
2536
	be used to configure a computer to receive data calls from a
2536
	be used to configure a computer to receive data calls from a
2537
	cellular phone.</para>
2537
	cellular phone.</para>
2538
2538
2539
      <para>Network access with a <acronym>PPP</acronym> profile can
2539
      <para>Network access with a <acronym>PPP</acronym> profile can
2540
	be used to provide <acronym>LAN</acronym> access for a single
2540
	be used to provide <acronym>LAN</acronym> access for a single
2541
	Bluetooth device or multiple Bluetooth devices.  It can also
2541
	Bluetooth device or multiple Bluetooth devices.  It can also
2542
	provide <acronym>PC</acronym> to <acronym>PC</acronym>
2542
	provide <acronym>PC</acronym> to <acronym>PC</acronym>
2543
	connection using <acronym>PPP</acronym> networking over serial
2543
	connection using <acronym>PPP</acronym> networking over serial
2544
	cable emulation.</para>
2544
	cable emulation.</para>
2545
2545
2546
      <para>In &os;, these profiles are implemented with &man.ppp.8;
2546
      <para>In &os;, these profiles are implemented with &man.ppp.8;
2547
	and the &man.rfcomm.pppd.8; wrapper which converts a
2547
	and the &man.rfcomm.pppd.8; wrapper which converts a
2548
	Bluetooth connection into something
2548
	Bluetooth connection into something
2549
	<acronym>PPP</acronym> can use.  Before a profile can be used,
2549
	<acronym>PPP</acronym> can use.  Before a profile can be used,
2550
	a new <acronym>PPP</acronym> label must be created in
2550
	a new <acronym>PPP</acronym> label must be created in
2551
	<filename>/etc/ppp/ppp.conf</filename>.  Consult
2551
	<filename>/etc/ppp/ppp.conf</filename>.  Consult
2552
	&man.rfcomm.pppd.8; for examples.</para>
2552
	&man.rfcomm.pppd.8; for examples.</para>
2553
2553
2554
      <para>In this example, &man.rfcomm.pppd.8; is used to open a
2554
      <para>In this example, &man.rfcomm.pppd.8; is used to open a
2555
	connection to a remote device with a
2555
	connection to a remote device with a
2556
	<literal>BD_ADDR</literal> of
2556
	<literal>BD_ADDR</literal> of
2557
	<literal>00:80:37:29:19:a4</literal> on a
2557
	<literal>00:80:37:29:19:a4</literal> on a
2558
	<acronym>DUN</acronym> <acronym>RFCOMM</acronym>
2558
	<acronym>DUN</acronym> <acronym>RFCOMM</acronym>
2559
	channel:</para>
2559
	channel:</para>
2560
2560
2561
      <screen>&prompt.root; <userinput>rfcomm_pppd -a 00:80:37:29:19:a4 -c -C dun -l rfcomm-dialup</userinput></screen>
2561
      <screen>&prompt.root; <userinput>rfcomm_pppd -a 00:80:37:29:19:a4 -c -C dun -l rfcomm-dialup</userinput></screen>
2562
2562
2563
      <para>The actual channel number will be obtained from the remote
2563
      <para>The actual channel number will be obtained from the remote
2564
	device using the <acronym>SDP</acronym> protocol.  It is
2564
	device using the <acronym>SDP</acronym> protocol.  It is
2565
	possible to specify the <acronym>RFCOMM</acronym> channel by
2565
	possible to specify the <acronym>RFCOMM</acronym> channel by
2566
	hand, and in this case &man.rfcomm.pppd.8; will not perform
2566
	hand, and in this case &man.rfcomm.pppd.8; will not perform
2567
	the <acronym>SDP</acronym> query.  Use &man.sdpcontrol.8; to
2567
	the <acronym>SDP</acronym> query.  Use &man.sdpcontrol.8; to
2568
	find out the <acronym>RFCOMM</acronym> channel on the remote
2568
	find out the <acronym>RFCOMM</acronym> channel on the remote
2569
	device.</para>
2569
	device.</para>
2570
2570
2571
      <para>In order to provide network access with the
2571
      <para>In order to provide network access with the
2572
	<acronym>PPP</acronym> <acronym>LAN</acronym> service,
2572
	<acronym>PPP</acronym> <acronym>LAN</acronym> service,
2573
	&man.sdpd.8; must be running and a new entry for
2573
	&man.sdpd.8; must be running and a new entry for
2574
	<acronym>LAN</acronym> clients must be created in
2574
	<acronym>LAN</acronym> clients must be created in
2575
	<filename>/etc/ppp/ppp.conf</filename>.  Consult
2575
	<filename>/etc/ppp/ppp.conf</filename>.  Consult
2576
	&man.rfcomm.pppd.8; for examples.  Finally, start the
2576
	&man.rfcomm.pppd.8; for examples.  Finally, start the
2577
	<acronym>RFCOMM</acronym> <acronym>PPP</acronym> server on a
2577
	<acronym>RFCOMM</acronym> <acronym>PPP</acronym> server on a
2578
	valid <acronym>RFCOMM</acronym> channel number.  The
2578
	valid <acronym>RFCOMM</acronym> channel number.  The
2579
	<acronym>RFCOMM</acronym> <acronym>PPP</acronym> server will
2579
	<acronym>RFCOMM</acronym> <acronym>PPP</acronym> server will
2580
	automatically register the Bluetooth <acronym>LAN</acronym>
2580
	automatically register the Bluetooth <acronym>LAN</acronym>
2581
	service with the local <acronym>SDP</acronym> daemon.  The
2581
	service with the local <acronym>SDP</acronym> daemon.  The
2582
	example below shows how to start the <acronym>RFCOMM</acronym>
2582
	example below shows how to start the <acronym>RFCOMM</acronym>
2583
	<acronym>PPP</acronym> server.</para>
2583
	<acronym>PPP</acronym> server.</para>
2584
2584
2585
      <screen>&prompt.root; <userinput>rfcomm_pppd -s -C 7 -l rfcomm-server</userinput></screen>
2585
      <screen>&prompt.root; <userinput>rfcomm_pppd -s -C 7 -l rfcomm-server</userinput></screen>
2586
    </sect2>
2586
    </sect2>
2587
2587
2588
    <sect2>
2588
    <sect2>
2589
      <title>Bluetooth Protocols</title>
2589
      <title>Bluetooth Protocols</title>
2590
2590
2591
      <para>This section provides an overview of the various Bluetooth
2591
      <para>This section provides an overview of the various Bluetooth
2592
	protocols, their function, and associated utilities.</para>
2592
	protocols, their function, and associated utilities.</para>
2593
2593
2594
      <sect3>
2594
      <sect3>
2595
	<title>Logical Link Control and Adaptation Protocol
2595
	<title>Logical Link Control and Adaptation Protocol
2596
	  (<acronym>L2CAP</acronym>)</title>
2596
	  (<acronym>L2CAP</acronym>)</title>
2597
2597
2598
	<indexterm>
2598
	<indexterm>
2599
	  <primary>L2CAP</primary>
2599
	  <primary>L2CAP</primary>
2600
	</indexterm>
2600
	</indexterm>
2601
2601
2602
	<para>The Logical Link Control and Adaptation Protocol
2602
	<para>The Logical Link Control and Adaptation Protocol
2603
	  (<acronym>L2CAP</acronym>) provides connection-oriented and
2603
	  (<acronym>L2CAP</acronym>) provides connection-oriented and
2604
	  connectionless data services to upper layer protocols.
2604
	  connectionless data services to upper layer protocols.
2605
	  <acronym>L2CAP</acronym> permits higher level protocols and
2605
	  <acronym>L2CAP</acronym> permits higher level protocols and
2606
	  applications to transmit and receive
2606
	  applications to transmit and receive
2607
	  <acronym>L2CAP</acronym> data packets up to 64 kilobytes in
2607
	  <acronym>L2CAP</acronym> data packets up to 64 kilobytes in
2608
	  length.</para>
2608
	  length.</para>
2609
2609
2610
	<para><acronym>L2CAP</acronym> is based around the concept of
2610
	<para><acronym>L2CAP</acronym> is based around the concept of
2611
	  <emphasis>channels</emphasis>.  A channel is a logical
2611
	  <emphasis>channels</emphasis>.  A channel is a logical
2612
	  connection on top of a baseband connection, where each
2612
	  connection on top of a baseband connection, where each
2613
	  channel is bound to a single protocol in a many-to-one
2613
	  channel is bound to a single protocol in a many-to-one
2614
	  fashion.  Multiple channels can be bound to the same
2614
	  fashion.  Multiple channels can be bound to the same
2615
	  protocol, but a channel cannot be bound to multiple
2615
	  protocol, but a channel cannot be bound to multiple
2616
	  protocols.  Each <acronym>L2CAP</acronym> packet received on
2616
	  protocols.  Each <acronym>L2CAP</acronym> packet received on
2617
	  a channel is directed to the appropriate higher level
2617
	  a channel is directed to the appropriate higher level
2618
	  protocol.  Multiple channels can share the same baseband
2618
	  protocol.  Multiple channels can share the same baseband
2619
	  connection.</para>
2619
	  connection.</para>
2620
2620
2621
	<para>In &os;, a netgraph <acronym>L2CAP</acronym> node is
2621
	<para>In &os;, a netgraph <acronym>L2CAP</acronym> node is
2622
	  created for each Bluetooth device.  This node is normally
2622
	  created for each Bluetooth device.  This node is normally
2623
	  connected to the downstream Bluetooth <acronym>HCI</acronym>
2623
	  connected to the downstream Bluetooth <acronym>HCI</acronym>
2624
	  node and upstream Bluetooth socket nodes.  The default name
2624
	  node and upstream Bluetooth socket nodes.  The default name
2625
	  for the <acronym>L2CAP</acronym> node is
2625
	  for the <acronym>L2CAP</acronym> node is
2626
	  <quote>devicel2cap</quote>.  For more details refer to
2626
	  <quote>devicel2cap</quote>.  For more details refer to
2627
	  &man.ng.l2cap.4;.</para>
2627
	  &man.ng.l2cap.4;.</para>
2628
2628
2629
	<para>A useful command is &man.l2ping.8;, which can be used to
2629
	<para>A useful command is &man.l2ping.8;, which can be used to
2630
	  ping other devices.  Some Bluetooth implementations might
2630
	  ping other devices.  Some Bluetooth implementations might
2631
	  not return all of the data sent to them, so <literal>0
2631
	  not return all of the data sent to them, so <literal>0
2632
	    bytes</literal> in the following example is normal.</para>
2632
	    bytes</literal> in the following example is normal.</para>
2633
2633
2634
	<screen>&prompt.root; <userinput>l2ping -a 00:80:37:29:19:a4</userinput>
2634
	<screen>&prompt.root; <userinput>l2ping -a 00:80:37:29:19:a4</userinput>
2635
0 bytes from 0:80:37:29:19:a4 seq_no=0 time=48.633 ms result=0
2635
0 bytes from 0:80:37:29:19:a4 seq_no=0 time=48.633 ms result=0
2636
0 bytes from 0:80:37:29:19:a4 seq_no=1 time=37.551 ms result=0
2636
0 bytes from 0:80:37:29:19:a4 seq_no=1 time=37.551 ms result=0
2637
0 bytes from 0:80:37:29:19:a4 seq_no=2 time=28.324 ms result=0
2637
0 bytes from 0:80:37:29:19:a4 seq_no=2 time=28.324 ms result=0
2638
0 bytes from 0:80:37:29:19:a4 seq_no=3 time=46.150 ms result=0</screen>
2638
0 bytes from 0:80:37:29:19:a4 seq_no=3 time=46.150 ms result=0</screen>
2639
2639
2640
	<para>The &man.l2control.8; utility is used to perform various
2640
	<para>The &man.l2control.8; utility is used to perform various
2641
	  operations on <acronym>L2CAP</acronym> nodes.  This example
2641
	  operations on <acronym>L2CAP</acronym> nodes.  This example
2642
	  shows how to obtain the list of logical connections
2642
	  shows how to obtain the list of logical connections
2643
	  (channels) and the list of baseband connections for the
2643
	  (channels) and the list of baseband connections for the
2644
	  local device:</para>
2644
	  local device:</para>
2645
2645
2646
	<screen>&prompt.user; <userinput>l2control -a 00:02:72:00:d4:1a read_channel_list</userinput>
2646
	<screen>&prompt.user; <userinput>l2control -a 00:02:72:00:d4:1a read_channel_list</userinput>
2647
L2CAP channels:
2647
L2CAP channels:
2648
Remote BD_ADDR     SCID/ DCID   PSM  IMTU/ OMTU State
2648
Remote BD_ADDR     SCID/ DCID   PSM  IMTU/ OMTU State
2649
00:07:e0:00:0b:ca    66/   64     3   132/  672 OPEN
2649
00:07:e0:00:0b:ca    66/   64     3   132/  672 OPEN
2650
&prompt.user; <userinput>l2control -a 00:02:72:00:d4:1a read_connection_list</userinput>
2650
&prompt.user; <userinput>l2control -a 00:02:72:00:d4:1a read_connection_list</userinput>
2651
L2CAP connections:
2651
L2CAP connections:
2652
Remote BD_ADDR    Handle Flags Pending State
2652
Remote BD_ADDR    Handle Flags Pending State
2653
00:07:e0:00:0b:ca     41 O           0 OPEN</screen>
2653
00:07:e0:00:0b:ca     41 O           0 OPEN</screen>
2654
2654
2655
	<para>Another diagnostic tool is &man.btsockstat.1;.  It is
2655
	<para>Another diagnostic tool is &man.btsockstat.1;.  It is
2656
	  similar to &man.netstat.1;, but for Bluetooth
2656
	  similar to &man.netstat.1;, but for Bluetooth
2657
	  network-related data structures.  The example below shows
2657
	  network-related data structures.  The example below shows
2658
	  the same logical connection as &man.l2control.8;
2658
	  the same logical connection as &man.l2control.8;
2659
	  above.</para>
2659
	  above.</para>
2660
2660
2661
	<screen>&prompt.user; <userinput>btsockstat</userinput>
2661
	<screen>&prompt.user; <userinput>btsockstat</userinput>
2662
Active L2CAP sockets
2662
Active L2CAP sockets
2663
PCB      Recv-Q Send-Q Local address/PSM       Foreign address   CID   State
2663
PCB      Recv-Q Send-Q Local address/PSM       Foreign address   CID   State
2664
c2afe900      0      0 00:02:72:00:d4:1a/3     00:07:e0:00:0b:ca 66    OPEN
2664
c2afe900      0      0 00:02:72:00:d4:1a/3     00:07:e0:00:0b:ca 66    OPEN
2665
Active RFCOMM sessions
2665
Active RFCOMM sessions
2666
L2PCB    PCB      Flag MTU   Out-Q DLCs State
2666
L2PCB    PCB      Flag MTU   Out-Q DLCs State
2667
c2afe900 c2b53380 1    127   0     Yes  OPEN
2667
c2afe900 c2b53380 1    127   0     Yes  OPEN
2668
Active RFCOMM sockets
2668
Active RFCOMM sockets
2669
PCB      Recv-Q Send-Q Local address     Foreign address   Chan DLCI State
2669
PCB      Recv-Q Send-Q Local address     Foreign address   Chan DLCI State
2670
c2e8bc80      0    250 00:02:72:00:d4:1a 00:07:e0:00:0b:ca 3    6    OPEN</screen>
2670
c2e8bc80      0    250 00:02:72:00:d4:1a 00:07:e0:00:0b:ca 3    6    OPEN</screen>
2671
      </sect3>
2671
      </sect3>
2672
2672
2673
      <sect3>
2673
      <sect3>
2674
	<title>Radio Frequency Communication
2674
	<title>Radio Frequency Communication
2675
	  (<acronym>RFCOMM</acronym>)</title>
2675
	  (<acronym>RFCOMM</acronym>)</title>
2676
2676
2677
	<para>The <acronym>RFCOMM</acronym> protocol provides
2677
	<para>The <acronym>RFCOMM</acronym> protocol provides
2678
	  emulation of serial ports over the <acronym>L2CAP</acronym>
2678
	  emulation of serial ports over the <acronym>L2CAP</acronym>
2679
	  protocol.  <acronym>RFCOMM</acronym> is a simple transport
2679
	  protocol.  <acronym>RFCOMM</acronym> is a simple transport
2680
	  protocol, with additional provisions for emulating the 9
2680
	  protocol, with additional provisions for emulating the 9
2681
	  circuits of RS-232 (EIATIA-232-E) serial ports.  It
2681
	  circuits of RS-232 (EIATIA-232-E) serial ports.  It
2682
	  supports up to 60 simultaneous connections
2682
	  supports up to 60 simultaneous connections
2683
	  (<acronym>RFCOMM</acronym> channels) between two Bluetooth
2683
	  (<acronym>RFCOMM</acronym> channels) between two Bluetooth
2684
	  devices.</para>
2684
	  devices.</para>
2685
2685
2686
	<para>For the purposes of <acronym>RFCOMM</acronym>, a
2686
	<para>For the purposes of <acronym>RFCOMM</acronym>, a
2687
	  complete communication path involves two applications
2687
	  complete communication path involves two applications
2688
	  running on the communication endpoints with a communication
2688
	  running on the communication endpoints with a communication
2689
	  segment between them.  <acronym>RFCOMM</acronym> is intended
2689
	  segment between them.  <acronym>RFCOMM</acronym> is intended
2690
	  to cover applications that make use of the serial ports of
2690
	  to cover applications that make use of the serial ports of
2691
	  the devices in which they reside.  The communication segment
2691
	  the devices in which they reside.  The communication segment
2692
	  is a direct connect Bluetooth link from one device to
2692
	  is a direct connect Bluetooth link from one device to
2693
	  another.</para>
2693
	  another.</para>
2694
2694
2695
	<para><acronym>RFCOMM</acronym> is only concerned with the
2695
	<para><acronym>RFCOMM</acronym> is only concerned with the
2696
	  connection between the devices in the direct connect case,
2696
	  connection between the devices in the direct connect case,
2697
	  or between the device and a modem in the network case.
2697
	  or between the device and a modem in the network case.
2698
	  <acronym>RFCOMM</acronym> can support other configurations,
2698
	  <acronym>RFCOMM</acronym> can support other configurations,
2699
	  such as modules that communicate via Bluetooth wireless
2699
	  such as modules that communicate via Bluetooth wireless
2700
	  technology on one side and provide a wired interface on the
2700
	  technology on one side and provide a wired interface on the
2701
	  other side.</para>
2701
	  other side.</para>
2702
2702
2703
	<para>In &os;, <acronym>RFCOMM</acronym> is implemented at the
2703
	<para>In &os;, <acronym>RFCOMM</acronym> is implemented at the
2704
	  Bluetooth sockets layer.</para>
2704
	  Bluetooth sockets layer.</para>
2705
      </sect3>
2705
      </sect3>
2706
2706
2707
      <sect3>
2707
      <sect3>
2708
	<title>Service Discovery Protocol
2708
	<title>Service Discovery Protocol
2709
	  (<acronym>SDP</acronym>)</title>
2709
	  (<acronym>SDP</acronym>)</title>
2710
2710
2711
	<indexterm>
2711
	<indexterm>
2712
	  <primary>SDP</primary>
2712
	  <primary>SDP</primary>
2713
	</indexterm>
2713
	</indexterm>
2714
2714
2715
	<para>The Service Discovery Protocol (<acronym>SDP</acronym>)
2715
	<para>The Service Discovery Protocol (<acronym>SDP</acronym>)
2716
	  provides the means for client applications to discover the
2716
	  provides the means for client applications to discover the
2717
	  existence of services provided by server applications as
2717
	  existence of services provided by server applications as
2718
	  well as the attributes of those services.  The attributes of
2718
	  well as the attributes of those services.  The attributes of
2719
	  a service include the type or class of service offered and
2719
	  a service include the type or class of service offered and
2720
	  the mechanism or protocol information needed to utilize the
2720
	  the mechanism or protocol information needed to utilize the
2721
	  service.</para>
2721
	  service.</para>
2722
2722
2723
	<para><acronym>SDP</acronym> involves communication between a
2723
	<para><acronym>SDP</acronym> involves communication between a
2724
	  <acronym>SDP</acronym> server and a <acronym>SDP</acronym>
2724
	  <acronym>SDP</acronym> server and a <acronym>SDP</acronym>
2725
	  client.  The server maintains a list of service records that
2725
	  client.  The server maintains a list of service records that
2726
	  describe the characteristics of services associated with the
2726
	  describe the characteristics of services associated with the
2727
	  server.  Each service record contains information about a
2727
	  server.  Each service record contains information about a
2728
	  single service.  A client may retrieve information from a
2728
	  single service.  A client may retrieve information from a
2729
	  service record maintained by the <acronym>SDP</acronym>
2729
	  service record maintained by the <acronym>SDP</acronym>
2730
	  server by issuing a <acronym>SDP</acronym> request.  If the
2730
	  server by issuing a <acronym>SDP</acronym> request.  If the
2731
	  client, or an application associated with the client,
2731
	  client, or an application associated with the client,
2732
	  decides to use a service, it must open a separate connection
2732
	  decides to use a service, it must open a separate connection
2733
	  to the service provider in order to utilize the service.
2733
	  to the service provider in order to utilize the service.
2734
	  <acronym>SDP</acronym> provides a mechanism for discovering
2734
	  <acronym>SDP</acronym> provides a mechanism for discovering
2735
	  services and their attributes, but it does not provide a
2735
	  services and their attributes, but it does not provide a
2736
	  mechanism for utilizing those services.</para>
2736
	  mechanism for utilizing those services.</para>
2737
2737
2738
	<para>Normally, a <acronym>SDP</acronym> client searches for
2738
	<para>Normally, a <acronym>SDP</acronym> client searches for
2739
	  services based on some desired characteristics of the
2739
	  services based on some desired characteristics of the
2740
	  services.  However, there are times when it is desirable to
2740
	  services.  However, there are times when it is desirable to
2741
	  discover which types of services are described by an
2741
	  discover which types of services are described by an
2742
	  <acronym>SDP</acronym> server's service records without any
2742
	  <acronym>SDP</acronym> server's service records without any
2743
	  prior information about the services.  This process of
2743
	  prior information about the services.  This process of
2744
	  looking for any offered services is called
2744
	  looking for any offered services is called
2745
	  <emphasis>browsing</emphasis>.</para>
2745
	  <emphasis>browsing</emphasis>.</para>
2746
2746
2747
	<para>The Bluetooth <acronym>SDP</acronym> server,
2747
	<para>The Bluetooth <acronym>SDP</acronym> server,
2748
	  &man.sdpd.8;, and command line client, &man.sdpcontrol.8;,
2748
	  &man.sdpd.8;, and command line client, &man.sdpcontrol.8;,
2749
	  are included in the standard &os; installation.  The
2749
	  are included in the standard &os; installation.  The
2750
	  following example shows how to perform a
2750
	  following example shows how to perform a
2751
	  <acronym>SDP</acronym> browse query.</para>
2751
	  <acronym>SDP</acronym> browse query.</para>
2752
2752
2753
	<screen>&prompt.user; <userinput>sdpcontrol -a 00:01:03:fc:6e:ec browse</userinput>
2753
	<screen>&prompt.user; <userinput>sdpcontrol -a 00:01:03:fc:6e:ec browse</userinput>
2754
Record Handle: 00000000
2754
Record Handle: 00000000
2755
Service Class ID List:
2755
Service Class ID List:
2756
        Service Discovery Server (0x1000)
2756
        Service Discovery Server (0x1000)
2757
Protocol Descriptor List:
2757
Protocol Descriptor List:
2758
        L2CAP (0x0100)
2758
        L2CAP (0x0100)
2759
                Protocol specific parameter #1: u/int/uuid16 1
2759
                Protocol specific parameter #1: u/int/uuid16 1
2760
                Protocol specific parameter #2: u/int/uuid16 1
2760
                Protocol specific parameter #2: u/int/uuid16 1
2761
2761
2762
Record Handle: 0x00000001
2762
Record Handle: 0x00000001
2763
Service Class ID List:
2763
Service Class ID List:
2764
        Browse Group Descriptor (0x1001)
2764
        Browse Group Descriptor (0x1001)
2765
2765
2766
Record Handle: 0x00000002
2766
Record Handle: 0x00000002
2767
Service Class ID List:
2767
Service Class ID List:
2768
        LAN Access Using PPP (0x1102)
2768
        LAN Access Using PPP (0x1102)
2769
Protocol Descriptor List:
2769
Protocol Descriptor List:
2770
        L2CAP (0x0100)
2770
        L2CAP (0x0100)
2771
        RFCOMM (0x0003)
2771
        RFCOMM (0x0003)
2772
                Protocol specific parameter #1: u/int8/bool 1
2772
                Protocol specific parameter #1: u/int8/bool 1
2773
Bluetooth Profile Descriptor List:
2773
Bluetooth Profile Descriptor List:
2774
        LAN Access Using PPP (0x1102) ver. 1.0</screen>
2774
        LAN Access Using PPP (0x1102) ver. 1.0</screen>
2775
2775
2776
	<para>Note that each service has a list of attributes, such
2776
	<para>Note that each service has a list of attributes, such
2777
	  as the <acronym>RFCOMM</acronym> channel.  Depending on the
2777
	  as the <acronym>RFCOMM</acronym> channel.  Depending on the
2778
	  service, the user might need to make note of some of the
2778
	  service, the user might need to make note of some of the
2779
	  attributes.  Some Bluetooth implementations do not support
2779
	  attributes.  Some Bluetooth implementations do not support
2780
	  service browsing and may return an empty list.  In this
2780
	  service browsing and may return an empty list.  In this
2781
	  case, it is possible to search for the specific service.
2781
	  case, it is possible to search for the specific service.
2782
	  The example below shows how to search for the
2782
	  The example below shows how to search for the
2783
	  <acronym>OBEX</acronym> Object Push
2783
	  <acronym>OBEX</acronym> Object Push
2784
	  (<acronym>OPUSH</acronym>) service:</para>
2784
	  (<acronym>OPUSH</acronym>) service:</para>
2785
2785
2786
	<screen>&prompt.user; <userinput>sdpcontrol -a 00:01:03:fc:6e:ec search OPUSH</userinput></screen>
2786
	<screen>&prompt.user; <userinput>sdpcontrol -a 00:01:03:fc:6e:ec search OPUSH</userinput></screen>
2787
2787
2788
	<para>Offering services on &os; to Bluetooth clients is done
2788
	<para>Offering services on &os; to Bluetooth clients is done
2789
	  with the &man.sdpd.8; server.  The following line can be
2789
	  with the &man.sdpd.8; server.  The following line can be
2790
	  added to <filename>/etc/rc.conf</filename>:</para>
2790
	  added to <filename>/etc/rc.conf</filename>:</para>
2791
2791
2792
	<programlisting>sdpd_enable="YES"</programlisting>
2792
	<programlisting>sdpd_enable="YES"</programlisting>
2793
2793
2794
	<para>Then the &man.sdpd.8; daemon can be started with:</para>
2794
	<para>Then the &man.sdpd.8; daemon can be started with:</para>
2795
2795
2796
	<screen>&prompt.root; <userinput>service sdpd start</userinput></screen>
2796
	<screen>&prompt.root; <userinput>service sdpd start</userinput></screen>
2797
2797
2798
	<para>The local server application that wants to provide a
2798
	<para>The local server application that wants to provide a
2799
	  Bluetooth service to remote clients will register the
2799
	  Bluetooth service to remote clients will register the
2800
	  service with the local <acronym>SDP</acronym> daemon.  An
2800
	  service with the local <acronym>SDP</acronym> daemon.  An
2801
	  example of such an application is &man.rfcomm.pppd.8;.  Once
2801
	  example of such an application is &man.rfcomm.pppd.8;.  Once
2802
	  started, it will register the Bluetooth LAN service with the
2802
	  started, it will register the Bluetooth LAN service with the
2803
	  local <acronym>SDP</acronym> daemon.</para>
2803
	  local <acronym>SDP</acronym> daemon.</para>
2804
2804
2805
	<para>The list of services registered with the local
2805
	<para>The list of services registered with the local
2806
	  <acronym>SDP</acronym> server can be obtained by issuing a
2806
	  <acronym>SDP</acronym> server can be obtained by issuing a
2807
	  <acronym>SDP</acronym> browse query via the local control
2807
	  <acronym>SDP</acronym> browse query via the local control
2808
	  channel:</para>
2808
	  channel:</para>
2809
2809
2810
	<screen>&prompt.root; <userinput>sdpcontrol -l browse</userinput></screen>
2810
	<screen>&prompt.root; <userinput>sdpcontrol -l browse</userinput></screen>
2811
      </sect3>
2811
      </sect3>
2812
2812
2813
      <sect3>
2813
      <sect3>
2814
	<title><acronym>OBEX</acronym> Object Push
2814
	<title><acronym>OBEX</acronym> Object Push
2815
	  (<acronym>OPUSH</acronym>)</title>
2815
	  (<acronym>OPUSH</acronym>)</title>
2816
2816
2817
	<indexterm>
2817
	<indexterm>
2818
	  <primary>OBEX</primary>
2818
	  <primary>OBEX</primary>
2819
	</indexterm>
2819
	</indexterm>
2820
2820
2821
	<para>Object Exchange (<acronym>OBEX</acronym>) is a widely
2821
	<para>Object Exchange (<acronym>OBEX</acronym>) is a widely
2822
	  used protocol for simple file transfers between mobile
2822
	  used protocol for simple file transfers between mobile
2823
	  devices.  Its main use is in infrared communication, where
2823
	  devices.  Its main use is in infrared communication, where
2824
	  it is used for generic file transfers between notebooks or
2824
	  it is used for generic file transfers between notebooks or
2825
	  <acronym>PDA</acronym>s, and for sending business cards or
2825
	  <acronym>PDA</acronym>s, and for sending business cards or
2826
	  calendar entries between cellular phones and other devices
2826
	  calendar entries between cellular phones and other devices
2827
	  with Personal Information Manager (<acronym>PIM</acronym>)
2827
	  with Personal Information Manager (<acronym>PIM</acronym>)
2828
	  applications.</para>
2828
	  applications.</para>
2829
2829
2830
	<para>The <acronym>OBEX</acronym> server and client are
2830
	<para>The <acronym>OBEX</acronym> server and client are
2831
	  implemented by <application>obexapp</application>, which can
2831
	  implemented by <application>obexapp</application>, which can
2832
	  be installed using the <package>comms/obexapp</package>
2832
	  be installed using the <package>comms/obexapp</package>
2833
	  package or port.</para>
2833
	  package or port.</para>
2834
2834
2835
	<para>The <acronym>OBEX</acronym> client is used to push
2835
	<para>The <acronym>OBEX</acronym> client is used to push
2836
	  and/or pull objects from the <acronym>OBEX</acronym> server.
2836
	  and/or pull objects from the <acronym>OBEX</acronym> server.
2837
	  An example object is a business card or an appointment.
2837
	  An example object is a business card or an appointment.
2838
	  The <acronym>OBEX</acronym> client can obtain the
2838
	  The <acronym>OBEX</acronym> client can obtain the
2839
	  <acronym>RFCOMM</acronym> channel number from the remote
2839
	  <acronym>RFCOMM</acronym> channel number from the remote
2840
	  device via <acronym>SDP</acronym>.  This can be done by
2840
	  device via <acronym>SDP</acronym>.  This can be done by
2841
	  specifying the service name instead of the
2841
	  specifying the service name instead of the
2842
	  <acronym>RFCOMM</acronym> channel number.  Supported service
2842
	  <acronym>RFCOMM</acronym> channel number.  Supported service
2843
	  names are: <literal>IrMC</literal>, <literal>FTRN</literal>,
2843
	  names are: <literal>IrMC</literal>, <literal>FTRN</literal>,
2844
	  and <literal>OPUSH</literal>.  It is also possible to
2844
	  and <literal>OPUSH</literal>.  It is also possible to
2845
	  specify the <acronym>RFCOMM</acronym> channel as a number.
2845
	  specify the <acronym>RFCOMM</acronym> channel as a number.
2846
	  Below is an example of an <acronym>OBEX</acronym> session
2846
	  Below is an example of an <acronym>OBEX</acronym> session
2847
	  where the device information object is pulled from the
2847
	  where the device information object is pulled from the
2848
	  cellular phone, and a new object, the business card, is
2848
	  cellular phone, and a new object, the business card, is
2849
	  pushed into the phone's directory.</para>
2849
	  pushed into the phone's directory.</para>
2850
2850
2851
	<screen>&prompt.user; <userinput>obexapp -a 00:80:37:29:19:a4 -C IrMC</userinput>
2851
	<screen>&prompt.user; <userinput>obexapp -a 00:80:37:29:19:a4 -C IrMC</userinput>
2852
obex&gt; get telecom/devinfo.txt devinfo-t39.txt
2852
obex&gt; get telecom/devinfo.txt devinfo-t39.txt
2853
Success, response: OK, Success (0x20)
2853
Success, response: OK, Success (0x20)
2854
obex&gt; put new.vcf
2854
obex&gt; put new.vcf
2855
Success, response: OK, Success (0x20)
2855
Success, response: OK, Success (0x20)
2856
obex&gt; di
2856
obex&gt; di
2857
Success, response: OK, Success (0x20)</screen>
2857
Success, response: OK, Success (0x20)</screen>
2858
2858
2859
	<para>In order to provide the <acronym>OPUSH</acronym>
2859
	<para>In order to provide the <acronym>OPUSH</acronym>
2860
	  service, &man.sdpd.8; must be running and a root folder,
2860
	  service, &man.sdpd.8; must be running and a root folder,
2861
	  where all incoming objects will be stored, must be created.
2861
	  where all incoming objects will be stored, must be created.
2862
	  The default path to the root folder is
2862
	  The default path to the root folder is
2863
	  <filename>/var/spool/obex</filename>.  Finally, start the
2863
	  <filename>/var/spool/obex</filename>.  Finally, start the
2864
	  <acronym>OBEX</acronym> server on a valid
2864
	  <acronym>OBEX</acronym> server on a valid
2865
	  <acronym>RFCOMM</acronym> channel number.  The
2865
	  <acronym>RFCOMM</acronym> channel number.  The
2866
	  <acronym>OBEX</acronym> server will automatically register
2866
	  <acronym>OBEX</acronym> server will automatically register
2867
	  the <acronym>OPUSH</acronym> service with the local
2867
	  the <acronym>OPUSH</acronym> service with the local
2868
	  <acronym>SDP</acronym> daemon.  The example below shows how
2868
	  <acronym>SDP</acronym> daemon.  The example below shows how
2869
	  to start the <acronym>OBEX</acronym> server.</para>
2869
	  to start the <acronym>OBEX</acronym> server.</para>
2870
2870
2871
	<screen>&prompt.root; <userinput>obexapp -s -C 10</userinput></screen>
2871
	<screen>&prompt.root; <userinput>obexapp -s -C 10</userinput></screen>
2872
      </sect3>
2872
      </sect3>
2873
2873
2874
      <sect3>
2874
      <sect3>
2875
	<title>Serial Port Profile (<acronym>SPP</acronym>)</title>
2875
	<title>Serial Port Profile (<acronym>SPP</acronym>)</title>
2876
2876
2877
	<para>The Serial Port Profile (<acronym>SPP</acronym>) allows
2877
	<para>The Serial Port Profile (<acronym>SPP</acronym>) allows
2878
	  Bluetooth devices to perform serial cable emulation.  This
2878
	  Bluetooth devices to perform serial cable emulation.  This
2879
	  profile allows legacy applications to use Bluetooth as a
2879
	  profile allows legacy applications to use Bluetooth as a
2880
	  cable replacement, through a virtual serial port
2880
	  cable replacement, through a virtual serial port
2881
	  abstraction.</para>
2881
	  abstraction.</para>
2882
2882
2883
	<para>In &os;, &man.rfcomm.sppd.1; implements
2883
	<para>In &os;, &man.rfcomm.sppd.1; implements
2884
	  <acronym>SPP</acronym> and a pseudo tty is used as a virtual
2884
	  <acronym>SPP</acronym> and a pseudo tty is used as a virtual
2885
	  serial port abstraction.  The example below shows how to
2885
	  serial port abstraction.  The example below shows how to
2886
	  connect to a remote device's serial port service.  A
2886
	  connect to a remote device's serial port service.  A
2887
	  <acronym>RFCOMM</acronym> channel does not have to be
2887
	  <acronym>RFCOMM</acronym> channel does not have to be
2888
	  specified as &man.rfcomm.sppd.1; can obtain it from the
2888
	  specified as &man.rfcomm.sppd.1; can obtain it from the
2889
	  remote device via <acronym>SDP</acronym>.  To override this,
2889
	  remote device via <acronym>SDP</acronym>.  To override this,
2890
	  specify a <acronym>RFCOMM</acronym> channel on the command
2890
	  specify a <acronym>RFCOMM</acronym> channel on the command
2891
	  line.</para>
2891
	  line.</para>
2892
2892
2893
	<screen>&prompt.root; <userinput>rfcomm_sppd -a 00:07:E0:00:0B:CA -t</userinput>
2893
	<screen>&prompt.root; <userinput>rfcomm_sppd -a 00:07:E0:00:0B:CA -t</userinput>
2894
rfcomm_sppd[94692]: Starting on /dev/pts/6...
2894
rfcomm_sppd[94692]: Starting on /dev/pts/6...
2895
/dev/pts/6</screen>
2895
/dev/pts/6</screen>
2896
2896
2897
	<para>Once connected, the pseudo tty can be used as serial
2897
	<para>Once connected, the pseudo tty can be used as serial
2898
	  port:</para>
2898
	  port:</para>
2899
2899
2900
	<screen>&prompt.root; <userinput>cu -l /dev/pts/6</userinput></screen>
2900
	<screen>&prompt.root; <userinput>cu -l /dev/pts/6</userinput></screen>
2901
2901
2902
	<para>The pseudo tty is printed on stdout and can be read by
2902
	<para>The pseudo tty is printed on stdout and can be read by
2903
	  wrapper scripts:</para>
2903
	  wrapper scripts:</para>
2904
2904
2905
	<programlisting>PTS=`rfcomm_sppd -a 00:07:E0:00:0B:CA -t`
2905
	<programlisting>PTS=`rfcomm_sppd -a 00:07:E0:00:0B:CA -t`
2906
cu -l $PTS</programlisting>
2906
cu -l $PTS</programlisting>
2907
      </sect3>
2907
      </sect3>
2908
    </sect2>
2908
    </sect2>
2909
2909
2910
    <sect2>
2910
    <sect2>
2911
      <title>Troubleshooting</title>
2911
      <title>Troubleshooting</title>
2912
2912
2913
      <para>By default, when &os; is accepting a new connection, it
2913
      <para>By default, when &os; is accepting a new connection, it
2914
	tries to perform a role switch and become master.  Some older
2914
	tries to perform a role switch and become master.  Some older
2915
	Bluetooth devices which do not support role switching will not
2915
	Bluetooth devices which do not support role switching will not
2916
	be able to connect.  Since role switching is performed when a
2916
	be able to connect.  Since role switching is performed when a
2917
	new connection is being established, it is not possible to ask
2917
	new connection is being established, it is not possible to ask
2918
	the remote device if it supports role switching.  However,
2918
	the remote device if it supports role switching.  However,
2919
	there is a <acronym>HCI</acronym> option to disable role
2919
	there is a <acronym>HCI</acronym> option to disable role
2920
	switching on the local side:</para>
2920
	switching on the local side:</para>
2921
2921
2922
      <screen>&prompt.root; <userinput>hccontrol -n ubt0hci write_node_role_switch 0</userinput></screen>
2922
      <screen>&prompt.root; <userinput>hccontrol -n ubt0hci write_node_role_switch 0</userinput></screen>
2923
2923
2924
      <para>To display Bluetooth packets, use the third-party package
2924
      <para>To display Bluetooth packets, use the third-party package
2925
	<application>hcidump</application>, which can be installed
2925
	<application>hcidump</application>, which can be installed
2926
	using the <package>comms/hcidump</package> package or port.
2926
	using the <package>comms/hcidump</package> package or port.
2927
	This utility is similar to &man.tcpdump.1; and can be used to
2927
	This utility is similar to &man.tcpdump.1; and can be used to
2928
	display the contents of Bluetooth packets on the terminal and
2928
	display the contents of Bluetooth packets on the terminal and
2929
	to dump the Bluetooth packets to a file.</para>
2929
	to dump the Bluetooth packets to a file.</para>
2930
    </sect2>
2930
    </sect2>
2931
  </sect1>
2931
  </sect1>
2932
2932
2933
  <sect1 xml:id="network-bridging">
2933
  <sect1 xml:id="network-bridging">
2934
    <info>
2934
    <info>
2935
      <title>Bridging</title>
2935
      <title>Bridging</title>
2936
2936
2937
      <authorgroup>
2937
      <authorgroup>
2938
	<author>
2938
	<author>
2939
	  <personname>
2939
	  <personname>
2940
	    <firstname>Andrew</firstname>
2940
	    <firstname>Andrew</firstname>
2941
	    <surname>Thompson</surname>
2941
	    <surname>Thompson</surname>
2942
	  </personname>
2942
	  </personname>
2943
	  <contrib>Written by </contrib>
2943
	  <contrib>Written by </contrib>
2944
	</author>
2944
	</author>
2945
      </authorgroup>
2945
      </authorgroup>
2946
    </info>
2946
    </info>
2947
2947
2948
    <indexterm>
2948
    <indexterm>
2949
      <primary><acronym>IP</acronym> subnet</primary>
2949
      <primary><acronym>IP</acronym> subnet</primary>
2950
    </indexterm>
2950
    </indexterm>
2951
    <indexterm>
2951
    <indexterm>
2952
      <primary>bridge</primary>
2952
      <primary>bridge</primary>
2953
    </indexterm>
2953
    </indexterm>
2954
2954
2955
    <para>It is sometimes useful to divide a network, such as an
2955
    <para>It is sometimes useful to divide a network, such as an
2956
      Ethernet segment, into network segments without having to
2956
      Ethernet segment, into network segments without having to
2957
      create <acronym>IP</acronym> subnets and use a router to connect
2957
      create <acronym>IP</acronym> subnets and use a router to connect
2958
      the segments together.  A device that connects two networks
2958
      the segments together.  A device that connects two networks
2959
      together in this fashion is called a
2959
      together in this fashion is called a
2960
      <quote>bridge</quote>.</para>
2960
      <quote>bridge</quote>.</para>
2961
2961
2962
    <para>A bridge works by learning the <acronym>MAC</acronym>
2962
    <para>A bridge works by learning the <acronym>MAC</acronym>
2963
      addresses of the devices on each of its network interfaces.  It
2963
      addresses of the devices on each of its network interfaces.  It
2964
      forwards traffic between networks only when the source and
2964
      forwards traffic between networks only when the source and
2965
      destination <acronym>MAC</acronym> addresses are on different
2965
      destination <acronym>MAC</acronym> addresses are on different
2966
      networks.  In many respects, a bridge is like an Ethernet switch
2966
      networks.  In many respects, a bridge is like an Ethernet switch
2967
      with very few ports.    A &os; system with multiple network
2967
      with very few ports.    A &os; system with multiple network
2968
      interfaces can be configured to act as a bridge.</para>
2968
      interfaces can be configured to act as a bridge.</para>
2969
2969
2970
    <para>Bridging can be useful in the following situations:</para>
2970
    <para>Bridging can be useful in the following situations:</para>
2971
2971
2972
    <variablelist>
2972
    <variablelist>
2973
      <varlistentry>
2973
      <varlistentry>
2974
	<term>Connecting Networks</term>
2974
	<term>Connecting Networks</term>
2975
	<listitem>
2975
	<listitem>
2976
	  <para>The basic operation of a bridge is to join two or more
2976
	  <para>The basic operation of a bridge is to join two or more
2977
	    network segments.  There are many reasons to use a
2977
	    network segments.  There are many reasons to use a
2978
	    host-based bridge instead of networking equipment, such as
2978
	    host-based bridge instead of networking equipment, such as
2979
	    cabling constraints or firewalling.  A bridge can also
2979
	    cabling constraints or firewalling.  A bridge can also
2980
	    connect a wireless interface running in hostap mode to a
2980
	    connect a wireless interface running in hostap mode to a
2981
	    wired network and act as an access point.</para>
2981
	    wired network and act as an access point.</para>
2982
	</listitem>
2982
	</listitem>
2983
      </varlistentry>
2983
      </varlistentry>
2984
2984
2985
      <varlistentry>
2985
      <varlistentry>
2986
	<term>Filtering/Traffic Shaping Firewall</term>
2986
	<term>Filtering/Traffic Shaping Firewall</term>
2987
	<listitem>
2987
	<listitem>
2988
	  <para>A bridge can be used when firewall functionality is
2988
	  <para>A bridge can be used when firewall functionality is
2989
	    needed without routing or Network Address Translation
2989
	    needed without routing or Network Address Translation
2990
	    (<acronym>NAT</acronym>).</para>
2990
	    (<acronym>NAT</acronym>).</para>
2991
2991
2992
	  <para>An example is a small company that is connected via
2992
	  <para>An example is a small company that is connected via
2993
	    <acronym>DSL</acronym> or <acronym>ISDN</acronym> to an
2993
	    <acronym>DSL</acronym> or <acronym>ISDN</acronym> to an
2994
	    <acronym>ISP</acronym>.  There are thirteen public
2994
	    <acronym>ISP</acronym>.  There are thirteen public
2995
	    <acronym>IP</acronym> addresses from the
2995
	    <acronym>IP</acronym> addresses from the
2996
	    <acronym>ISP</acronym> and ten computers on the network.
2996
	    <acronym>ISP</acronym> and ten computers on the network.
2997
	    In this situation, using a router-based firewall is
2997
	    In this situation, using a router-based firewall is
2998
	    difficult because of subnetting issues.  A bridge-based
2998
	    difficult because of subnetting issues.  A bridge-based
2999
	    firewall can be configured without any
2999
	    firewall can be configured without any
3000
	    <acronym>IP</acronym> addressing issues.</para>
3000
	    <acronym>IP</acronym> addressing issues.</para>
3001
	</listitem>
3001
	</listitem>
3002
      </varlistentry>
3002
      </varlistentry>
3003
3003
3004
      <varlistentry>
3004
      <varlistentry>
3005
	<term>Network Tap</term>
3005
	<term>Network Tap</term>
3006
	<listitem>
3006
	<listitem>
3007
	  <para>A bridge can join two network segments in order to
3007
	  <para>A bridge can join two network segments in order to
3008
	    inspect all Ethernet frames that pass between them using
3008
	    inspect all Ethernet frames that pass between them using
3009
	    &man.bpf.4; and &man.tcpdump.1; on the bridge interface or
3009
	    &man.bpf.4; and &man.tcpdump.1; on the bridge interface or
3010
	    by sending a copy of all frames out an additional
3010
	    by sending a copy of all frames out an additional
3011
	    interface known as a span port.</para>
3011
	    interface known as a span port.</para>
3012
	</listitem>
3012
	</listitem>
3013
      </varlistentry>
3013
      </varlistentry>
3014
3014
3015
      <varlistentry>
3015
      <varlistentry>
3016
	<term>Layer 2 <acronym>VPN</acronym></term>
3016
	<term>Layer 2 <acronym>VPN</acronym></term>
3017
	<listitem>
3017
	<listitem>
3018
	  <para>Two Ethernet networks can be joined across an
3018
	  <para>Two Ethernet networks can be joined across an
3019
	    <acronym>IP</acronym> link by bridging the networks to an
3019
	    <acronym>IP</acronym> link by bridging the networks to an
3020
	    EtherIP tunnel or a &man.tap.4; based solution such as
3020
	    EtherIP tunnel or a &man.tap.4; based solution such as
3021
	    <application>OpenVPN</application>.</para>
3021
	    <application>OpenVPN</application>.</para>
3022
	</listitem>
3022
	</listitem>
3023
      </varlistentry>
3023
      </varlistentry>
3024
3024
3025
      <varlistentry>
3025
      <varlistentry>
3026
	<term>Layer 2 Redundancy</term>
3026
	<term>Layer 2 Redundancy</term>
3027
	<listitem>
3027
	<listitem>
3028
	  <para>A network can be connected together with multiple
3028
	  <para>A network can be connected together with multiple
3029
	    links and use the Spanning Tree Protocol
3029
	    links and use the Spanning Tree Protocol
3030
	    (<acronym>STP</acronym>) to block redundant paths.</para>
3030
	    (<acronym>STP</acronym>) to block redundant paths.</para>
3031
	</listitem>
3031
	</listitem>
3032
      </varlistentry>
3032
      </varlistentry>
3033
    </variablelist>
3033
    </variablelist>
3034
3034
3035
    <para>This section describes how to configure a &os; system as a
3035
    <para>This section describes how to configure a &os; system as a
3036
      bridge using &man.if.bridge.4;.  A netgraph bridging driver is
3036
      bridge using &man.if.bridge.4;.  A netgraph bridging driver is
3037
      also available, and is described in &man.ng.bridge.4;.</para>
3037
      also available, and is described in &man.ng.bridge.4;.</para>
3038
3038
3039
    <note>
3039
    <note>
3040
      <para>Packet filtering can be used with any firewall package
3040
      <para>Packet filtering can be used with any firewall package
3041
	that hooks into the &man.pfil.9; framework.  The bridge can be
3041
	that hooks into the &man.pfil.9; framework.  The bridge can be
3042
	used as a traffic shaper with &man.altq.4; or
3042
	used as a traffic shaper with &man.altq.4; or
3043
	&man.dummynet.4;.</para>
3043
	&man.dummynet.4;.</para>
3044
    </note>
3044
    </note>
3045
3045
3046
    <sect2>
3046
    <sect2>
3047
      <title>Enabling the Bridge</title>
3047
      <title>Enabling the Bridge</title>
3048
3048
3049
      <para>In &os;, &man.if.bridge.4; is a kernel module which is
3049
      <para>In &os;, &man.if.bridge.4; is a kernel module which is
3050
	automatically loaded by &man.ifconfig.8; when creating a
3050
	automatically loaded by &man.ifconfig.8; when creating a
3051
	bridge interface.  It is also possible to compile bridge
3051
	bridge interface.  It is also possible to compile bridge
3052
	support into a custom kernel by adding
3052
	support into a custom kernel by adding
3053
	<literal>device if_bridge</literal> to the custom kernel
3053
	<literal>device if_bridge</literal> to the custom kernel
3054
	configuration file.</para>
3054
	configuration file.</para>
3055
3055
3056
      <para>The bridge is created using interface cloning.  To create
3056
      <para>The bridge is created using interface cloning.  To create
3057
	the bridge interface:</para>
3057
	the bridge interface:</para>
3058
3058
3059
      <screen>&prompt.root; <userinput>ifconfig bridge create</userinput>
3059
      <screen>&prompt.root; <userinput>ifconfig bridge create</userinput>
3060
bridge0
3060
bridge0
3061
&prompt.root; <userinput>ifconfig bridge0</userinput>
3061
&prompt.root; <userinput>ifconfig bridge0</userinput>
3062
bridge0: flags=8802&lt;BROADCAST,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3062
bridge0: flags=8802&lt;BROADCAST,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3063
        ether 96:3d:4b:f1:79:7a
3063
        ether 96:3d:4b:f1:79:7a
3064
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
3064
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
3065
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
3065
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
3066
        root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0</screen>
3066
        root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0</screen>
3067
3067
3068
      <para>When a bridge interface is created, it is automatically
3068
      <para>When a bridge interface is created, it is automatically
3069
	assigned a randomly generated Ethernet address.  The
3069
	assigned a randomly generated Ethernet address.  The
3070
	<literal>maxaddr</literal> and <literal>timeout</literal>
3070
	<literal>maxaddr</literal> and <literal>timeout</literal>
3071
	parameters control how many <acronym>MAC</acronym> addresses
3071
	parameters control how many <acronym>MAC</acronym> addresses
3072
	the bridge will keep in its forwarding table and how many
3072
	the bridge will keep in its forwarding table and how many
3073
	seconds before each entry is removed after it is last seen.
3073
	seconds before each entry is removed after it is last seen.
3074
	The other parameters control how <acronym>STP</acronym>
3074
	The other parameters control how <acronym>STP</acronym>
3075
	operates.</para>
3075
	operates.</para>
3076
3076
3077
      <para>Next, specify which network interfaces to add as members
3077
      <para>Next, specify which network interfaces to add as members
3078
	of the bridge.  For the bridge to forward packets, all member
3078
	of the bridge.  For the bridge to forward packets, all member
3079
	interfaces and the bridge need to be up:</para>
3079
	interfaces and the bridge need to be up:</para>
3080
3080
3081
      <screen>&prompt.root; <userinput>ifconfig bridge0 addm fxp0 addm fxp1 up</userinput>
3081
      <screen>&prompt.root; <userinput>ifconfig bridge0 addm fxp0 addm fxp1 up</userinput>
3082
&prompt.root; <userinput>ifconfig fxp0 up</userinput>
3082
&prompt.root; <userinput>ifconfig fxp0 up</userinput>
3083
&prompt.root; <userinput>ifconfig fxp1 up</userinput></screen>
3083
&prompt.root; <userinput>ifconfig fxp1 up</userinput></screen>
3084
3084
3085
      <para>The bridge can now forward Ethernet frames between
3085
      <para>The bridge can now forward Ethernet frames between
3086
	<filename>fxp0</filename> and <filename>fxp1</filename>.  Add
3086
	<filename>fxp0</filename> and <filename>fxp1</filename>.  Add
3087
	the following lines to <filename>/etc/rc.conf</filename> so
3087
	the following lines to <filename>/etc/rc.conf</filename> so
3088
	the bridge is created at startup:</para>
3088
	the bridge is created at startup:</para>
3089
3089
3090
      <programlisting>cloned_interfaces="bridge0"
3090
      <programlisting>cloned_interfaces="bridge0"
3091
ifconfig_bridge0="addm fxp0 addm fxp1 up"
3091
ifconfig_bridge0="addm fxp0 addm fxp1 up"
3092
ifconfig_fxp0="up"
3092
ifconfig_fxp0="up"
3093
ifconfig_fxp1="up"</programlisting>
3093
ifconfig_fxp1="up"</programlisting>
3094
3094
3095
      <para>If the bridge host needs an <acronym>IP</acronym>
3095
      <para>If the bridge host needs an <acronym>IP</acronym>
3096
	address, set it on the bridge interface, not on the member
3096
	address, set it on the bridge interface, not on the member
3097
	interfaces.  The address can be set statically or via
3097
	interfaces.  The address can be set statically or via
3098
	<acronym>DHCP</acronym>.  This example sets a static
3098
	<acronym>DHCP</acronym>.  This example sets a static
3099
	<acronym>IP</acronym> address:</para>
3099
	<acronym>IP</acronym> address:</para>
3100
3100
3101
      <screen>&prompt.root; <userinput>ifconfig bridge0 inet 192.168.0.1/24</userinput></screen>
3101
      <screen>&prompt.root; <userinput>ifconfig bridge0 inet 192.168.0.1/24</userinput></screen>
3102
3102
3103
      <para>It is also possible to assign an <acronym>IPv6</acronym>
3103
      <para>It is also possible to assign an <acronym>IPv6</acronym>
3104
	address to a bridge interface.  To make the changes permanent,
3104
	address to a bridge interface.  To make the changes permanent,
3105
	add the addressing information to
3105
	add the addressing information to
3106
	<filename>/etc/rc.conf</filename>.</para>
3106
	<filename>/etc/rc.conf</filename>.</para>
3107
3107
3108
      <note>
3108
      <note>
3109
	<para>When packet filtering is enabled, bridged packets will
3109
	<para>When packet filtering is enabled, bridged packets will
3110
	  pass through the filter inbound on the originating interface
3110
	  pass through the filter inbound on the originating interface
3111
	  on the bridge interface, and outbound on the appropriate
3111
	  on the bridge interface, and outbound on the appropriate
3112
	  interfaces.  Either stage can be disabled.  When direction
3112
	  interfaces.  Either stage can be disabled.  When direction
3113
	  of the packet flow is important, it is best to firewall on
3113
	  of the packet flow is important, it is best to firewall on
3114
	  the member interfaces rather than the bridge itself.</para>
3114
	  the member interfaces rather than the bridge itself.</para>
3115
3115
3116
	<para>The bridge has several configurable settings for passing
3116
	<para>The bridge has several configurable settings for passing
3117
	  non-<acronym>IP</acronym> and <acronym>IP</acronym> packets,
3117
	  non-<acronym>IP</acronym> and <acronym>IP</acronym> packets,
3118
	  and layer2 firewalling with &man.ipfw.8;.  See
3118
	  and layer2 firewalling with &man.ipfw.8;.  See
3119
	  &man.if.bridge.4; for more information.</para>
3119
	  &man.if.bridge.4; for more information.</para>
3120
      </note>
3120
      </note>
3121
    </sect2>
3121
    </sect2>
3122
3122
3123
    <sect2>
3123
    <sect2>
3124
      <title>Enabling Spanning Tree</title>
3124
      <title>Enabling Spanning Tree</title>
3125
3125
3126
      <para>For an Ethernet network to function properly, only one
3126
      <para>For an Ethernet network to function properly, only one
3127
	active path can exist between two devices.  The
3127
	active path can exist between two devices.  The
3128
	<acronym>STP</acronym> protocol detects loops and puts
3128
	<acronym>STP</acronym> protocol detects loops and puts
3129
	redundant links into a blocked state.  Should one of the
3129
	redundant links into a blocked state.  Should one of the
3130
	active links fail, <acronym>STP</acronym> calculates a
3130
	active links fail, <acronym>STP</acronym> calculates a
3131
	different tree and enables one of the blocked paths to restore
3131
	different tree and enables one of the blocked paths to restore
3132
	connectivity to all points in the network.</para>
3132
	connectivity to all points in the network.</para>
3133
3133
3134
      <para>The Rapid Spanning Tree Protocol (<acronym>RSTP</acronym>
3134
      <para>The Rapid Spanning Tree Protocol (<acronym>RSTP</acronym>
3135
	or 802.1w) provides backwards compatibility with legacy
3135
	or 802.1w) provides backwards compatibility with legacy
3136
	<acronym>STP</acronym>.  <acronym>RSTP</acronym> provides
3136
	<acronym>STP</acronym>.  <acronym>RSTP</acronym> provides
3137
	faster convergence and exchanges information with neighboring
3137
	faster convergence and exchanges information with neighboring
3138
	switches to quickly transition to forwarding mode without
3138
	switches to quickly transition to forwarding mode without
3139
	creating loops.  &os; supports <acronym>RSTP</acronym> and
3139
	creating loops.  &os; supports <acronym>RSTP</acronym> and
3140
	<acronym>STP</acronym> as operating modes, with
3140
	<acronym>STP</acronym> as operating modes, with
3141
	<acronym>RSTP</acronym> being the default mode.</para>
3141
	<acronym>RSTP</acronym> being the default mode.</para>
3142
3142
3143
      <para><acronym>STP</acronym> can be enabled on member interfaces
3143
      <para><acronym>STP</acronym> can be enabled on member interfaces
3144
	using &man.ifconfig.8;.  For a bridge with
3144
	using &man.ifconfig.8;.  For a bridge with
3145
	<filename>fxp0</filename> and <filename>fxp1</filename> as the
3145
	<filename>fxp0</filename> and <filename>fxp1</filename> as the
3146
	current interfaces, enable <acronym>STP</acronym> with:</para>
3146
	current interfaces, enable <acronym>STP</acronym> with:</para>
3147
3147
3148
      <screen>&prompt.root; <userinput>ifconfig bridge0 stp fxp0 stp fxp1</userinput>
3148
      <screen>&prompt.root; <userinput>ifconfig bridge0 stp fxp0 stp fxp1</userinput>
3149
bridge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3149
bridge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3150
        ether d6:cf:d5:a0:94:6d
3150
        ether d6:cf:d5:a0:94:6d
3151
        id 00:01:02:4b:d4:50 priority 32768 hellotime 2 fwddelay 15
3151
        id 00:01:02:4b:d4:50 priority 32768 hellotime 2 fwddelay 15
3152
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
3152
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
3153
        root id 00:01:02:4b:d4:50 priority 32768 ifcost 0 port 0
3153
        root id 00:01:02:4b:d4:50 priority 32768 ifcost 0 port 0
3154
        member: fxp0 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3154
        member: fxp0 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3155
                port 3 priority 128 path cost 200000 proto rstp
3155
                port 3 priority 128 path cost 200000 proto rstp
3156
                role designated state forwarding
3156
                role designated state forwarding
3157
        member: fxp1 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3157
        member: fxp1 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3158
                port 4 priority 128 path cost 200000 proto rstp
3158
                port 4 priority 128 path cost 200000 proto rstp
3159
                role designated state forwarding</screen>
3159
                role designated state forwarding</screen>
3160
3160
3161
      <para>This bridge has a spanning tree ID of
3161
      <para>This bridge has a spanning tree ID of
3162
	<literal>00:01:02:4b:d4:50</literal> and a priority of
3162
	<literal>00:01:02:4b:d4:50</literal> and a priority of
3163
	<literal>32768</literal>.  As the <literal>root id</literal>
3163
	<literal>32768</literal>.  As the <literal>root id</literal>
3164
	is the same, it indicates that this is the root bridge for the
3164
	is the same, it indicates that this is the root bridge for the
3165
	tree.</para>
3165
	tree.</para>
3166
3166
3167
      <para>Another bridge on the network also has
3167
      <para>Another bridge on the network also has
3168
	<acronym>STP</acronym> enabled:</para>
3168
	<acronym>STP</acronym> enabled:</para>
3169
3169
3170
      <screen>bridge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3170
      <screen>bridge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3171
        ether 96:3d:4b:f1:79:7a
3171
        ether 96:3d:4b:f1:79:7a
3172
        id 00:13:d4:9a:06:7a priority 32768 hellotime 2 fwddelay 15
3172
        id 00:13:d4:9a:06:7a priority 32768 hellotime 2 fwddelay 15
3173
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
3173
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
3174
        root id 00:01:02:4b:d4:50 priority 32768 ifcost 400000 port 4
3174
        root id 00:01:02:4b:d4:50 priority 32768 ifcost 400000 port 4
3175
        member: fxp0 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3175
        member: fxp0 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3176
                port 4 priority 128 path cost 200000 proto rstp
3176
                port 4 priority 128 path cost 200000 proto rstp
3177
                role root state forwarding
3177
                role root state forwarding
3178
        member: fxp1 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3178
        member: fxp1 flags=1c7&lt;LEARNING,DISCOVER,STP,AUTOEDGE,PTP,AUTOPTP&gt;
3179
                port 5 priority 128 path cost 200000 proto rstp
3179
                port 5 priority 128 path cost 200000 proto rstp
3180
                role designated state forwarding</screen>
3180
                role designated state forwarding</screen>
3181
3181
3182
      <para>The line <literal>root id 00:01:02:4b:d4:50 priority 32768
3182
      <para>The line <literal>root id 00:01:02:4b:d4:50 priority 32768
3183
	  ifcost 400000 port 4</literal> shows that the root bridge is
3183
	  ifcost 400000 port 4</literal> shows that the root bridge is
3184
	<literal>00:01:02:4b:d4:50</literal> and has a path cost of
3184
	<literal>00:01:02:4b:d4:50</literal> and has a path cost of
3185
	<literal>400000</literal> from this bridge.  The path to the
3185
	<literal>400000</literal> from this bridge.  The path to the
3186
	root bridge is via <literal>port 4</literal> which is
3186
	root bridge is via <literal>port 4</literal> which is
3187
	<filename>fxp0</filename>.</para>
3187
	<filename>fxp0</filename>.</para>
3188
    </sect2>
3188
    </sect2>
3189
3189
3190
    <sect2>
3190
    <sect2>
3191
      <title>Bridge Interface Parameters</title>
3191
      <title>Bridge Interface Parameters</title>
3192
3192
3193
      <para>Several <command>ifconfig</command> parameters are unique
3193
      <para>Several <command>ifconfig</command> parameters are unique
3194
	to bridge interfaces.  This section summarizes some common
3194
	to bridge interfaces.  This section summarizes some common
3195
	uses for these parameters.  The complete list of available
3195
	uses for these parameters.  The complete list of available
3196
	parameters is described in &man.ifconfig.8;.</para>
3196
	parameters is described in &man.ifconfig.8;.</para>
3197
3197
3198
      <variablelist>
3198
      <variablelist>
3199
	<varlistentry>
3199
	<varlistentry>
3200
	  <term>private</term>
3200
	  <term>private</term>
3201
	  <listitem>
3201
	  <listitem>
3202
	    <para>A private interface does not forward any traffic to
3202
	    <para>A private interface does not forward any traffic to
3203
	      any other port that is also designated as a private
3203
	      any other port that is also designated as a private
3204
	      interface.  The traffic is blocked unconditionally so no
3204
	      interface.  The traffic is blocked unconditionally so no
3205
	      Ethernet frames will be forwarded, including
3205
	      Ethernet frames will be forwarded, including
3206
	      <acronym>ARP</acronym> packets.  If traffic needs to be
3206
	      <acronym>ARP</acronym> packets.  If traffic needs to be
3207
	      selectively blocked, a firewall should be used
3207
	      selectively blocked, a firewall should be used
3208
	      instead.</para>
3208
	      instead.</para>
3209
	  </listitem>
3209
	  </listitem>
3210
	</varlistentry>
3210
	</varlistentry>
3211
3211
3212
	<varlistentry>
3212
	<varlistentry>
3213
	  <term>span</term>
3213
	  <term>span</term>
3214
	  <listitem>
3214
	  <listitem>
3215
	    <para>A span port transmits a copy of every Ethernet frame
3215
	    <para>A span port transmits a copy of every Ethernet frame
3216
	      received by the bridge.  The number of span ports
3216
	      received by the bridge.  The number of span ports
3217
	      configured on a bridge is unlimited, but if an
3217
	      configured on a bridge is unlimited, but if an
3218
	      interface is designated as a span port, it cannot also
3218
	      interface is designated as a span port, it cannot also
3219
	      be used as a regular bridge port.  This is most useful
3219
	      be used as a regular bridge port.  This is most useful
3220
	      for snooping a bridged network passively on another host
3220
	      for snooping a bridged network passively on another host
3221
	      connected to one of the span ports of the bridge.  For
3221
	      connected to one of the span ports of the bridge.  For
3222
	      example, to send a copy of all frames out the interface
3222
	      example, to send a copy of all frames out the interface
3223
	      named <filename>fxp4</filename>:</para>
3223
	      named <filename>fxp4</filename>:</para>
3224
3224
3225
	    <screen>&prompt.root; <userinput>ifconfig bridge0 span fxp4</userinput></screen>
3225
	    <screen>&prompt.root; <userinput>ifconfig bridge0 span fxp4</userinput></screen>
3226
	  </listitem>
3226
	  </listitem>
3227
	</varlistentry>
3227
	</varlistentry>
3228
3228
3229
	<varlistentry>
3229
	<varlistentry>
3230
	  <term>sticky</term>
3230
	  <term>sticky</term>
3231
	  <listitem>
3231
	  <listitem>
3232
	    <para>If a bridge member interface is marked as sticky,
3232
	    <para>If a bridge member interface is marked as sticky,
3233
	      dynamically learned address entries are treated as
3233
	      dynamically learned address entries are treated as
3234
	      static entries in the forwarding cache.  Sticky entries
3234
	      static entries in the forwarding cache.  Sticky entries
3235
	      are never aged out of the cache or replaced, even if the
3235
	      are never aged out of the cache or replaced, even if the
3236
	      address is seen on a different interface.  This gives
3236
	      address is seen on a different interface.  This gives
3237
	      the benefit of static address entries without the need
3237
	      the benefit of static address entries without the need
3238
	      to pre-populate the forwarding table.  Clients learned
3238
	      to pre-populate the forwarding table.  Clients learned
3239
	      on a particular segment of the bridge cannot roam to
3239
	      on a particular segment of the bridge cannot roam to
3240
	      another segment.</para>
3240
	      another segment.</para>
3241
3241
3242
	    <para>An example of using sticky addresses is to combine
3242
	    <para>An example of using sticky addresses is to combine
3243
	      the bridge with <acronym>VLAN</acronym>s in order to
3243
	      the bridge with <acronym>VLAN</acronym>s in order to
3244
	      isolate customer networks without wasting
3244
	      isolate customer networks without wasting
3245
	      <acronym>IP</acronym> address space.  Consider that
3245
	      <acronym>IP</acronym> address space.  Consider that
3246
	      <systemitem class="fqdomainname">CustomerA</systemitem>
3246
	      <systemitem class="fqdomainname">CustomerA</systemitem>
3247
	      is on <literal>vlan100</literal>, <systemitem
3247
	      is on <literal>vlan100</literal>, <systemitem
3248
		class="fqdomainname">CustomerB</systemitem> is on
3248
		class="fqdomainname">CustomerB</systemitem> is on
3249
	      <literal>vlan101</literal>, and the bridge has the
3249
	      <literal>vlan101</literal>, and the bridge has the
3250
	      address <systemitem
3250
	      address <systemitem
3251
		class="ipaddress">192.168.0.1</systemitem>:</para>
3251
		class="ipaddress">192.168.0.1</systemitem>:</para>
3252
3252
3253
	    <screen>&prompt.root; <userinput>ifconfig bridge0 addm vlan100 sticky vlan100 addm vlan101 sticky vlan101</userinput>
3253
	    <screen>&prompt.root; <userinput>ifconfig bridge0 addm vlan100 sticky vlan100 addm vlan101 sticky vlan101</userinput>
3254
&prompt.root; <userinput>ifconfig bridge0 inet 192.168.0.1/24</userinput></screen>
3254
&prompt.root; <userinput>ifconfig bridge0 inet 192.168.0.1/24</userinput></screen>
3255
3255
3256
	    <para>In this example, both clients see <systemitem
3256
	    <para>In this example, both clients see <systemitem
3257
		class="ipaddress">192.168.0.1</systemitem> as their
3257
		class="ipaddress">192.168.0.1</systemitem> as their
3258
	      default gateway.  Since the bridge cache is sticky, one
3258
	      default gateway.  Since the bridge cache is sticky, one
3259
	      host cannot spoof the <acronym>MAC</acronym> address of
3259
	      host cannot spoof the <acronym>MAC</acronym> address of
3260
	      the other customer in order to intercept their
3260
	      the other customer in order to intercept their
3261
	      traffic.</para>
3261
	      traffic.</para>
3262
3262
3263
	    <para>Any communication between the
3263
	    <para>Any communication between the
3264
	      <acronym>VLAN</acronym>s can be blocked using a firewall
3264
	      <acronym>VLAN</acronym>s can be blocked using a firewall
3265
	      or, as seen in this example, private interfaces:</para>
3265
	      or, as seen in this example, private interfaces:</para>
3266
3266
3267
	    <screen>&prompt.root; <userinput>ifconfig bridge0 private vlan100 private vlan101</userinput></screen>
3267
	    <screen>&prompt.root; <userinput>ifconfig bridge0 private vlan100 private vlan101</userinput></screen>
3268
3268
3269
	    <para>The customers are completely isolated from each
3269
	    <para>The customers are completely isolated from each
3270
	      other and the full <systemitem
3270
	      other and the full <systemitem
3271
		class="netmask">/24</systemitem> address range can be
3271
		class="netmask">/24</systemitem> address range can be
3272
	      allocated without subnetting.</para>
3272
	      allocated without subnetting.</para>
3273
3273
3274
	    <para>The number of unique source <acronym>MAC</acronym>
3274
	    <para>The number of unique source <acronym>MAC</acronym>
3275
	      addresses behind an interface can be limited.  Once the
3275
	      addresses behind an interface can be limited.  Once the
3276
	      limit is reached, packets with unknown source addresses
3276
	      limit is reached, packets with unknown source addresses
3277
	      are dropped until an existing host cache entry expires
3277
	      are dropped until an existing host cache entry expires
3278
	      or is removed.</para>
3278
	      or is removed.</para>
3279
3279
3280
	    <para>The following example sets the maximum number of
3280
	    <para>The following example sets the maximum number of
3281
	      Ethernet devices for <systemitem
3281
	      Ethernet devices for <systemitem
3282
		class="fqdomainname">CustomerA</systemitem> on
3282
		class="fqdomainname">CustomerA</systemitem> on
3283
	      <literal>vlan100</literal> to 10:</para>
3283
	      <literal>vlan100</literal> to 10:</para>
3284
3284
3285
	    <screen>&prompt.root; <userinput>ifconfig bridge0 ifmaxaddr vlan100 10</userinput></screen>
3285
	    <screen>&prompt.root; <userinput>ifconfig bridge0 ifmaxaddr vlan100 10</userinput></screen>
3286
	  </listitem>
3286
	  </listitem>
3287
	</varlistentry>
3287
	</varlistentry>
3288
      </variablelist>
3288
      </variablelist>
3289
3289
3290
      <para>Bridge interfaces also support monitor mode, where the
3290
      <para>Bridge interfaces also support monitor mode, where the
3291
	packets are discarded after &man.bpf.4; processing and are not
3291
	packets are discarded after &man.bpf.4; processing and are not
3292
	processed or forwarded further.  This can be used to
3292
	processed or forwarded further.  This can be used to
3293
	multiplex the input of two or more interfaces into a single
3293
	multiplex the input of two or more interfaces into a single
3294
	&man.bpf.4; stream.  This is useful for reconstructing the
3294
	&man.bpf.4; stream.  This is useful for reconstructing the
3295
	traffic for network taps that transmit the RX/TX signals out
3295
	traffic for network taps that transmit the RX/TX signals out
3296
	through two separate interfaces.  For example, to read the
3296
	through two separate interfaces.  For example, to read the
3297
	input from four network interfaces as one stream:</para>
3297
	input from four network interfaces as one stream:</para>
3298
3298
3299
      <screen>&prompt.root; <userinput>ifconfig bridge0 addm fxp0 addm fxp1 addm fxp2 addm fxp3 monitor up</userinput>
3299
      <screen>&prompt.root; <userinput>ifconfig bridge0 addm fxp0 addm fxp1 addm fxp2 addm fxp3 monitor up</userinput>
3300
&prompt.root; <userinput>tcpdump -i bridge0</userinput></screen>
3300
&prompt.root; <userinput>tcpdump -i bridge0</userinput></screen>
3301
    </sect2>
3301
    </sect2>
3302
3302
3303
    <sect2>
3303
    <sect2>
3304
      <title><acronym>SNMP</acronym> Monitoring</title>
3304
      <title><acronym>SNMP</acronym> Monitoring</title>
3305
3305
3306
      <para>The bridge interface and <acronym>STP</acronym>
3306
      <para>The bridge interface and <acronym>STP</acronym>
3307
	parameters can be monitored via &man.bsnmpd.1; which is
3307
	parameters can be monitored via &man.bsnmpd.1; which is
3308
	included in the &os; base system.  The exported bridge
3308
	included in the &os; base system.  The exported bridge
3309
	<acronym>MIB</acronym>s conform to <acronym>IETF</acronym>
3309
	<acronym>MIB</acronym>s conform to <acronym>IETF</acronym>
3310
	standards so any <acronym>SNMP</acronym> client or monitoring
3310
	standards so any <acronym>SNMP</acronym> client or monitoring
3311
	package can be used to retrieve the data.</para>
3311
	package can be used to retrieve the data.</para>
3312
3312
3313
      <para>To enable monitoring on the bridge, uncomment this line in
3313
      <para>To enable monitoring on the bridge, uncomment this line in
3314
	<filename>/etc/snmpd.config</filename> by removing the
3314
	<filename>/etc/snmpd.config</filename> by removing the
3315
	beginning <literal>#</literal> symbol:</para>
3315
	beginning <literal>#</literal> symbol:</para>
3316
3316
3317
      <programlisting>begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so"</programlisting>
3317
      <programlisting>begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so"</programlisting>
3318
3318
3319
      <para>Other configuration settings, such as community names and
3319
      <para>Other configuration settings, such as community names and
3320
	access lists, may need to be modified in this file.  See
3320
	access lists, may need to be modified in this file.  See
3321
	&man.bsnmpd.1; and &man.snmp.bridge.3; for more information.
3321
	&man.bsnmpd.1; and &man.snmp.bridge.3; for more information.
3322
	Once these edits are saved, add this line to
3322
	Once these edits are saved, add this line to
3323
	<filename>/etc/rc.conf</filename>:</para>
3323
	<filename>/etc/rc.conf</filename>:</para>
3324
3324
3325
      <programlisting>bsnmpd_enable="YES"</programlisting>
3325
      <programlisting>bsnmpd_enable="YES"</programlisting>
3326
3326
3327
      <para>Then, start  &man.bsnmpd.1;:</para>
3327
      <para>Then, start  &man.bsnmpd.1;:</para>
3328
3328
3329
      <screen>&prompt.root; <userinput>service bsnmpd start</userinput></screen>
3329
      <screen>&prompt.root; <userinput>service bsnmpd start</userinput></screen>
3330
3330
3331
      <para>The following examples use the
3331
      <para>The following examples use the
3332
	<application>Net-SNMP</application> software
3332
	<application>Net-SNMP</application> software
3333
	(<package>net-mgmt/net-snmp</package>) to query a bridge
3333
	(<package>net-mgmt/net-snmp</package>) to query a bridge
3334
	from a client system.  The
3334
	from a client system.  The
3335
	<package>net-mgmt/bsnmptools</package> port can also be used.
3335
	<package>net-mgmt/bsnmptools</package> port can also be used.
3336
	From the <acronym>SNMP</acronym> client which is running
3336
	From the <acronym>SNMP</acronym> client which is running
3337
	<application>Net-SNMP</application>, add the following lines
3337
	<application>Net-SNMP</application>, add the following lines
3338
	to <filename>$HOME/.snmp/snmp.conf</filename> in order to
3338
	to <filename>$HOME/.snmp/snmp.conf</filename> in order to
3339
	import the bridge <acronym>MIB</acronym> definitions:</para>
3339
	import the bridge <acronym>MIB</acronym> definitions:</para>
3340
3340
3341
      <programlisting>mibdirs +/usr/share/snmp/mibs
3341
      <programlisting>mibdirs +/usr/share/snmp/mibs
3342
mibs +BRIDGE-MIB:RSTP-MIB:BEGEMOT-MIB:BEGEMOT-BRIDGE-MIB</programlisting>
3342
mibs +BRIDGE-MIB:RSTP-MIB:BEGEMOT-MIB:BEGEMOT-BRIDGE-MIB</programlisting>
3343
3343
3344
      <para>To monitor a single bridge using the IETF BRIDGE-MIB
3344
      <para>To monitor a single bridge using the IETF BRIDGE-MIB
3345
	(RFC4188):</para>
3345
	(RFC4188):</para>
3346
3346
3347
      <screen>&prompt.user; <userinput>snmpwalk -v 2c -c public bridge1.example.com mib-2.dot1dBridge</userinput>
3347
      <screen>&prompt.user; <userinput>snmpwalk -v 2c -c public bridge1.example.com mib-2.dot1dBridge</userinput>
3348
BRIDGE-MIB::dot1dBaseBridgeAddress.0 = STRING: 66:fb:9b:6e:5c:44
3348
BRIDGE-MIB::dot1dBaseBridgeAddress.0 = STRING: 66:fb:9b:6e:5c:44
3349
BRIDGE-MIB::dot1dBaseNumPorts.0 = INTEGER: 1 ports
3349
BRIDGE-MIB::dot1dBaseNumPorts.0 = INTEGER: 1 ports
3350
BRIDGE-MIB::dot1dStpTimeSinceTopologyChange.0 = Timeticks: (189959) 0:31:39.59 centi-seconds
3350
BRIDGE-MIB::dot1dStpTimeSinceTopologyChange.0 = Timeticks: (189959) 0:31:39.59 centi-seconds
3351
BRIDGE-MIB::dot1dStpTopChanges.0 = Counter32: 2
3351
BRIDGE-MIB::dot1dStpTopChanges.0 = Counter32: 2
3352
BRIDGE-MIB::dot1dStpDesignatedRoot.0 = Hex-STRING: 80 00 00 01 02 4B D4 50
3352
BRIDGE-MIB::dot1dStpDesignatedRoot.0 = Hex-STRING: 80 00 00 01 02 4B D4 50
3353
...
3353
...
3354
BRIDGE-MIB::dot1dStpPortState.3 = INTEGER: forwarding(5)
3354
BRIDGE-MIB::dot1dStpPortState.3 = INTEGER: forwarding(5)
3355
BRIDGE-MIB::dot1dStpPortEnable.3 = INTEGER: enabled(1)
3355
BRIDGE-MIB::dot1dStpPortEnable.3 = INTEGER: enabled(1)
3356
BRIDGE-MIB::dot1dStpPortPathCost.3 = INTEGER: 200000
3356
BRIDGE-MIB::dot1dStpPortPathCost.3 = INTEGER: 200000
3357
BRIDGE-MIB::dot1dStpPortDesignatedRoot.3 = Hex-STRING: 80 00 00 01 02 4B D4 50
3357
BRIDGE-MIB::dot1dStpPortDesignatedRoot.3 = Hex-STRING: 80 00 00 01 02 4B D4 50
3358
BRIDGE-MIB::dot1dStpPortDesignatedCost.3 = INTEGER: 0
3358
BRIDGE-MIB::dot1dStpPortDesignatedCost.3 = INTEGER: 0
3359
BRIDGE-MIB::dot1dStpPortDesignatedBridge.3 = Hex-STRING: 80 00 00 01 02 4B D4 50
3359
BRIDGE-MIB::dot1dStpPortDesignatedBridge.3 = Hex-STRING: 80 00 00 01 02 4B D4 50
3360
BRIDGE-MIB::dot1dStpPortDesignatedPort.3 = Hex-STRING: 03 80
3360
BRIDGE-MIB::dot1dStpPortDesignatedPort.3 = Hex-STRING: 03 80
3361
BRIDGE-MIB::dot1dStpPortForwardTransitions.3 = Counter32: 1
3361
BRIDGE-MIB::dot1dStpPortForwardTransitions.3 = Counter32: 1
3362
RSTP-MIB::dot1dStpVersion.0 = INTEGER: rstp(2)</screen>
3362
RSTP-MIB::dot1dStpVersion.0 = INTEGER: rstp(2)</screen>
3363
3363
3364
      <para>The <literal>dot1dStpTopChanges.0</literal> value is two,
3364
      <para>The <literal>dot1dStpTopChanges.0</literal> value is two,
3365
	indicating that the <acronym>STP</acronym> bridge topology has
3365
	indicating that the <acronym>STP</acronym> bridge topology has
3366
	changed twice.  A topology change means that one or more links
3366
	changed twice.  A topology change means that one or more links
3367
	in the network have changed or failed and a new tree has been
3367
	in the network have changed or failed and a new tree has been
3368
	calculated.  The
3368
	calculated.  The
3369
	<literal>dot1dStpTimeSinceTopologyChange.0</literal> value
3369
	<literal>dot1dStpTimeSinceTopologyChange.0</literal> value
3370
	will show when this happened.</para>
3370
	will show when this happened.</para>
3371
3371
3372
      <para>To monitor multiple bridge interfaces, the private
3372
      <para>To monitor multiple bridge interfaces, the private
3373
	BEGEMOT-BRIDGE-MIB can be used:</para>
3373
	BEGEMOT-BRIDGE-MIB can be used:</para>
3374
3374
3375
      <screen>&prompt.user; <userinput>snmpwalk -v 2c -c public bridge1.example.com</userinput>
3375
      <screen>&prompt.user; <userinput>snmpwalk -v 2c -c public bridge1.example.com</userinput>
3376
enterprises.fokus.begemot.begemotBridge
3376
enterprises.fokus.begemot.begemotBridge
3377
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseName."bridge0" = STRING: bridge0
3377
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseName."bridge0" = STRING: bridge0
3378
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseName."bridge2" = STRING: bridge2
3378
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseName."bridge2" = STRING: bridge2
3379
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseAddress."bridge0" = STRING: e:ce:3b:5a:9e:13
3379
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseAddress."bridge0" = STRING: e:ce:3b:5a:9e:13
3380
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseAddress."bridge2" = STRING: 12:5e:4d:74:d:fc
3380
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseAddress."bridge2" = STRING: 12:5e:4d:74:d:fc
3381
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseNumPorts."bridge0" = INTEGER: 1
3381
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseNumPorts."bridge0" = INTEGER: 1
3382
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseNumPorts."bridge2" = INTEGER: 1
3382
BEGEMOT-BRIDGE-MIB::begemotBridgeBaseNumPorts."bridge2" = INTEGER: 1
3383
...
3383
...
3384
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTimeSinceTopologyChange."bridge0" = Timeticks: (116927) 0:19:29.27 centi-seconds
3384
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTimeSinceTopologyChange."bridge0" = Timeticks: (116927) 0:19:29.27 centi-seconds
3385
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTimeSinceTopologyChange."bridge2" = Timeticks: (82773) 0:13:47.73 centi-seconds
3385
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTimeSinceTopologyChange."bridge2" = Timeticks: (82773) 0:13:47.73 centi-seconds
3386
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTopChanges."bridge0" = Counter32: 1
3386
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTopChanges."bridge0" = Counter32: 1
3387
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTopChanges."bridge2" = Counter32: 1
3387
BEGEMOT-BRIDGE-MIB::begemotBridgeStpTopChanges."bridge2" = Counter32: 1
3388
BEGEMOT-BRIDGE-MIB::begemotBridgeStpDesignatedRoot."bridge0" = Hex-STRING: 80 00 00 40 95 30 5E 31
3388
BEGEMOT-BRIDGE-MIB::begemotBridgeStpDesignatedRoot."bridge0" = Hex-STRING: 80 00 00 40 95 30 5E 31
3389
BEGEMOT-BRIDGE-MIB::begemotBridgeStpDesignatedRoot."bridge2" = Hex-STRING: 80 00 00 50 8B B8 C6 A9</screen>
3389
BEGEMOT-BRIDGE-MIB::begemotBridgeStpDesignatedRoot."bridge2" = Hex-STRING: 80 00 00 50 8B B8 C6 A9</screen>
3390
3390
3391
      <para>To change the bridge interface being monitored via the
3391
      <para>To change the bridge interface being monitored via the
3392
	<literal>mib-2.dot1dBridge</literal> subtree:</para>
3392
	<literal>mib-2.dot1dBridge</literal> subtree:</para>
3393
3393
3394
      <screen>&prompt.user; <userinput>snmpset -v 2c -c private bridge1.example.com</userinput>
3394
      <screen>&prompt.user; <userinput>snmpset -v 2c -c private bridge1.example.com</userinput>
3395
BEGEMOT-BRIDGE-MIB::begemotBridgeDefaultBridgeIf.0 s bridge2</screen>
3395
BEGEMOT-BRIDGE-MIB::begemotBridgeDefaultBridgeIf.0 s bridge2</screen>
3396
    </sect2>
3396
    </sect2>
3397
  </sect1>
3397
  </sect1>
3398
3398
3399
  <sect1 xml:id="network-aggregation">
3399
  <sect1 xml:id="network-aggregation">
3400
    <info>
3400
    <info>
3401
      <title>Link Aggregation and Failover</title>
3401
      <title>Link Aggregation and Failover</title>
3402
3402
3403
      <authorgroup>
3403
      <authorgroup>
3404
	<author>
3404
	<author>
3405
	  <personname>
3405
	  <personname>
3406
	    <firstname>Andrew</firstname>
3406
	    <firstname>Andrew</firstname>
3407
	    <surname>Thompson</surname>
3407
	    <surname>Thompson</surname>
3408
	  </personname>
3408
	  </personname>
3409
	  <contrib>Written by </contrib>
3409
	  <contrib>Written by </contrib>
3410
	</author>
3410
	</author>
3411
      </authorgroup>
3411
      </authorgroup>
3412
    </info>
3412
    </info>
3413
3413
3414
    <indexterm>
3414
    <indexterm>
3415
      <primary>lagg</primary>
3415
      <primary>lagg</primary>
3416
    </indexterm>
3416
    </indexterm>
3417
    <indexterm>
3417
    <indexterm>
3418
      <primary>failover</primary>
3418
      <primary>failover</primary>
3419
    </indexterm>
3419
    </indexterm>
3420
    <indexterm>
3420
    <indexterm>
3421
      <primary><acronym>FEC</acronym></primary>
3421
      <primary><acronym>FEC</acronym></primary>
3422
    </indexterm>
3422
    </indexterm>
3423
    <indexterm>
3423
    <indexterm>
3424
      <primary><acronym>LACP</acronym></primary>
3424
      <primary><acronym>LACP</acronym></primary>
3425
    </indexterm>
3425
    </indexterm>
3426
    <indexterm>
3426
    <indexterm>
3427
      <primary>loadbalance</primary>
3427
      <primary>loadbalance</primary>
3428
    </indexterm>
3428
    </indexterm>
3429
    <indexterm>
3429
    <indexterm>
3430
      <primary>roundrobin</primary>
3430
      <primary>roundrobin</primary>
3431
    </indexterm>
3431
    </indexterm>
3432
3432
3433
    <para>&os; provides the &man.lagg.4; interface which can be used
3433
    <para>&os; provides the &man.lagg.4; interface which can be used
3434
      to aggregate multiple network interfaces into one virtual
3434
      to aggregate multiple network interfaces into one virtual
3435
      interface in order to provide failover and link aggregation.
3435
      interface in order to provide failover and link aggregation.
3436
      Failover allows traffic to continue to flow as long as at least
3436
      Failover allows traffic to continue to flow as long as at least
3437
      one aggregated network interface has an established link.  Link
3437
      one aggregated network interface has an established link.  Link
3438
      aggregation works best on switches which support
3438
      aggregation works best on switches which support
3439
      <acronym>LACP</acronym>, as this protocol distributes traffic
3439
      <acronym>LACP</acronym>, as this protocol distributes traffic
3440
      bi-directionally while responding to the failure of individual
3440
      bi-directionally while responding to the failure of individual
3441
      links.</para>
3441
      links.</para>
3442
3442
3443
    <para>The aggregation protocols supported by the lagg interface
3443
    <para>The aggregation protocols supported by the lagg interface
3444
      determine which ports are used for outgoing traffic and whether
3444
      determine which ports are used for outgoing traffic and whether
3445
      or not a specific port accepts incoming traffic.  The following
3445
      or not a specific port accepts incoming traffic.  The following
3446
      protocols are supported by &man.lagg.4;:</para>
3446
      protocols are supported by &man.lagg.4;:</para>
3447
3447
3448
    <variablelist>
3448
    <variablelist>
3449
      <varlistentry>
3449
      <varlistentry>
3450
	<term>failover</term>
3450
	<term>failover</term>
3451
	<listitem>
3451
	<listitem>
3452
	  <para>This mode sends and receives traffic only through
3452
	  <para>This mode sends and receives traffic only through
3453
	    the master port.  If the master port becomes
3453
	    the master port.  If the master port becomes
3454
	    unavailable, the next active port is used.  The first
3454
	    unavailable, the next active port is used.  The first
3455
	    interface added to the virtual interface is the master
3455
	    interface added to the virtual interface is the master
3456
	    port and all subsequently added interfaces are used as
3456
	    port and all subsequently added interfaces are used as
3457
	    failover devices.  If failover to a non-master port
3457
	    failover devices.  If failover to a non-master port
3458
	    occurs, the original port becomes master once it
3458
	    occurs, the original port becomes master once it
3459
	    becomes available again.</para>
3459
	    becomes available again.</para>
3460
	</listitem>
3460
	</listitem>
3461
      </varlistentry>
3461
      </varlistentry>
3462
3462
3463
      <varlistentry>
3463
      <varlistentry>
3464
	<term>fec / loadbalance</term>
3464
	<term>fec / loadbalance</term>
3465
	<listitem>
3465
	<listitem>
3466
	  <para>&cisco; Fast &etherchannel; (<acronym>FEC</acronym>)
3466
	  <para>&cisco; Fast &etherchannel; (<acronym>FEC</acronym>)
3467
	    is found on older &cisco; switches.  It provides a
3467
	    is found on older &cisco; switches.  It provides a
3468
	    static setup and does not negotiate aggregation with the
3468
	    static setup and does not negotiate aggregation with the
3469
	    peer or exchange frames to monitor the link.  If the
3469
	    peer or exchange frames to monitor the link.  If the
3470
	    switch supports <acronym>LACP</acronym>, that should be
3470
	    switch supports <acronym>LACP</acronym>, that should be
3471
	    used instead.</para>
3471
	    used instead.</para>
3472
	</listitem>
3472
	</listitem>
3473
      </varlistentry>
3473
      </varlistentry>
3474
3474
3475
      <varlistentry>
3475
      <varlistentry>
3476
	<term><acronym>lacp</acronym></term>
3476
	<term><acronym>lacp</acronym></term>
3477
	<listitem>
3477
	<listitem>
3478
	  <para>The &ieee; 802.3ad Link Aggregation Control Protocol
3478
	  <para>The &ieee; 802.3ad Link Aggregation Control Protocol
3479
	    (<acronym>LACP</acronym>) negotiates a set of
3479
	    (<acronym>LACP</acronym>) negotiates a set of
3480
	    aggregable links with the peer into one or more Link
3480
	    aggregable links with the peer into one or more Link
3481
	    Aggregated Groups (<acronym>LAG</acronym>s).  Each
3481
	    Aggregated Groups (<acronym>LAG</acronym>s).  Each
3482
	    <acronym>LAG</acronym> is composed of ports of the same
3482
	    <acronym>LAG</acronym> is composed of ports of the same
3483
	    speed, set to full-duplex operation, and traffic is
3483
	    speed, set to full-duplex operation, and traffic is
3484
	    balanced across the ports in the
3484
	    balanced across the ports in the
3485
	    <acronym>LAG</acronym> with the greatest total speed.
3485
	    <acronym>LAG</acronym> with the greatest total speed.
3486
	    Typically, there is only one <acronym>LAG</acronym>
3486
	    Typically, there is only one <acronym>LAG</acronym>
3487
	    which contains all the ports.  In the event of changes
3487
	    which contains all the ports.  In the event of changes
3488
	    in physical connectivity,
3488
	    in physical connectivity,
3489
	    <acronym>LACP</acronym> will quickly converge to a new
3489
	    <acronym>LACP</acronym> will quickly converge to a new
3490
	    configuration.</para>
3490
	    configuration.</para>
3491
3491
3492
	  <para><acronym>LACP</acronym> balances outgoing traffic
3492
	  <para><acronym>LACP</acronym> balances outgoing traffic
3493
	    across the active ports based on hashed protocol header
3493
	    across the active ports based on hashed protocol header
3494
	    information and accepts incoming traffic from any active
3494
	    information and accepts incoming traffic from any active
3495
	    port.  The hash includes the Ethernet source and
3495
	    port.  The hash includes the Ethernet source and
3496
	    destination address and, if available, the
3496
	    destination address and, if available, the
3497
	    <acronym>VLAN</acronym> tag, and the
3497
	    <acronym>VLAN</acronym> tag, and the
3498
	    <acronym>IPv4</acronym> or <acronym>IPv6</acronym>
3498
	    <acronym>IPv4</acronym> or <acronym>IPv6</acronym>
3499
	    source and destination address.</para>
3499
	    source and destination address.</para>
3500
	</listitem>
3500
	</listitem>
3501
      </varlistentry>
3501
      </varlistentry>
3502
3502
3503
      <varlistentry>
3503
      <varlistentry>
3504
	<term>roundrobin</term>
3504
	<term>roundrobin</term>
3505
	<listitem>
3505
	<listitem>
3506
	  <para>This mode distributes outgoing traffic using a
3506
	  <para>This mode distributes outgoing traffic using a
3507
	    round-robin scheduler through all active ports and
3507
	    round-robin scheduler through all active ports and
3508
	    accepts incoming traffic from any active port.  Since
3508
	    accepts incoming traffic from any active port.  Since
3509
	    this mode violates Ethernet frame ordering, it should be
3509
	    this mode violates Ethernet frame ordering, it should be
3510
	    used with caution.</para>
3510
	    used with caution.</para>
3511
	</listitem>
3511
	</listitem>
3512
      </varlistentry>
3512
      </varlistentry>
3513
    </variablelist>
3513
    </variablelist>
3514
3514
3515
    <sect2>
3515
    <sect2>
3516
      <title>Configuration Examples</title>
3516
      <title>Configuration Examples</title>
3517
3517
3518
      <para>This section demonstrates how to configure a &cisco;
3518
      <para>This section demonstrates how to configure a &cisco;
3519
	switch and a &os; system for <acronym>LACP</acronym> load
3519
	switch and a &os; system for <acronym>LACP</acronym> load
3520
	balancing.  It then shows how to configure two Ethernet
3520
	balancing.  It then shows how to configure two Ethernet
3521
	interfaces in failover mode as well as how to configure
3521
	interfaces in failover mode as well as how to configure
3522
	failover mode between an Ethernet and a wireless
3522
	failover mode between an Ethernet and a wireless
3523
	interface.</para>
3523
	interface.</para>
3524
3524
3525
      <example xml:id="networking-lacp-aggregation-cisco">
3525
      <example xml:id="networking-lacp-aggregation-cisco">
3526
	<title><acronym>LACP</acronym> Aggregation with a &cisco;
3526
	<title><acronym>LACP</acronym> Aggregation with a &cisco;
3527
	  Switch</title>
3527
	  Switch</title>
3528
3528
3529
	<para>This example connects two &man.fxp.4; Ethernet
3529
	<para>This example connects two &man.fxp.4; Ethernet
3530
	  interfaces on a &os; machine to the first two Ethernet ports
3530
	  interfaces on a &os; machine to the first two Ethernet ports
3531
	  on a &cisco; switch as a single load balanced and fault
3531
	  on a &cisco; switch as a single load balanced and fault
3532
	  tolerant link.  More interfaces can be added to increase
3532
	  tolerant link.  More interfaces can be added to increase
3533
	  throughput and fault tolerance.  Replace the names of the
3533
	  throughput and fault tolerance.  Replace the names of the
3534
	  &cisco; ports, Ethernet devices, channel group number, and
3534
	  &cisco; ports, Ethernet devices, channel group number, and
3535
	  <acronym>IP</acronym> address shown in the example to match
3535
	  <acronym>IP</acronym> address shown in the example to match
3536
	  the local configuration.</para>
3536
	  the local configuration.</para>
3537
3537
3538
	<para>Frame ordering is mandatory on Ethernet links and any
3538
	<para>Frame ordering is mandatory on Ethernet links and any
3539
	  traffic between two stations always flows over the same
3539
	  traffic between two stations always flows over the same
3540
	  physical link, limiting the maximum speed to that of one
3540
	  physical link, limiting the maximum speed to that of one
3541
	  interface.  The transmit algorithm attempts to use as much
3541
	  interface.  The transmit algorithm attempts to use as much
3542
	  information as it can to distinguish different traffic flows
3542
	  information as it can to distinguish different traffic flows
3543
	  and balance the flows across the available
3543
	  and balance the flows across the available
3544
	  interfaces.</para>
3544
	  interfaces.</para>
3545
3545
3546
	<para>On the &cisco; switch, add the
3546
	<para>On the &cisco; switch, add the
3547
	  <replaceable>FastEthernet0/1</replaceable> and
3547
	  <replaceable>FastEthernet0/1</replaceable> and
3548
	  <replaceable>FastEthernet0/2</replaceable> interfaces to
3548
	  <replaceable>FastEthernet0/2</replaceable> interfaces to
3549
	  channel group <replaceable>1</replaceable>:</para>
3549
	  channel group <replaceable>1</replaceable>:</para>
3550
3550
3551
	<screen><userinput>interface <replaceable>FastEthernet0/1</replaceable>
3551
	<screen><userinput>interface <replaceable>FastEthernet0/1</replaceable>
3552
 channel-group <replaceable>1</replaceable> mode active
3552
 channel-group <replaceable>1</replaceable> mode active
3553
 channel-protocol lacp</userinput>
3553
 channel-protocol lacp</userinput>
3554
!
3554
!
3555
<userinput>interface <replaceable>FastEthernet0/2</replaceable>
3555
<userinput>interface <replaceable>FastEthernet0/2</replaceable>
3556
 channel-group <replaceable>1</replaceable> mode active
3556
 channel-group <replaceable>1</replaceable> mode active
3557
 channel-protocol lacp</userinput></screen>
3557
 channel-protocol lacp</userinput></screen>
3558
3558
3559
	<para>On the &os; system, create the &man.lagg.4; interface
3559
	<para>On the &os; system, create the &man.lagg.4; interface
3560
	  using the physical interfaces
3560
	  using the physical interfaces
3561
	  <replaceable>fxp0</replaceable> and
3561
	  <replaceable>fxp0</replaceable> and
3562
	  <replaceable>fxp1</replaceable> and bring the interfaces up
3562
	  <replaceable>fxp1</replaceable> and bring the interfaces up
3563
	  with an <acronym>IP</acronym> address of
3563
	  with an <acronym>IP</acronym> address of
3564
	  <replaceable>10.0.0.3/24</replaceable>:</para>
3564
	  <replaceable>10.0.0.3/24</replaceable>:</para>
3565
3565
3566
	<screen>&prompt.root; <userinput>ifconfig <replaceable>fxp0</replaceable> up</userinput>
3566
	<screen>&prompt.root; <userinput>ifconfig <replaceable>fxp0</replaceable> up</userinput>
3567
&prompt.root; <userinput>ifconfig <replaceable>fxp1</replaceable> up</userinput>
3567
&prompt.root; <userinput>ifconfig <replaceable>fxp1</replaceable> up</userinput>
3568
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> create </userinput>
3568
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> create </userinput>
3569
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> up laggproto lacp laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.3/24</replaceable></userinput></screen>
3569
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> up laggproto lacp laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.3/24</replaceable></userinput></screen>
3570
3570
3571
	<para>Next, verify the status of the virtual interface:</para>
3571
	<para>Next, verify the status of the virtual interface:</para>
3572
3572
3573
	<screen>&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal></userinput>
3573
	<screen>&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal></userinput>
3574
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3574
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3575
        options=8&lt;VLAN_MTU&gt;
3575
        options=8&lt;VLAN_MTU&gt;
3576
        ether 00:05:5d:71:8d:b8
3576
        ether 00:05:5d:71:8d:b8
3577
        media: Ethernet autoselect
3577
        media: Ethernet autoselect
3578
        status: active
3578
        status: active
3579
        laggproto lacp
3579
        laggproto lacp
3580
        laggport: fxp1 flags=1c&lt;ACTIVE,COLLECTING,DISTRIBUTING&gt;
3580
        laggport: fxp1 flags=1c&lt;ACTIVE,COLLECTING,DISTRIBUTING&gt;
3581
        laggport: fxp0 flags=1c&lt;ACTIVE,COLLECTING,DISTRIBUTING&gt;</screen>
3581
        laggport: fxp0 flags=1c&lt;ACTIVE,COLLECTING,DISTRIBUTING&gt;</screen>
3582
3582
3583
	<para>Ports
3583
	<para>Ports
3584
	  marked as <literal>ACTIVE</literal> are part of the
3584
	  marked as <literal>ACTIVE</literal> are part of the
3585
	  <acronym>LAG</acronym> that has been negotiated with the
3585
	  <acronym>LAG</acronym> that has been negotiated with the
3586
	  remote switch.  Traffic will be transmitted and received
3586
	  remote switch.  Traffic will be transmitted and received
3587
	  through these active ports.  Add <option>-v</option> to the
3587
	  through these active ports.  Add <option>-v</option> to the
3588
	  above command to view the <acronym>LAG</acronym>
3588
	  above command to view the <acronym>LAG</acronym>
3589
	  identifiers.</para>
3589
	  identifiers.</para>
3590
3590
3591
	<para>To see the port status on the &cisco; switch:</para>
3591
	<para>To see the port status on the &cisco; switch:</para>
3592
3592
3593
	<screen>switch# <userinput>show lacp neighbor</userinput>
3593
	<screen>switch# <userinput>show lacp neighbor</userinput>
3594
Flags:  S - Device is requesting Slow LACPDUs
3594
Flags:  S - Device is requesting Slow LACPDUs
3595
        F - Device is requesting Fast LACPDUs
3595
        F - Device is requesting Fast LACPDUs
3596
        A - Device is in Active mode       P - Device is in Passive mode
3596
        A - Device is in Active mode       P - Device is in Passive mode
3597
3597
3598
Channel group 1 neighbors
3598
Channel group 1 neighbors
3599
3599
3600
Partner's information:
3600
Partner's information:
3601
3601
3602
                  LACP port                        Oper    Port     Port
3602
                  LACP port                        Oper    Port     Port
3603
Port      Flags   Priority  Dev ID         Age     Key     Number   State
3603
Port      Flags   Priority  Dev ID         Age     Key     Number   State
3604
Fa0/1     SA      32768     0005.5d71.8db8  29s    0x146   0x3      0x3D
3604
Fa0/1     SA      32768     0005.5d71.8db8  29s    0x146   0x3      0x3D
3605
Fa0/2     SA      32768     0005.5d71.8db8  29s    0x146   0x4      0x3D</screen>
3605
Fa0/2     SA      32768     0005.5d71.8db8  29s    0x146   0x4      0x3D</screen>
3606
3606
3607
	<para>For more detail, type <userinput>show lacp neighbor
3607
	<para>For more detail, type <userinput>show lacp neighbor
3608
	  detail</userinput>.</para>
3608
	  detail</userinput>.</para>
3609
3609
3610
	<para>To retain this configuration across reboots, add the
3610
	<para>To retain this configuration across reboots, add the
3611
	  following entries to
3611
	  following entries to
3612
	  <filename>/etc/rc.conf</filename> on the &os; system:</para>
3612
	  <filename>/etc/rc.conf</filename> on the &os; system:</para>
3613
3613
3614
	<programlisting>ifconfig_<replaceable>fxp0</replaceable>="up"
3614
	<programlisting>ifconfig_<replaceable>fxp0</replaceable>="up"
3615
ifconfig_<replaceable>fxp1</replaceable>="up"
3615
ifconfig_<replaceable>fxp1</replaceable>="up"
3616
cloned_interfaces="<literal>lagg<replaceable>0</replaceable></literal>"
3616
cloned_interfaces="<literal>lagg<replaceable>0</replaceable></literal>"
3617
ifconfig_<literal>lagg<replaceable>0</replaceable></literal>="laggproto lacp laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.3/24</replaceable>"</programlisting>
3617
ifconfig_<literal>lagg<replaceable>0</replaceable></literal>="laggproto lacp laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.3/24</replaceable>"</programlisting>
3618
      </example>
3618
      </example>
3619
3619
3620
      <example xml:id="networking-lagg-failover">
3620
      <example xml:id="networking-lagg-failover">
3621
	<title>Failover Mode</title>
3621
	<title>Failover Mode</title>
3622
3622
3623
	<para>Failover mode can be used to switch over to a secondary
3623
	<para>Failover mode can be used to switch over to a secondary
3624
	  interface if the link is lost on the master interface.  To
3624
	  interface if the link is lost on the master interface.  To
3625
	  configure failover, make sure that the underlying physical
3625
	  configure failover, make sure that the underlying physical
3626
	  interfaces are up, then create the &man.lagg.4; interface.
3626
	  interfaces are up, then create the &man.lagg.4; interface.
3627
	  In this example, <replaceable>fxp0</replaceable> is the
3627
	  In this example, <replaceable>fxp0</replaceable> is the
3628
	  master interface, <replaceable>fxp1</replaceable> is the
3628
	  master interface, <replaceable>fxp1</replaceable> is the
3629
	  secondary interface, and the virtual interface is assigned
3629
	  secondary interface, and the virtual interface is assigned
3630
	  an <acronym>IP</acronym> address of
3630
	  an <acronym>IP</acronym> address of
3631
	  <replaceable>10.0.0.15/24</replaceable>:</para>
3631
	  <replaceable>10.0.0.15/24</replaceable>:</para>
3632
3632
3633
	<screen>&prompt.root; <userinput>ifconfig <replaceable>fxp0</replaceable> up</userinput>
3633
	<screen>&prompt.root; <userinput>ifconfig <replaceable>fxp0</replaceable> up</userinput>
3634
&prompt.root; <userinput>ifconfig <replaceable>fxp1</replaceable> up</userinput>
3634
&prompt.root; <userinput>ifconfig <replaceable>fxp1</replaceable> up</userinput>
3635
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> create</userinput>
3635
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> create</userinput>
3636
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> up laggproto failover laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.15/24</replaceable></userinput></screen>
3636
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> up laggproto failover laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.15/24</replaceable></userinput></screen>
3637
3637
3638
	<para>The virtual interface should look something like
3638
	<para>The virtual interface should look something like
3639
	  this:</para>
3639
	  this:</para>
3640
3640
3641
	<screen>&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal></userinput>
3641
	<screen>&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal></userinput>
3642
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3642
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3643
        options=8&lt;VLAN_MTU&gt;
3643
        options=8&lt;VLAN_MTU&gt;
3644
        ether 00:05:5d:71:8d:b8
3644
        ether 00:05:5d:71:8d:b8
3645
        inet 10.0.0.15 netmask 0xffffff00 broadcast 10.0.0.255
3645
        inet 10.0.0.15 netmask 0xffffff00 broadcast 10.0.0.255
3646
        media: Ethernet autoselect
3646
        media: Ethernet autoselect
3647
        status: active
3647
        status: active
3648
        laggproto failover
3648
        laggproto failover
3649
        laggport: fxp1 flags=0&lt;&gt;
3649
        laggport: fxp1 flags=0&lt;&gt;
3650
        laggport: fxp0 flags=5&lt;MASTER,ACTIVE&gt;</screen>
3650
        laggport: fxp0 flags=5&lt;MASTER,ACTIVE&gt;</screen>
3651
3651
3652
	<para>Traffic will be transmitted and received on
3652
	<para>Traffic will be transmitted and received on
3653
	  <replaceable>fxp0</replaceable>.  If the link is lost on
3653
	  <replaceable>fxp0</replaceable>.  If the link is lost on
3654
	  <replaceable>fxp0</replaceable>,
3654
	  <replaceable>fxp0</replaceable>,
3655
	  <replaceable>fxp1</replaceable> will become the active link.
3655
	  <replaceable>fxp1</replaceable> will become the active link.
3656
	  If the link is restored on the master interface, it will
3656
	  If the link is restored on the master interface, it will
3657
	  once again become the active link.</para>
3657
	  once again become the active link.</para>
3658
3658
3659
	<para>To retain this configuration across reboots, add the
3659
	<para>To retain this configuration across reboots, add the
3660
	  following entries to
3660
	  following entries to
3661
	  <filename>/etc/rc.conf</filename>:</para>
3661
	  <filename>/etc/rc.conf</filename>:</para>
3662
3662
3663
	<programlisting>ifconfig_<replaceable>fxp0</replaceable>="up"
3663
	<programlisting>ifconfig_<replaceable>fxp0</replaceable>="up"
3664
ifconfig_<replaceable>fxp1</replaceable>="up"
3664
ifconfig_<replaceable>fxp1</replaceable>="up"
3665
cloned_interfaces="<literal>lagg<replaceable>0</replaceable></literal>"
3665
cloned_interfaces="<literal>lagg<replaceable>0</replaceable></literal>"
3666
ifconfig_<literal>lagg<replaceable>0</replaceable></literal>="laggproto failover laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.15/24</replaceable>"</programlisting>
3666
ifconfig_<literal>lagg<replaceable>0</replaceable></literal>="laggproto failover laggport <replaceable>fxp0</replaceable> laggport <replaceable>fxp1</replaceable> <replaceable>10.0.0.15/24</replaceable>"</programlisting>
3667
      </example>
3667
      </example>
3668
3668
3669
      <example xml:id="networking-lagg-wired-and-wireless">
3669
      <example xml:id="networking-lagg-wired-and-wireless">
3670
	<title>Failover Mode Between Ethernet and Wireless
3670
	<title>Failover Mode Between Ethernet and Wireless
3671
	  Interfaces</title>
3671
	  Interfaces</title>
3672
3672
3673
	<para>For laptop users, it is usually desirable to configure
3673
	<para>For laptop users, it is usually desirable to configure
3674
	  the wireless device as a secondary which is only used when
3674
	  the wireless device as a secondary which is only used when
3675
	  the Ethernet connection is not available.  With
3675
	  the Ethernet connection is not available.  With
3676
	  &man.lagg.4;, it is possible to configure a failover which
3676
	  &man.lagg.4;, it is possible to configure a failover which
3677
	  prefers the Ethernet connection for both performance and
3677
	  prefers the Ethernet connection for both performance and
3678
	  security reasons, while maintaining the ability to transfer
3678
	  security reasons, while maintaining the ability to transfer
3679
	  data over the wireless connection.</para>
3679
	  data over the wireless connection.</para>
3680
3680
3681
	<para>This is achieved by overriding the physical wireless
3681
	<para>This is achieved by overriding the physical wireless
3682
	  interface's <acronym>MAC</acronym> address with that of the
3682
	  interface's <acronym>MAC</acronym> address with that of the
3683
	  Ethernet interface.</para>
3683
	  Ethernet interface.</para>
3684
3684
3685
	<para>In this example, the Ethernet interface,
3685
	<para>In this example, the Ethernet interface,
3686
	  <replaceable>bge0</replaceable>, is the master and the
3686
	  <replaceable>bge0</replaceable>, is the master and the
3687
	  wireless interface, <replaceable>wlan0</replaceable>, is
3687
	  wireless interface, <replaceable>wlan0</replaceable>, is
3688
	  the failover.  The <replaceable>wlan0</replaceable> device
3688
	  the failover.  The <replaceable>wlan0</replaceable> device
3689
	  was created from <replaceable>iwn0</replaceable> wireless
3689
	  was created from <replaceable>iwn0</replaceable> wireless
3690
	  interface, which will be configured with the
3690
	  interface, which will be configured with the
3691
	  <acronym>MAC</acronym> address of the Ethernet interface.
3691
	  <acronym>MAC</acronym> address of the Ethernet interface.
3692
	  First, determine the <acronym>MAC</acronym> address of the
3692
	  First, determine the <acronym>MAC</acronym> address of the
3693
	  Ethernet interface:</para>
3693
	  Ethernet interface:</para>
3694
3694
3695
	<screen>&prompt.root; <userinput>ifconfig <replaceable>bge0</replaceable></userinput>
3695
	<screen>&prompt.root; <userinput>ifconfig <replaceable>bge0</replaceable></userinput>
3696
bge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3696
bge0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3697
	options=19b&lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4&gt;
3697
	options=19b&lt;RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4&gt;
3698
	ether 00:21:70:da:ae:37
3698
	ether 00:21:70:da:ae:37
3699
	inet6 fe80::221:70ff:feda:ae37%bge0 prefixlen 64 scopeid 0x2
3699
	inet6 fe80::221:70ff:feda:ae37%bge0 prefixlen 64 scopeid 0x2
3700
	nd6 options=29&lt;PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL&gt;
3700
	nd6 options=29&lt;PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL&gt;
3701
	media: Ethernet autoselect (1000baseT &lt;full-duplex&gt;)
3701
	media: Ethernet autoselect (1000baseT &lt;full-duplex&gt;)
3702
	status: active</screen>
3702
	status: active</screen>
3703
3703
3704
	<para>Replace <replaceable>bge0</replaceable> to match the
3704
	<para>Replace <replaceable>bge0</replaceable> to match the
3705
	  system's Ethernet interface name.  The
3705
	  system's Ethernet interface name.  The
3706
	  <literal>ether</literal> line will contain the
3706
	  <literal>ether</literal> line will contain the
3707
	  <acronym>MAC</acronym> address of the specified interface.
3707
	  <acronym>MAC</acronym> address of the specified interface.
3708
	  Now, change the <acronym>MAC</acronym> address of the
3708
	  Now, change the <acronym>MAC</acronym> address of the
3709
	  underlying wireless interface:</para>
3709
	  underlying wireless interface:</para>
3710
3710
3711
	<screen>&prompt.root; <userinput>ifconfig <replaceable>iwn0</replaceable> ether <replaceable>00:21:70:da:ae:37</replaceable></userinput></screen>
3711
	<screen>&prompt.root; <userinput>ifconfig <replaceable>iwn0</replaceable> ether <replaceable>00:21:70:da:ae:37</replaceable></userinput></screen>
3712
3712
3713
	<para>Bring the wireless interface up, but do not set an
3713
	<para>Bring the wireless interface up, but do not set an
3714
	  <acronym>IP</acronym> address:</para>
3714
	  <acronym>IP</acronym> address:</para>
3715
3715
3716
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>iwn0</replaceable> ssid <replaceable>my_router</replaceable> up</userinput></screen>
3716
	<screen>&prompt.root; <userinput>ifconfig <replaceable>wlan0</replaceable> create wlandev <replaceable>iwn0</replaceable> ssid <replaceable>my_router</replaceable> up</userinput></screen>
3717
3717
3718
	<para>Make sure the <replaceable>bge0</replaceable> interface
3718
	<para>Make sure the <replaceable>bge0</replaceable> interface
3719
	  is up, then create the &man.lagg.4; interface with
3719
	  is up, then create the &man.lagg.4; interface with
3720
	  <replaceable>bge0</replaceable> as master with failover to
3720
	  <replaceable>bge0</replaceable> as master with failover to
3721
	  <replaceable>wlan0</replaceable>:</para>
3721
	  <replaceable>wlan0</replaceable>:</para>
3722
3722
3723
	<screen>&prompt.root; <userinput>ifconfig <replaceable>bge0</replaceable> up</userinput>
3723
	<screen>&prompt.root; <userinput>ifconfig <replaceable>bge0</replaceable> up</userinput>
3724
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> create</userinput>
3724
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> create</userinput>
3725
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> up laggproto failover laggport <replaceable>bge0</replaceable> laggport <replaceable>wlan0</replaceable></userinput></screen>
3725
&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal> up laggproto failover laggport <replaceable>bge0</replaceable> laggport <replaceable>wlan0</replaceable></userinput></screen>
3726
3726
3727
	<para>The virtual interface should look something like
3727
	<para>The virtual interface should look something like
3728
	  this:</para>
3728
	  this:</para>
3729
3729
3730
	<screen>&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal></userinput>
3730
	<screen>&prompt.root; <userinput>ifconfig <literal>lagg<replaceable>0</replaceable></literal></userinput>
3731
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3731
lagg0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; metric 0 mtu 1500
3732
        options=8&lt;VLAN_MTU&gt;
3732
        options=8&lt;VLAN_MTU&gt;
3733
        ether 00:21:70:da:ae:37
3733
        ether 00:21:70:da:ae:37
3734
        media: Ethernet autoselect
3734
        media: Ethernet autoselect
3735
        status: active
3735
        status: active
3736
        laggproto failover
3736
        laggproto failover
3737
        laggport: wlan0 flags=0&lt;&gt;
3737
        laggport: wlan0 flags=0&lt;&gt;
3738
        laggport: bge0 flags=5&lt;MASTER,ACTIVE&gt;</screen>
3738
        laggport: bge0 flags=5&lt;MASTER,ACTIVE&gt;</screen>
3739
3739
3740
	<para>Then, start the <acronym>DHCP</acronym> client to
3740
	<para>Then, start the <acronym>DHCP</acronym> client to
3741
	  obtain an <acronym>IP</acronym> address:</para>
3741
	  obtain an <acronym>IP</acronym> address:</para>
3742
3742
3743
	<screen>&prompt.root; <userinput>dhclient <literal>lagg<replaceable>0</replaceable></literal></userinput></screen>
3743
	<screen>&prompt.root; <userinput>dhclient <literal>lagg<replaceable>0</replaceable></literal></userinput></screen>
3744
3744
3745
	<para>To retain this configuration across reboots, add the
3745
	<para>To retain this configuration across reboots, add the
3746
	  following entries to
3746
	  following entries to
3747
	  <filename>/etc/rc.conf</filename>:</para>
3747
	  <filename>/etc/rc.conf</filename>:</para>
3748
3748
3749
	<programlisting>ifconfig_bge0="up"
3749
	<programlisting>ifconfig_bge0="up"
3750
wlans_<replaceable>iwn0</replaceable>="wlan0"
3750
wlans_<replaceable>iwn0</replaceable>="wlan0"
3751
ifconfig_wlan0="WPA"
3751
ifconfig_wlan0="WPA"
3752
create_args_wlan0="<replaceable>wlanaddr 00:21:70:da:ae:37</replaceable>"
3752
create_args_wlan0="<replaceable>wlanaddr 00:21:70:da:ae:37</replaceable>"
3753
cloned_interfaces="<literal>lagg<replaceable>0</replaceable></literal>"
3753
cloned_interfaces="<literal>lagg<replaceable>0</replaceable></literal>"
3754
ifconfig_<literal>lagg<replaceable>0</replaceable></literal>="up laggproto failover laggport bge0 laggport wlan0 DHCP"</programlisting>
3754
ifconfig_<literal>lagg<replaceable>0</replaceable></literal>="up laggproto failover laggport bge0 laggport wlan0 DHCP"</programlisting>
3755
      </example>
3755
      </example>
3756
    </sect2>
3756
    </sect2>
3757
  </sect1>
3757
  </sect1>
3758
3758
3759
  <sect1 xml:id="network-diskless">
3759
  <sect1 xml:id="network-diskless">
3760
    <info>
3760
    <info>
3761
      <title>Diskless Operation with <acronym>PXE</acronym></title>
3761
      <title>Diskless Operation with <acronym>PXE</acronym></title>
3762
3762
3763
      <authorgroup>
3763
      <authorgroup>
3764
	<author>
3764
	<author>
3765
	  <personname>
3765
	  <personname>
3766
	    <firstname>Jean-Fran&ccedil;ois</firstname>
3766
	    <firstname>Jean-Fran&ccedil;ois</firstname>
3767
	    <surname>Dock&egrave;s</surname>
3767
	    <surname>Dock&egrave;s</surname>
3768
	  </personname>
3768
	  </personname>
3769
	  <contrib>Updated by </contrib>
3769
	  <contrib>Updated by </contrib>
3770
	</author>
3770
	</author>
3771
      </authorgroup>
3771
      </authorgroup>
3772
      <authorgroup>
3772
      <authorgroup>
3773
	<author>
3773
	<author>
3774
	  <personname>
3774
	  <personname>
3775
	    <firstname>Alex</firstname>
3775
	    <firstname>Alex</firstname>
3776
	    <surname>Dupre</surname>
3776
	    <surname>Dupre</surname>
3777
	  </personname>
3777
	  </personname>
3778
	  <contrib>Reorganized and enhanced by </contrib>
3778
	  <contrib>Reorganized and enhanced by </contrib>
3779
	</author>
3779
	</author>
3780
      </authorgroup>
3780
      </authorgroup>
3781
    </info>
3781
    </info>
3782
3782
3783
    <indexterm>
3783
    <indexterm>
3784
      <primary>diskless workstation</primary>
3784
      <primary>diskless workstation</primary>
3785
    </indexterm>
3785
    </indexterm>
3786
    <indexterm>
3786
    <indexterm>
3787
      <primary>diskless operation</primary>
3787
      <primary>diskless operation</primary>
3788
    </indexterm>
3788
    </indexterm>
3789
3789
3790
    <para>The &intel; Preboot eXecution Environment
3790
    <para>The &intel; Preboot eXecution Environment
3791
      (<acronym>PXE</acronym>) allows an operating system to boot over
3791
      (<acronym>PXE</acronym>) allows an operating system to boot over
3792
      the network.  For example, a &os; system can boot over the
3792
      the network.  For example, a &os; system can boot over the
3793
      network and operate without a local disk, using file systems
3793
      network and operate without a local disk, using file systems
3794
      mounted from an <acronym>NFS</acronym> server.
3794
      mounted from an <acronym>NFS</acronym> server.
3795
      <acronym>PXE</acronym> support is usually available in the
3795
      <acronym>PXE</acronym> support is usually available in the
3796
      <acronym>BIOS</acronym>.  To use <acronym>PXE</acronym> when the
3796
      <acronym>BIOS</acronym>.  To use <acronym>PXE</acronym> when the
3797
      machine starts, select the <literal>Boot from network</literal>
3797
      machine starts, select the <literal>Boot from network</literal>
3798
      option in the <acronym>BIOS</acronym> setup or type a function
3798
      option in the <acronym>BIOS</acronym> setup or type a function
3799
      key during system initialization.</para>
3799
      key during system initialization.</para>
3800
3800
3801
    <para>In order to provide the files needed for an operating system
3801
    <para>In order to provide the files needed for an operating system
3802
      to boot over the network, a <acronym>PXE</acronym> setup also
3802
      to boot over the network, a <acronym>PXE</acronym> setup also
3803
      requires properly configured <acronym>DHCP</acronym>,
3803
      requires properly configured <acronym>DHCP</acronym>,
3804
      <acronym>TFTP</acronym>, and <acronym>NFS</acronym> servers,
3804
      <acronym>TFTP</acronym>, and <acronym>NFS</acronym> servers,
3805
      where:</para>
3805
      where:</para>
3806
3806
3807
    <itemizedlist>
3807
    <itemizedlist>
3808
      <listitem>
3808
      <listitem>
3809
	<para>Initial parameters, such as an <acronym>IP</acronym>
3809
	<para>Initial parameters, such as an <acronym>IP</acronym>
3810
	  address, executable boot filename and location, server name,
3810
	  address, executable boot filename and location, server name,
3811
	  and root path are obtained from the
3811
	  and root path are obtained from the
3812
	  <acronym>DHCP</acronym> server.</para>
3812
	  <acronym>DHCP</acronym> server.</para>
3813
      </listitem>
3813
      </listitem>
3814
3814
3815
      <listitem>
3815
      <listitem>
3816
	<para>The operating system loader file is booted using
3816
	<para>The operating system loader file is booted using
3817
	  <acronym>TFTP</acronym>.</para>
3817
	  <acronym>TFTP</acronym>.</para>
3818
      </listitem>
3818
      </listitem>
3819
3819
3820
      <listitem>
3820
      <listitem>
3821
	<para>The file systems are loaded using
3821
	<para>The file systems are loaded using
3822
	  <acronym>NFS</acronym>.</para>
3822
	  <acronym>NFS</acronym>.</para>
3823
      </listitem>
3823
      </listitem>
3824
    </itemizedlist>
3824
    </itemizedlist>
3825
3825
3826
    <para>When a computer <acronym>PXE</acronym> boots, it receives
3826
    <para>When a computer <acronym>PXE</acronym> boots, it receives
3827
      information over <acronym>DHCP</acronym> about where to obtain
3827
      information over <acronym>DHCP</acronym> about where to obtain
3828
      the initial boot loader file.  After the host computer receives
3828
      the initial boot loader file.  After the host computer receives
3829
      this information, it downloads the boot loader via
3829
      this information, it downloads the boot loader via
3830
      <acronym>TFTP</acronym> and then executes the boot loader.  In
3830
      <acronym>TFTP</acronym> and then executes the boot loader.  In
3831
      &os;, the boot loader file is
3831
      &os;, the boot loader file is
3832
      <filename>/boot/pxeboot</filename>.  After
3832
      <filename>/boot/pxeboot</filename>.  After
3833
      <filename>/boot/pxeboot</filename> executes, the &os; kernel is
3833
      <filename>/boot/pxeboot</filename> executes, the &os; kernel is
3834
      loaded and the rest of the &os; bootup sequence proceeds, as
3834
      loaded and the rest of the &os; bootup sequence proceeds, as
3835
      described in <xref linkend="boot"/>.</para>
3835
      described in <xref linkend="boot"/>.</para>
3836
3836
3837
    <para>This section describes how to configure these services on a
3837
    <para>This section describes how to configure these services on a
3838
      &os; system so that other systems can <acronym>PXE</acronym>
3838
      &os; system so that other systems can <acronym>PXE</acronym>
3839
      boot into &os;.  Refer to &man.diskless.8; for more
3839
      boot into &os;.  Refer to &man.diskless.8; for more
3840
      information.</para>
3840
      information.</para>
3841
3841
3842
    <caution>
3842
    <caution>
3843
      <para>As described, the system providing these services is
3843
      <para>As described, the system providing these services is
3844
	insecure.  It should live in a protected area of a network and
3844
	insecure.  It should live in a protected area of a network and
3845
	be untrusted by other hosts.</para>
3845
	be untrusted by other hosts.</para>
3846
    </caution>
3846
    </caution>
3847
3847
3848
    <sect2 xml:id="network-pxe-nfs">
3848
    <sect2 xml:id="network-pxe-nfs">
3849
      <info>
3849
      <info>
3850
	<title>Setting Up the <acronym>PXE</acronym>
3850
	<title>Setting Up the <acronym>PXE</acronym>
3851
	  Environment</title>
3851
	  Environment</title>
3852
3852
3853
	<authorgroup>
3853
	<authorgroup>
3854
	  <author>
3854
	  <author>
3855
	    <personname>
3855
	    <personname>
3856
	      <firstname>Craig</firstname>
3856
	      <firstname>Craig</firstname>
3857
	      <surname>Rodrigues</surname>
3857
	      <surname>Rodrigues</surname>
3858
	    </personname>
3858
	    </personname>
3859
	    <affiliation>
3859
	    <affiliation>
3860
	      <address>rodrigc@FreeBSD.org</address>
3860
	      <address>rodrigc@FreeBSD.org</address>
3861
	    </affiliation>
3861
	    </affiliation>
3862
	    <contrib>Written by </contrib>
3862
	    <contrib>Written by </contrib>
3863
	  </author>
3863
	  </author>
3864
	</authorgroup>
3864
	</authorgroup>
3865
      </info>
3865
      </info>
3866
3866
3867
      <para>The steps shown in this section configure the built-in
3867
      <para>The steps shown in this section configure the built-in
3868
	<acronym>NFS</acronym> and <acronym>TFTP</acronym> servers.
3868
	<acronym>NFS</acronym> and <acronym>TFTP</acronym> servers.
3869
	The next section demonstrates how to install and configure the
3869
	The next section demonstrates how to install and configure the
3870
	<acronym>DHCP</acronym> server.  In this example, the
3870
	<acronym>DHCP</acronym> server.  In this example, the
3871
	directory which will contain the files used by
3871
	directory which will contain the files used by
3872
	<acronym>PXE</acronym> users is
3872
	<acronym>PXE</acronym> users is
3873
	<filename>/b/tftpboot/FreeBSD/install</filename>.  It is
3873
	<filename>/b/tftpboot/FreeBSD/install</filename>.  It is
3874
	important that this directory exists and that the same
3874
	important that this directory exists and that the same
3875
	directory name is set in both
3875
	directory name is set in both
3876
	<filename>/etc/inetd.conf</filename> and
3876
	<filename>/etc/inetd.conf</filename> and
3877
	<filename>/usr/local/etc/dhcpd.conf</filename>.</para>
3877
	<filename>/usr/local/etc/dhcpd.conf</filename>.</para>
3878
3878
3879
      <procedure>
3879
      <procedure>
3880
	<step>
3880
	<step>
3881
	  <para>Create the root directory which will contain a &os;
3881
	  <para>Create the root directory which will contain a &os;
3882
	    installation to be <acronym>NFS</acronym> mounted:</para>
3882
	    installation to be <acronym>NFS</acronym> mounted:</para>
3883
3883
3884
	  <screen>&prompt.root; <userinput>export NFSROOTDIR=/b/tftpboot/FreeBSD/install</userinput>
3884
	  <screen>&prompt.root; <userinput>export NFSROOTDIR=/b/tftpboot/FreeBSD/install</userinput>
3885
&prompt.root; <userinput>mkdir -p ${NFSROOTDIR}</userinput></screen>
3885
&prompt.root; <userinput>mkdir -p ${NFSROOTDIR}</userinput></screen>
3886
	</step>
3886
	</step>
3887
3887
3888
	<step>
3888
	<step>
3889
	  <para>Enable the <acronym>NFS</acronym> server by adding
3889
	  <para>Enable the <acronym>NFS</acronym> server by adding
3890
	    this line to <filename>/etc/rc.conf</filename>:</para>
3890
	    this line to <filename>/etc/rc.conf</filename>:</para>
3891
3891
3892
	  <programlisting>nfs_server_enable="YES"</programlisting>
3892
	  <programlisting>nfs_server_enable="YES"</programlisting>
3893
	</step>
3893
	</step>
3894
3894
3895
	<step>
3895
	<step>
3896
	  <para>Export the diskless root directory via
3896
	  <para>Export the diskless root directory via
3897
	    <acronym>NFS</acronym> by adding the following to
3897
	    <acronym>NFS</acronym> by adding the following to
3898
	    <filename>/etc/exports</filename>:</para>
3898
	    <filename>/etc/exports</filename>:</para>
3899
3899
3900
	  <programlisting>/b -ro -alldirs</programlisting>
3900
	  <programlisting>/b -ro -alldirs</programlisting>
3901
	</step>
3901
	</step>
3902
3902
3903
	<step>
3903
	<step>
3904
	  <para>Start the <acronym>NFS</acronym> server:</para>
3904
	  <para>Start the <acronym>NFS</acronym> server:</para>
3905
3905
3906
	  <screen>&prompt.root; <userinput>service nfsd start</userinput></screen>
3906
	  <screen>&prompt.root; <userinput>service nfsd start</userinput></screen>
3907
	</step>
3907
	</step>
3908
3908
3909
	<step>
3909
	<step>
3910
	  <para>Enable &man.inetd.8; by adding the following line to
3910
	  <para>Enable &man.inetd.8; by adding the following line to
3911
	    <filename>/etc/rc.conf</filename>:</para>
3911
	    <filename>/etc/rc.conf</filename>:</para>
3912
3912
3913
	  <programlisting>inetd_enable="YES"</programlisting>
3913
	  <programlisting>inetd_enable="YES"</programlisting>
3914
	</step>
3914
	</step>
3915
3915
3916
	<step>
3916
	<step>
3917
	  <para>Uncomment the following line in
3917
	  <para>Uncomment the following line in
3918
	    <filename>/etc/inetd.conf</filename> by making sure it
3918
	    <filename>/etc/inetd.conf</filename> by making sure it
3919
	    does not start with a <literal>#</literal> symbol:</para>
3919
	    does not start with a <literal>#</literal> symbol:</para>
3920
3920
3921
	  <programlisting>tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /b/tftpboot</programlisting>
3921
	  <programlisting>tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /b/tftpboot</programlisting>
3922
3922
3923
	  <note>
3923
	  <note>
3924
	    <para>Some <acronym>PXE</acronym> versions require the
3924
	    <para>Some <acronym>PXE</acronym> versions require the
3925
	      <acronym>TCP</acronym> version of
3925
	      <acronym>TCP</acronym> version of
3926
	      <acronym>TFTP</acronym>.  In this case, uncomment the
3926
	      <acronym>TFTP</acronym>.  In this case, uncomment the
3927
	      second <literal>tftp</literal> line which contains
3927
	      second <literal>tftp</literal> line which contains
3928
	      <literal>stream tcp</literal>.</para>
3928
	      <literal>stream tcp</literal>.</para>
3929
	  </note>
3929
	  </note>
3930
	</step>
3930
	</step>
3931
3931
3932
	<step>
3932
	<step>
3933
	  <para>Start &man.inetd.8;:</para>
3933
	  <para>Start &man.inetd.8;:</para>
3934
3934
3935
	  <screen>&prompt.root; <userinput>service inetd start</userinput></screen>
3935
	  <screen>&prompt.root; <userinput>service inetd start</userinput></screen>
3936
	</step>
3936
	</step>
3937
3937
3938
	<step>
3938
	<step>
3939
	  <para>Rebuild the &os; kernel and userland (refer to <xref
3939
	  <para>Rebuild the &os; kernel and userland (refer to <xref
3940
	      linkend="makeworld"/> for more detailed
3940
	      linkend="makeworld"/> for more detailed
3941
	    instructions):</para>
3941
	    instructions):</para>
3942
3942
3943
	  <screen>&prompt.root; <userinput>cd /usr/src</userinput>
3943
	  <screen>&prompt.root; <userinput>cd /usr/src</userinput>
3944
&prompt.root; <userinput>make buildworld</userinput>
3944
&prompt.root; <userinput>make buildworld</userinput>
3945
&prompt.root; <userinput>make buildkernel</userinput></screen>
3945
&prompt.root; <userinput>make buildkernel</userinput></screen>
3946
	</step>
3946
	</step>
3947
3947
3948
	<step>
3948
	<step>
3949
	  <para>Install &os; into the directory mounted over
3949
	  <para>Install &os; into the directory mounted over
3950
	    <acronym>NFS</acronym>:</para>
3950
	    <acronym>NFS</acronym>:</para>
3951
3951
3952
	  <screen>&prompt.root; <userinput>make installworld DESTDIR=${NFSROOTDIR}</userinput>
3952
	  <screen>&prompt.root; <userinput>make installworld DESTDIR=${NFSROOTDIR}</userinput>
3953
&prompt.root; <userinput>make installkernel DESTDIR=${NFSROOTDIR}</userinput>
3953
&prompt.root; <userinput>make installkernel DESTDIR=${NFSROOTDIR}</userinput>
3954
&prompt.root; <userinput>make distribution DESTDIR=${NFSROOTDIR}</userinput></screen>
3954
&prompt.root; <userinput>make distribution DESTDIR=${NFSROOTDIR}</userinput></screen>
3955
	</step>
3955
	</step>
3956
3956
3957
	<step>
3957
	<step>
3958
	  <para>Test that the <acronym>TFTP</acronym> server works and
3958
	  <para>Test that the <acronym>TFTP</acronym> server works and
3959
	    can download the boot loader which will be obtained via
3959
	    can download the boot loader which will be obtained via
3960
	    <acronym>PXE</acronym>:</para>
3960
	    <acronym>PXE</acronym>:</para>
3961
3961
3962
	  <screen>&prompt.root; <userinput>tftp localhost</userinput>
3962
	  <screen>&prompt.root; <userinput>tftp localhost</userinput>
3963
tftp&gt; <userinput>get FreeBSD/install/boot/pxeboot</userinput>
3963
tftp&gt; <userinput>get FreeBSD/install/boot/pxeboot</userinput>
3964
Received 264951 bytes in 0.1 seconds</screen>
3964
Received 264951 bytes in 0.1 seconds</screen>
3965
	</step>
3965
	</step>
3966
3966
3967
	<step>
3967
	<step>
3968
	  <para>Edit <filename>${NFSROOTDIR}/etc/fstab</filename> and
3968
	  <para>Edit <filename>${NFSROOTDIR}/etc/fstab</filename> and
3969
	    create an entry to mount the root file system over
3969
	    create an entry to mount the root file system over
3970
	    <acronym>NFS</acronym>:</para>
3970
	    <acronym>NFS</acronym>:</para>
3971
3971
3972
	  <programlisting># Device                                         Mountpoint    FSType   Options  Dump Pass
3972
	  <programlisting># Device                                         Mountpoint    FSType   Options  Dump Pass
3973
<replaceable>myhost.example.com</replaceable>:/b/tftpboot/FreeBSD/install       /         nfs      ro        0    0</programlisting>
3973
<replaceable>myhost.example.com</replaceable>:/b/tftpboot/FreeBSD/install       /         nfs      ro        0    0</programlisting>
3974
3974
3975
	  <para>Replace <replaceable>myhost.example.com</replaceable>
3975
	  <para>Replace <replaceable>myhost.example.com</replaceable>
3976
	    with the hostname or <acronym>IP</acronym> address of the
3976
	    with the hostname or <acronym>IP</acronym> address of the
3977
	    <acronym>NFS</acronym> server.  In this example, the root
3977
	    <acronym>NFS</acronym> server.  In this example, the root
3978
	    file system is mounted read-only in order to prevent
3978
	    file system is mounted read-only in order to prevent
3979
	    <acronym>NFS</acronym> clients from potentially deleting
3979
	    <acronym>NFS</acronym> clients from potentially deleting
3980
	    the contents of the root file system.</para>
3980
	    the contents of the root file system.</para>
3981
	</step>
3981
	</step>
3982
3982
3983
	<step>
3983
	<step>
3984
	  <para>Set the root password in the <acronym>PXE</acronym>
3984
	  <para>Set the root password in the <acronym>PXE</acronym>
3985
	    environment for client machines which are
3985
	    environment for client machines which are
3986
	    <acronym>PXE</acronym> booting :</para>
3986
	    <acronym>PXE</acronym> booting :</para>
3987
3987
3988
	  <screen>&prompt.root; <userinput>chroot ${NFSROOTDIR}</userinput>
3988
	  <screen>&prompt.root; <userinput>chroot ${NFSROOTDIR}</userinput>
3989
&prompt.root; <userinput>passwd</userinput></screen>
3989
&prompt.root; <userinput>passwd</userinput></screen>
3990
	</step>
3990
	</step>
3991
3991
3992
	<step>
3992
	<step>
3993
	  <para>If needed, enable &man.ssh.1; root logins for client
3993
	  <para>If needed, enable &man.ssh.1; root logins for client
3994
	    machines which are <acronym>PXE</acronym> booting by
3994
	    machines which are <acronym>PXE</acronym> booting by
3995
	    editing
3995
	    editing
3996
	    <filename>${NFSROOTDIR}/etc/ssh/sshd_config</filename> and
3996
	    <filename>${NFSROOTDIR}/etc/ssh/sshd_config</filename> and
3997
	    enabling <literal>PermitRootLogin</literal>.  This option
3997
	    enabling <literal>PermitRootLogin</literal>.  This option
3998
	    is documented in &man.sshd.config.5;.</para>
3998
	    is documented in &man.sshd.config.5;.</para>
3999
	</step>
3999
	</step>
4000
4000
4001
	<step>
4001
	<step>
4002
	  <para>Perform any other needed customizations of the
4002
	  <para>Perform any other needed customizations of the
4003
	    <acronym>PXE</acronym> environment in
4003
	    <acronym>PXE</acronym> environment in
4004
	    <filename>${NFSROOTDIR}</filename>.  These customizations
4004
	    <filename>${NFSROOTDIR}</filename>.  These customizations
4005
	    could include things like installing packages or editing
4005
	    could include things like installing packages or editing
4006
	    the password file with &man.vipw.8;.</para>
4006
	    the password file with &man.vipw.8;.</para>
4007
	</step>
4007
	</step>
4008
      </procedure>
4008
      </procedure>
4009
4009
4010
      <para>When booting from an <acronym>NFS</acronym> root volume,
4010
      <para>When booting from an <acronym>NFS</acronym> root volume,
4011
	<filename>/etc/rc</filename> detects the
4011
	<filename>/etc/rc</filename> detects the
4012
	<acronym>NFS</acronym> boot and runs
4012
	<acronym>NFS</acronym> boot and runs
4013
	<filename>/etc/rc.initdiskless</filename>.  In this case,
4013
	<filename>/etc/rc.initdiskless</filename>.  In this case,
4014
	<filename>/etc</filename> and <filename>/var</filename> need
4014
	<filename>/etc</filename> and <filename>/var</filename> need
4015
	to be memory backed file systems so that these directories are
4015
	to be memory backed file systems so that these directories are
4016
	writable but the <acronym>NFS</acronym> root directory is
4016
	writable but the <acronym>NFS</acronym> root directory is
4017
	read-only:</para>
4017
	read-only:</para>
4018
4018
4019
      <screen>&prompt.root; <userinput>chroot ${NFSROOTDIR}</userinput>
4019
      <screen>&prompt.root; <userinput>chroot ${NFSROOTDIR}</userinput>
4020
&prompt.root; <userinput>mkdir -p conf/base</userinput>
4020
&prompt.root; <userinput>mkdir -p conf/base</userinput>
4021
&prompt.root; <userinput>tar -c -v -f conf/base/etc.cpio.gz --format cpio --gzip etc</userinput>
4021
&prompt.root; <userinput>tar -c -v -f conf/base/etc.cpio.gz --format cpio --gzip etc</userinput>
4022
&prompt.root; <userinput>tar -c -v -f conf/base/var.cpio.gz --format cpio --gzip var</userinput></screen>
4022
&prompt.root; <userinput>tar -c -v -f conf/base/var.cpio.gz --format cpio --gzip var</userinput></screen>
4023
4023
4024
      <para>When the system boots, memory file systems for
4024
      <para>When the system boots, memory file systems for
4025
	<filename>/etc</filename> and <filename>/var</filename> will
4025
	<filename>/etc</filename> and <filename>/var</filename> will
4026
	be created and mounted and the contents of the
4026
	be created and mounted and the contents of the
4027
	<filename>cpio.gz</filename> files will be copied into
4027
	<filename>cpio.gz</filename> files will be copied into
4028
	them.</para>
4028
	them.</para>
4029
    </sect2>
4029
    </sect2>
4030
4030
4031
    <sect2 xml:id="network-pxe-setting-up-dhcp">
4031
    <sect2 xml:id="network-pxe-setting-up-dhcp">
4032
      <title>Configuring the <acronym>DHCP</acronym> Server</title>
4032
      <title>Configuring the <acronym>DHCP</acronym> Server</title>
4033
4033
4034
      <indexterm>
4034
      <indexterm>
4035
	<primary>DHCP</primary>
4035
	<primary>DHCP</primary>
4036
	<secondary>diskless operation</secondary>
4036
	<secondary>diskless operation</secondary>
4037
      </indexterm>
4037
      </indexterm>
4038
4038
4039
      <para>The <acronym>DHCP</acronym> server does not need to be the
4039
      <para>The <acronym>DHCP</acronym> server does not need to be the
4040
	same machine as the <acronym>TFTP</acronym> and
4040
	same machine as the <acronym>TFTP</acronym> and
4041
	<acronym>NFS</acronym> server, but it needs to be accessible
4041
	<acronym>NFS</acronym> server, but it needs to be accessible
4042
	in the network.</para>
4042
	in the network.</para>
4043
4043
4044
      <para><acronym>DHCP</acronym> is not part of the &os; base
4044
      <para><acronym>DHCP</acronym> is not part of the &os; base
4045
	system but can be installed using the
4045
	system but can be installed using the
4046
	<package>net/isc-dhcp42-server</package> port or
4046
	<package>net/isc-dhcp43-server</package> port or
4047
	package.</para>
4047
	package.</para>
4048
4048
4049
      <para>Once installed, edit the configuration file,
4049
      <para>Once installed, edit the configuration file,
4050
	<filename>/usr/local/etc/dhcpd.conf</filename>.  Configure
4050
	<filename>/usr/local/etc/dhcpd.conf</filename>.  Configure
4051
	the <literal>next-server</literal>,
4051
	the <literal>next-server</literal>,
4052
	<literal>filename</literal>, and
4052
	<literal>filename</literal>, and
4053
	<literal>root-path</literal> settings as seen in this
4053
	<literal>root-path</literal> settings as seen in this
4054
	example:</para>
4054
	example:</para>
4055
4055
4056
      <programlisting>subnet 192.168.0.0 netmask 255.255.255.0 {
4056
      <programlisting>subnet 192.168.0.0 netmask 255.255.255.0 {
4057
   range 192.168.0.2 192.168.0.3 ;
4057
   range 192.168.0.2 192.168.0.3 ;
4058
   option subnet-mask 255.255.255.0 ;
4058
   option subnet-mask 255.255.255.0 ;
4059
   option routers 192.168.0.1 ;
4059
   option routers 192.168.0.1 ;
4060
   option broadcast-address 192.168.0.255 ;
4060
   option broadcast-address 192.168.0.255 ;
4061
   option domain-name-servers 192.168.35.35, 192.168.35.36 ;
4061
   option domain-name-servers 192.168.35.35, 192.168.35.36 ;
4062
   option domain-name "example.com";
4062
   option domain-name "example.com";
4063
4063
4064
   # IP address of TFTP server
4064
   # IP address of TFTP server
4065
   next-server <replaceable>192.168.0.1</replaceable> ;
4065
   next-server <replaceable>192.168.0.1</replaceable> ;
4066
4066
4067
   # path of boot loader obtained via tftp
4067
   # path of boot loader obtained via tftp
4068
     filename "<replaceable>FreeBSD/install/boot/pxeboot</replaceable>" ;
4068
     filename "<replaceable>FreeBSD/install/boot/pxeboot</replaceable>" ;
4069
4069
4070
   # pxeboot boot loader will try to NFS mount this directory for root FS
4070
   # pxeboot boot loader will try to NFS mount this directory for root FS
4071
   option root-path "<replaceable>192.168.0.1:/b/tftpboot/FreeBSD/install/</replaceable>" ;
4071
   option root-path "<replaceable>192.168.0.1:/b/tftpboot/FreeBSD/install/</replaceable>" ;
4072
4072
4073
}</programlisting>
4073
}</programlisting>
4074
4074
4075
<!--
4075
<!--
4076
 This option still needed?
4076
 This option still needed?
4077
 host corbieres {
4077
 host corbieres {
4078
      <para>This option tells <application>dhcpd</application>
4078
      <para>This option tells <application>dhcpd</application>
4079
	to send the value in the <literal>host</literal>
4079
	to send the value in the <literal>host</literal>
4080
	declarations as the hostname for the diskless host.
4080
	declarations as the hostname for the diskless host.
4081
	An alternate way would be to add an <literal>option
4081
	An alternate way would be to add an <literal>option
4082
	host-name <replaceable>corbieres</replaceable></literal>
4082
	host-name <replaceable>corbieres</replaceable></literal>
4083
	inside the <literal>host</literal> declarations.</para>
4083
	inside the <literal>host</literal> declarations.</para>
4084
-->
4084
-->
4085
4085
4086
      <para>The <literal>next-server</literal> directive is used to
4086
      <para>The <literal>next-server</literal> directive is used to
4087
	specify the <acronym>IP</acronym> address of the
4087
	specify the <acronym>IP</acronym> address of the
4088
	<acronym>TFTP</acronym> server.</para>
4088
	<acronym>TFTP</acronym> server.</para>
4089
4089
4090
      <para>The <literal>filename</literal> directive defines the path
4090
      <para>The <literal>filename</literal> directive defines the path
4091
	to <filename>/boot/pxeboot</filename>.  A relative filename is
4091
	to <filename>/boot/pxeboot</filename>.  A relative filename is
4092
	used, meaning that <filename>/b/tftpboot</filename> is not
4092
	used, meaning that <filename>/b/tftpboot</filename> is not
4093
	included in the path.</para>
4093
	included in the path.</para>
4094
4094
4095
      <para>The <literal>root-path</literal> option defines the path
4095
      <para>The <literal>root-path</literal> option defines the path
4096
	to the <acronym>NFS</acronym> root file system.</para>
4096
	to the <acronym>NFS</acronym> root file system.</para>
4097
4097
4098
      <para>Once the edits are saved, enable <acronym>DHCP</acronym>
4098
      <para>Once the edits are saved, enable <acronym>DHCP</acronym>
4099
	at boot time by adding the following line to
4099
	at boot time by adding the following line to
4100
	<filename>/etc/rc.conf</filename>:</para>
4100
	<filename>/etc/rc.conf</filename>:</para>
4101
4101
4102
      <programlisting>dhcpd_enable="YES"</programlisting>
4102
      <programlisting>dhcpd_enable="YES"</programlisting>
4103
4103
4104
      <para>Then start the <acronym>DHCP</acronym> service:</para>
4104
      <para>Then start the <acronym>DHCP</acronym> service:</para>
4105
4105
4106
      <screen>&prompt.root; <userinput>service isc-dhcpd start</userinput></screen>
4106
      <screen>&prompt.root; <userinput>service isc-dhcpd start</userinput></screen>
4107
    </sect2>
4107
    </sect2>
4108
<!--
4108
<!--
4109
Are these sections still needed?
4109
Are these sections still needed?
4110
    <sect2>
4110
    <sect2>
4111
      <title>Preparing the Root File System</title>
4111
      <title>Preparing the Root File System</title>
4112
4112
4113
      <indexterm>
4113
      <indexterm>
4114
	<primary>diskless operation</primary>
4114
	<primary>diskless operation</primary>
4115
	<secondary>kernel configuration</secondary>
4115
	<secondary>kernel configuration</secondary>
4116
      </indexterm>
4116
      </indexterm>
4117
4117
4118
      <para>When using <acronym>PXE</acronym>, building a custom
4118
      <para>When using <acronym>PXE</acronym>, building a custom
4119
	kernel with the following options is not strictly necessary.
4119
	kernel with the following options is not strictly necessary.
4120
	These options cause more <acronym>DHCP</acronym> requests
4120
	These options cause more <acronym>DHCP</acronym> requests
4121
	to be issued during kernel startup, with a small risk of
4121
	to be issued during kernel startup, with a small risk of
4122
	inconsistency between the new values and those retrieved
4122
	inconsistency between the new values and those retrieved
4123
	by &man.pxeboot.8; in some special cases.  The advantage
4123
	by &man.pxeboot.8; in some special cases.  The advantage
4124
	is that the host name will be set.  Otherwise, set the
4124
	is that the host name will be set.  Otherwise, set the
4125
	host name in a client-specific
4125
	host name in a client-specific
4126
	<filename>/etc/rc.conf</filename>.</para>
4126
	<filename>/etc/rc.conf</filename>.</para>
4127
4127
4128
      <programlisting>options     BOOTP          # Use BOOTP to obtain IP address/hostname
4128
      <programlisting>options     BOOTP          # Use BOOTP to obtain IP address/hostname
4129
options     BOOTP_NFSROOT  # NFS mount root file system using BOOTP info</programlisting>
4129
options     BOOTP_NFSROOT  # NFS mount root file system using BOOTP info</programlisting>
4130
4130
4131
      <para>The custom kernel can also include
4131
      <para>The custom kernel can also include
4132
	<literal>BOOTP_NFSV3</literal>,
4132
	<literal>BOOTP_NFSV3</literal>,
4133
	<literal>BOOT_COMPAT</literal> and
4133
	<literal>BOOT_COMPAT</literal> and
4134
	<literal>BOOTP_WIRED_TO</literal>.  Refer to
4134
	<literal>BOOTP_WIRED_TO</literal>.  Refer to
4135
	<filename>NOTES</filename> for descriptions of these
4135
	<filename>NOTES</filename> for descriptions of these
4136
	options.</para>
4136
	options.</para>
4137
4137
4138
      <para>These option names are historical and slightly
4138
      <para>These option names are historical and slightly
4139
	misleading as they actually enable indifferent use of
4139
	misleading as they actually enable indifferent use of
4140
	<acronym>DHCP</acronym> and <acronym>BOOTP</acronym>
4140
	<acronym>DHCP</acronym> and <acronym>BOOTP</acronym>
4141
	inside the kernel.</para>
4141
	inside the kernel.</para>
4142
4142
4143
      <para>Build the custom kernel, using the instructions in
4143
      <para>Build the custom kernel, using the instructions in
4144
	<xref linkend="kernelconfig"/>, and copy it to the place
4144
	<xref linkend="kernelconfig"/>, and copy it to the place
4145
	specified in
4145
	specified in
4146
	<filename>/usr/local/etc/dhcpd.conf</filename>.</para>
4146
	<filename>/usr/local/etc/dhcpd.conf</filename>.</para>
4147
4147
4148
      <indexterm>
4148
      <indexterm>
4149
	<primary>root file system</primary>
4149
	<primary>root file system</primary>
4150
	<secondary>diskless operation</secondary>
4150
	<secondary>diskless operation</secondary>
4151
      </indexterm>
4151
      </indexterm>
4152
4152
4153
      <para>Create a root file system for the diskless
4153
      <para>Create a root file system for the diskless
4154
	workstations in the location listed as
4154
	workstations in the location listed as
4155
	<literal>root-path</literal> in
4155
	<literal>root-path</literal> in
4156
	<filename>/usr/local/etc/dhcpd.conf</filename>.</para>
4156
	<filename>/usr/local/etc/dhcpd.conf</filename>.</para>
4157
4157
4158
      <para>Using <command>make world</command> to populate root is
4158
      <para>Using <command>make world</command> to populate root is
4159
	quick and will install a complete virgin system, not just
4159
	quick and will install a complete virgin system, not just
4160
	the root file system, into <envar>DESTDIR</envar>.  Execute
4160
	the root file system, into <envar>DESTDIR</envar>.  Execute
4161
	the following script:</para>
4161
	the following script:</para>
4162
4162
4163
      <programlisting>#!/bin/sh
4163
      <programlisting>#!/bin/sh
4164
export DESTDIR=/data/misc/diskless
4164
export DESTDIR=/data/misc/diskless
4165
mkdir -p ${DESTDIR}
4165
mkdir -p ${DESTDIR}
4166
cd /usr/src; make buildworld &amp;&amp; make buildkernel
4166
cd /usr/src; make buildworld &amp;&amp; make buildkernel
4167
make installworld &amp;&amp; make installkernel
4167
make installworld &amp;&amp; make installkernel
4168
cd /usr/src/etc; make distribution</programlisting>
4168
cd /usr/src/etc; make distribution</programlisting>
4169
4169
4170
      <para>Once done, customize
4170
      <para>Once done, customize
4171
	<filename>/etc/rc.conf</filename> and
4171
	<filename>/etc/rc.conf</filename> and
4172
	<filename>/etc/fstab</filename> placed into
4172
	<filename>/etc/fstab</filename> placed into
4173
	<envar>DESTDIR</envar> according to the system's
4173
	<envar>DESTDIR</envar> according to the system's
4174
	requirements.</para>
4174
	requirements.</para>
4175
    </sect2>
4175
    </sect2>
4176
4176
4177
    <sect2>
4177
    <sect2>
4178
      <title>Configuring Swap</title>
4178
      <title>Configuring Swap</title>
4179
4179
4180
      <para>If needed, a swap file located on the server can be
4180
      <para>If needed, a swap file located on the server can be
4181
	accessed via <acronym>NFS</acronym>.</para>
4181
	accessed via <acronym>NFS</acronym>.</para>
4182
4182
4183
      <para>The kernel does not support enabling
4183
      <para>The kernel does not support enabling
4184
	<acronym>NFS</acronym> swap at boot time.  Swap must be
4184
	<acronym>NFS</acronym> swap at boot time.  Swap must be
4185
	enabled by the startup scripts, by mounting a writable
4185
	enabled by the startup scripts, by mounting a writable
4186
	file system and creating and enabling a swap file.  To
4186
	file system and creating and enabling a swap file.  To
4187
	create a swap file:</para>
4187
	create a swap file:</para>
4188
4188
4189
      <screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>/path/to/swapfile</replaceable> bs=1k count=1 oseek=<replaceable>100000</replaceable></userinput></screen>
4189
      <screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>/path/to/swapfile</replaceable> bs=1k count=1 oseek=<replaceable>100000</replaceable></userinput></screen>
4190
4190
4191
      <para>To enable the swap file, add the following line to
4191
      <para>To enable the swap file, add the following line to
4192
	<filename>/etc/rc.conf</filename>:</para>
4192
	<filename>/etc/rc.conf</filename>:</para>
4193
4193
4194
      <programlisting>swapfile=<replaceable>/path/to/swapfile</replaceable></programlisting>
4194
      <programlisting>swapfile=<replaceable>/path/to/swapfile</replaceable></programlisting>
4195
    </sect2>
4195
    </sect2>
4196
4196
4197
    <sect2>
4197
    <sect2>
4198
      <title>Miscellaneous Issues</title>
4198
      <title>Miscellaneous Issues</title>
4199
4199
4200
      <indexterm>
4200
      <indexterm>
4201
	<primary>diskless operation</primary>
4201
	<primary>diskless operation</primary>
4202
	<secondary>/usr read-only</secondary>
4202
	<secondary>/usr read-only</secondary>
4203
      </indexterm>
4203
      </indexterm>
4204
4204
4205
      <para>If the diskless workstation is configured to run
4205
      <para>If the diskless workstation is configured to run
4206
	<application>&xorg;</application> and is running with a
4206
	<application>&xorg;</application> and is running with a
4207
	read-only <filename>/usr</filename>, adjust the
4207
	read-only <filename>/usr</filename>, adjust the
4208
	<application>XDM</application> configuration file as it puts
4208
	<application>XDM</application> configuration file as it puts
4209
	the error log on <filename>/usr</filename> by
4209
	the error log on <filename>/usr</filename> by
4210
	default.</para>
4210
	default.</para>
4211
4211
4212
      <para>When the server for the root file system is not
4212
      <para>When the server for the root file system is not
4213
	running &os;, create the root file system on a &os;
4213
	running &os;, create the root file system on a &os;
4214
	machine, then copy it to its destination, using
4214
	machine, then copy it to its destination, using
4215
	&man.tar.1; or &man.cpio.1;.</para>
4215
	&man.tar.1; or &man.cpio.1;.</para>
4216
4216
4217
      <para>In this situation, there are sometimes problems with
4217
      <para>In this situation, there are sometimes problems with
4218
	the special files in <filename>/dev</filename>, due to
4218
	the special files in <filename>/dev</filename>, due to
4219
	differing major/minor integer sizes.  A solution to this
4219
	differing major/minor integer sizes.  A solution to this
4220
	problem is to export a directory from the non-&os; server,
4220
	problem is to export a directory from the non-&os; server,
4221
	mount this directory onto a &os; machine, and use
4221
	mount this directory onto a &os; machine, and use
4222
	&man.devfs.5; to allocate device nodes transparently for
4222
	&man.devfs.5; to allocate device nodes transparently for
4223
	the user.</para>
4223
	the user.</para>
4224
    </sect2>
4224
    </sect2>
4225
-->
4225
-->
4226
4226
4227
    <sect2>
4227
    <sect2>
4228
      <title>Debugging <acronym>PXE</acronym> Problems</title>
4228
      <title>Debugging <acronym>PXE</acronym> Problems</title>
4229
4229
4230
      <para>Once all of the services are configured and started,
4230
      <para>Once all of the services are configured and started,
4231
	<acronym>PXE</acronym> clients should be able to
4231
	<acronym>PXE</acronym> clients should be able to
4232
	automatically load &os; over the network.  If a particular
4232
	automatically load &os; over the network.  If a particular
4233
	client is unable to connect, when that client machine boots
4233
	client is unable to connect, when that client machine boots
4234
	up, enter the <acronym>BIOS</acronym> configuration menu and
4234
	up, enter the <acronym>BIOS</acronym> configuration menu and
4235
	confirm that it is set to boot from the network.</para>
4235
	confirm that it is set to boot from the network.</para>
4236
4236
4237
      <para>This section describes some troubleshooting tips for
4237
      <para>This section describes some troubleshooting tips for
4238
	isolating the source of the configuration problem should no
4238
	isolating the source of the configuration problem should no
4239
	clients be able to <acronym>PXE</acronym> boot.</para>
4239
	clients be able to <acronym>PXE</acronym> boot.</para>
4240
4240
4241
      <procedure>
4241
      <procedure>
4242
	<step>
4242
	<step>
4243
	  <para>Use the <package>net/wireshark</package> package or
4243
	  <para>Use the <package>net/wireshark</package> package or
4244
	    port to debug the network traffic involved during the
4244
	    port to debug the network traffic involved during the
4245
	    <acronym>PXE</acronym> booting process, which is
4245
	    <acronym>PXE</acronym> booting process, which is
4246
	    illustrated in the diagram below.</para>
4246
	    illustrated in the diagram below.</para>
4247
4247
4248
	  <figure>
4248
	  <figure>
4249
	    <title><acronym>PXE</acronym> Booting Process with
4249
	    <title><acronym>PXE</acronym> Booting Process with
4250
	      <acronym>NFS</acronym> Root Mount</title>
4250
	      <acronym>NFS</acronym> Root Mount</title>
4251
4251
4252
	    <mediaobject>
4252
	    <mediaobject>
4253
	      <imageobjectco>
4253
	      <imageobjectco>
4254
		<areaspec units="calspair">
4254
		<areaspec units="calspair">
4255
		  <area
4255
		  <area
4256
		    xml:id="co-pxenfs1" coords="2873,8133 3313,7266"/>
4256
		    xml:id="co-pxenfs1" coords="2873,8133 3313,7266"/>
4257
		  <area
4257
		  <area
4258
		    xml:id="co-pxenfs2" coords="3519,6333 3885,5500"/>
4258
		    xml:id="co-pxenfs2" coords="3519,6333 3885,5500"/>
4259
		  <area
4259
		  <area
4260
		    xml:id="co-pxenfs3" coords="4780,5866 5102,5200"/>
4260
		    xml:id="co-pxenfs3" coords="4780,5866 5102,5200"/>
4261
		  <area
4261
		  <area
4262
		    xml:id="co-pxenfs4" coords="4794,4333 5102,3600"/>
4262
		    xml:id="co-pxenfs4" coords="4794,4333 5102,3600"/>
4263
		  <area
4263
		  <area
4264
		    xml:id="co-pxenfs5" coords="3108,2666 3519,1800"/>
4264
		    xml:id="co-pxenfs5" coords="3108,2666 3519,1800"/>
4265
		</areaspec>
4265
		</areaspec>
4266
		<imageobject>
4266
		<imageobject>
4267
		  <imagedata fileref="advanced-networking/pxe-nfs"/>
4267
		  <imagedata fileref="advanced-networking/pxe-nfs"/>
4268
		</imageobject>
4268
		</imageobject>
4269
		<calloutlist>
4269
		<calloutlist>
4270
		  <callout arearefs="co-pxenfs1">
4270
		  <callout arearefs="co-pxenfs1">
4271
		    <para>Client broadcasts a
4271
		    <para>Client broadcasts a
4272
		      <literal>DHCPDISCOVER</literal> message.</para>
4272
		      <literal>DHCPDISCOVER</literal> message.</para>
4273
		  </callout>
4273
		  </callout>
4274
		  <callout arearefs="co-pxenfs2">
4274
		  <callout arearefs="co-pxenfs2">
4275
		    <para>The <acronym>DHCP</acronym> server responds
4275
		    <para>The <acronym>DHCP</acronym> server responds
4276
		      with the <acronym>IP</acronym> address,
4276
		      with the <acronym>IP</acronym> address,
4277
		      <literal>next-server</literal>,
4277
		      <literal>next-server</literal>,
4278
		      <literal>filename</literal>, and
4278
		      <literal>filename</literal>, and
4279
		      <literal>root-path</literal> values.</para>
4279
		      <literal>root-path</literal> values.</para>
4280
		  </callout>
4280
		  </callout>
4281
		  <callout arearefs="co-pxenfs3">
4281
		  <callout arearefs="co-pxenfs3">
4282
		    <para>The client sends a <acronym>TFTP</acronym>
4282
		    <para>The client sends a <acronym>TFTP</acronym>
4283
		      request to <literal>next-server</literal>,
4283
		      request to <literal>next-server</literal>,
4284
		      asking to retrieve
4284
		      asking to retrieve
4285
		      <literal>filename</literal>.</para>
4285
		      <literal>filename</literal>.</para>
4286
		  </callout>
4286
		  </callout>
4287
		  <callout arearefs="co-pxenfs4">
4287
		  <callout arearefs="co-pxenfs4">
4288
		    <para>The <acronym>TFTP</acronym> server responds
4288
		    <para>The <acronym>TFTP</acronym> server responds
4289
		      and sends <literal>filename</literal> to
4289
		      and sends <literal>filename</literal> to
4290
		      client.</para>
4290
		      client.</para>
4291
		  </callout>
4291
		  </callout>
4292
		  <callout arearefs="co-pxenfs5">
4292
		  <callout arearefs="co-pxenfs5">
4293
		    <para>The client executes
4293
		    <para>The client executes
4294
		      <literal>filename</literal>, which is
4294
		      <literal>filename</literal>, which is
4295
		      &man.pxeboot.8;, which then loads the kernel.
4295
		      &man.pxeboot.8;, which then loads the kernel.
4296
		      When the kernel executes, the root file system
4296
		      When the kernel executes, the root file system
4297
		      specified by <literal>root-path</literal> is
4297
		      specified by <literal>root-path</literal> is
4298
		      mounted over <acronym>NFS</acronym>.</para>
4298
		      mounted over <acronym>NFS</acronym>.</para>
4299
		  </callout>
4299
		  </callout>
4300
		</calloutlist>
4300
		</calloutlist>
4301
	      </imageobjectco>
4301
	      </imageobjectco>
4302
	    </mediaobject>
4302
	    </mediaobject>
4303
	  </figure>
4303
	  </figure>
4304
	</step>
4304
	</step>
4305
4305
4306
	<step>
4306
	<step>
4307
	  <para>On the
4307
	  <para>On the
4308
	    <acronym>TFTP</acronym> server, read
4308
	    <acronym>TFTP</acronym> server, read
4309
	    <filename>/var/log/xferlog</filename> to ensure that
4309
	    <filename>/var/log/xferlog</filename> to ensure that
4310
	    <filename>pxeboot</filename> is being retrieved from
4310
	    <filename>pxeboot</filename> is being retrieved from
4311
	    the correct location.  To test this example
4311
	    the correct location.  To test this example
4312
	    configuration:</para>
4312
	    configuration:</para>
4313
4313
4314
	  <screen>&prompt.root; <userinput>tftp 192.168.0.1</userinput>
4314
	  <screen>&prompt.root; <userinput>tftp 192.168.0.1</userinput>
4315
tftp&gt; <userinput>get FreeBSD/install/boot/pxeboot</userinput>
4315
tftp&gt; <userinput>get FreeBSD/install/boot/pxeboot</userinput>
4316
Received 264951 bytes in 0.1 seconds</screen>
4316
Received 264951 bytes in 0.1 seconds</screen>
4317
4317
4318
	  <para>The <literal>BUGS</literal> sections in &man.tftpd.8;
4318
	  <para>The <literal>BUGS</literal> sections in &man.tftpd.8;
4319
	    and &man.tftp.1; document some limitations with
4319
	    and &man.tftp.1; document some limitations with
4320
	    <acronym>TFTP</acronym>.</para>
4320
	    <acronym>TFTP</acronym>.</para>
4321
	</step>
4321
	</step>
4322
4322
4323
	<step>
4323
	<step>
4324
	  <para>Make sure that the root file system can be mounted
4324
	  <para>Make sure that the root file system can be mounted
4325
	    via <acronym>NFS</acronym>.  To test this example
4325
	    via <acronym>NFS</acronym>.  To test this example
4326
	    configuration:</para>
4326
	    configuration:</para>
4327
4327
4328
	  <screen>&prompt.root; <userinput>mount -t nfs 192.168.0.1:/b/tftpboot/FreeBSD/install /mnt</userinput></screen>
4328
	  <screen>&prompt.root; <userinput>mount -t nfs 192.168.0.1:/b/tftpboot/FreeBSD/install /mnt</userinput></screen>
4329
	</step>
4329
	</step>
4330
      </procedure>
4330
      </procedure>
4331
    </sect2>
4331
    </sect2>
4332
  </sect1>
4332
  </sect1>
4333
4333
4334
  <sect1 xml:id="network-ipv6">
4334
  <sect1 xml:id="network-ipv6">
4335
    <info>
4335
    <info>
4336
      <title><acronym>IPv6</acronym></title>
4336
      <title><acronym>IPv6</acronym></title>
4337
4337
4338
      <authorgroup>
4338
      <authorgroup>
4339
	<author>
4339
	<author>
4340
	  <personname>
4340
	  <personname>
4341
	    <firstname>Aaron</firstname>
4341
	    <firstname>Aaron</firstname>
4342
	    <surname>Kaplan</surname>
4342
	    <surname>Kaplan</surname>
4343
	  </personname>
4343
	  </personname>
4344
	  <contrib>Originally Written by </contrib>
4344
	  <contrib>Originally Written by </contrib>
4345
	</author>
4345
	</author>
4346
      </authorgroup>
4346
      </authorgroup>
4347
      <authorgroup>
4347
      <authorgroup>
4348
	<author>
4348
	<author>
4349
	  <personname>
4349
	  <personname>
4350
	    <firstname>Tom</firstname>
4350
	    <firstname>Tom</firstname>
4351
	    <surname>Rhodes</surname>
4351
	    <surname>Rhodes</surname>
4352
	  </personname>
4352
	  </personname>
4353
	  <contrib>Restructured and Added by </contrib>
4353
	  <contrib>Restructured and Added by </contrib>
4354
	</author>
4354
	</author>
4355
      </authorgroup>
4355
      </authorgroup>
4356
      <authorgroup>
4356
      <authorgroup>
4357
	<author>
4357
	<author>
4358
	  <personname>
4358
	  <personname>
4359
	    <firstname>Brad</firstname>
4359
	    <firstname>Brad</firstname>
4360
	    <surname>Davis</surname>
4360
	    <surname>Davis</surname>
4361
	  </personname>
4361
	  </personname>
4362
	  <contrib>Extended by </contrib>
4362
	  <contrib>Extended by </contrib>
4363
	</author>
4363
	</author>
4364
      </authorgroup>
4364
      </authorgroup>
4365
    </info>
4365
    </info>
4366
4366
4367
    <para><acronym>IPv6</acronym> is the new version of the well known
4367
    <para><acronym>IPv6</acronym> is the new version of the well known
4368
      <acronym>IP</acronym> protocol, also known as
4368
      <acronym>IP</acronym> protocol, also known as
4369
      <acronym>IPv4</acronym>.  <acronym>IPv6</acronym> provides
4369
      <acronym>IPv4</acronym>.  <acronym>IPv6</acronym> provides
4370
      several advantages over <acronym>IPv4</acronym> as well as many
4370
      several advantages over <acronym>IPv4</acronym> as well as many
4371
      new features:</para>
4371
      new features:</para>
4372
4372
4373
    <itemizedlist>
4373
    <itemizedlist>
4374
      <listitem>
4374
      <listitem>
4375
	<para>Its 128-bit address space allows for
4375
	<para>Its 128-bit address space allows for
4376
	  340,282,366,920,938,463,463,374,607,431,768,211,456
4376
	  340,282,366,920,938,463,463,374,607,431,768,211,456
4377
	  addresses.  This addresses the <acronym>IPv4</acronym>
4377
	  addresses.  This addresses the <acronym>IPv4</acronym>
4378
	  address shortage and eventual <acronym>IPv4</acronym>
4378
	  address shortage and eventual <acronym>IPv4</acronym>
4379
	  address exhaustion.</para>
4379
	  address exhaustion.</para>
4380
      </listitem>
4380
      </listitem>
4381
4381
4382
      <listitem>
4382
      <listitem>
4383
	<para>Routers only store network aggregation addresses in
4383
	<para>Routers only store network aggregation addresses in
4384
	  their routing tables, thus reducing the average space of a
4384
	  their routing tables, thus reducing the average space of a
4385
	  routing table to 8192 entries.  This addresses the
4385
	  routing table to 8192 entries.  This addresses the
4386
	  scalability issues associated with <acronym>IPv4</acronym>,
4386
	  scalability issues associated with <acronym>IPv4</acronym>,
4387
	  which required every allocated block of
4387
	  which required every allocated block of
4388
	  <acronym>IPv4</acronym> addresses to be exchanged between
4388
	  <acronym>IPv4</acronym> addresses to be exchanged between
4389
	  Internet routers, causing their routing tables to become too
4389
	  Internet routers, causing their routing tables to become too
4390
	  large to allow efficient routing.</para>
4390
	  large to allow efficient routing.</para>
4391
      </listitem>
4391
      </listitem>
4392
    </itemizedlist>
4392
    </itemizedlist>
4393
4393
4394
    <itemizedlist>
4394
    <itemizedlist>
4395
      <listitem>
4395
      <listitem>
4396
	<para>Address autoconfiguration (<link
4396
	<para>Address autoconfiguration (<link
4397
	    xlink:href="http://www.ietf.org/rfc/rfc2462.txt">RFC2462</link>).</para>
4397
	    xlink:href="http://www.ietf.org/rfc/rfc2462.txt">RFC2462</link>).</para>
4398
      </listitem>
4398
      </listitem>
4399
4399
4400
      <listitem>
4400
      <listitem>
4401
	<para>Mandatory multicast addresses.</para>
4401
	<para>Mandatory multicast addresses.</para>
4402
      </listitem>
4402
      </listitem>
4403
4403
4404
      <listitem>
4404
      <listitem>
4405
	<para>Built-in <acronym>IPsec</acronym> (<acronym>IP</acronym>
4405
	<para>Built-in <acronym>IPsec</acronym> (<acronym>IP</acronym>
4406
	  security).</para>
4406
	  security).</para>
4407
      </listitem>
4407
      </listitem>
4408
4408
4409
      <listitem>
4409
      <listitem>
4410
	<para>Simplified header structure.</para>
4410
	<para>Simplified header structure.</para>
4411
      </listitem>
4411
      </listitem>
4412
4412
4413
      <listitem>
4413
      <listitem>
4414
	<para>Support for mobile <acronym>IP</acronym>.</para>
4414
	<para>Support for mobile <acronym>IP</acronym>.</para>
4415
      </listitem>
4415
      </listitem>
4416
4416
4417
      <listitem>
4417
      <listitem>
4418
	<para><acronym>IPv6</acronym>-to-<acronym>IPv4</acronym>
4418
	<para><acronym>IPv6</acronym>-to-<acronym>IPv4</acronym>
4419
	  transition mechanisms.</para>
4419
	  transition mechanisms.</para>
4420
      </listitem>
4420
      </listitem>
4421
    </itemizedlist>
4421
    </itemizedlist>
4422
4422
4423
    <para>&os; includes the <link
4423
    <para>&os; includes the <link
4424
	xlink:href="http://www.kame.net/">http://www.kame.net/</link>
4424
	xlink:href="http://www.kame.net/">http://www.kame.net/</link>
4425
      <acronym>IPv6</acronym> reference implementation and comes
4425
      <acronym>IPv6</acronym> reference implementation and comes
4426
      with everything needed to use <acronym>IPv6</acronym>.  This
4426
      with everything needed to use <acronym>IPv6</acronym>.  This
4427
      section focuses on getting <acronym>IPv6</acronym> configured
4427
      section focuses on getting <acronym>IPv6</acronym> configured
4428
      and running.</para>
4428
      and running.</para>
4429
4429
4430
    <sect2>
4430
    <sect2>
4431
      <title>Background on <acronym>IPv6</acronym> Addresses</title>
4431
      <title>Background on <acronym>IPv6</acronym> Addresses</title>
4432
4432
4433
      <para>There are three different types of <acronym>IPv6</acronym>
4433
      <para>There are three different types of <acronym>IPv6</acronym>
4434
	addresses:</para>
4434
	addresses:</para>
4435
4435
4436
      <variablelist>
4436
      <variablelist>
4437
	<varlistentry>
4437
	<varlistentry>
4438
	  <term>Unicast</term>
4438
	  <term>Unicast</term>
4439
	  <listitem>
4439
	  <listitem>
4440
	    <para>A packet sent to a unicast address arrives at the
4440
	    <para>A packet sent to a unicast address arrives at the
4441
	      interface belonging to the address.</para>
4441
	      interface belonging to the address.</para>
4442
	  </listitem>
4442
	  </listitem>
4443
	</varlistentry>
4443
	</varlistentry>
4444
4444
4445
	<varlistentry>
4445
	<varlistentry>
4446
	  <term>Anycast</term>
4446
	  <term>Anycast</term>
4447
	  <listitem>
4447
	  <listitem>
4448
	    <para>These addresses are syntactically indistinguishable
4448
	    <para>These addresses are syntactically indistinguishable
4449
	      from unicast addresses but they address a group of
4449
	      from unicast addresses but they address a group of
4450
	      interfaces.  The packet destined for an anycast address
4450
	      interfaces.  The packet destined for an anycast address
4451
	      will arrive at the nearest router interface.  Anycast
4451
	      will arrive at the nearest router interface.  Anycast
4452
	      addresses are only used by routers.</para>
4452
	      addresses are only used by routers.</para>
4453
	  </listitem>
4453
	  </listitem>
4454
	</varlistentry>
4454
	</varlistentry>
4455
4455
4456
	<varlistentry>
4456
	<varlistentry>
4457
	  <term>Multicast</term>
4457
	  <term>Multicast</term>
4458
	  <listitem>
4458
	  <listitem>
4459
	    <para>These addresses identify a group of interfaces.  A
4459
	    <para>These addresses identify a group of interfaces.  A
4460
	      packet destined for a multicast address will arrive at
4460
	      packet destined for a multicast address will arrive at
4461
	      all interfaces belonging to the multicast group.  The
4461
	      all interfaces belonging to the multicast group.  The
4462
	      <acronym>IPv4</acronym> broadcast address, usually
4462
	      <acronym>IPv4</acronym> broadcast address, usually
4463
	      <systemitem
4463
	      <systemitem
4464
		class="ipaddress">xxx.xxx.xxx.255</systemitem>, is
4464
		class="ipaddress">xxx.xxx.xxx.255</systemitem>, is
4465
	      expressed by multicast addresses in
4465
	      expressed by multicast addresses in
4466
	      <acronym>IPv6</acronym>.</para>
4466
	      <acronym>IPv6</acronym>.</para>
4467
	  </listitem>
4467
	  </listitem>
4468
	</varlistentry>
4468
	</varlistentry>
4469
      </variablelist>
4469
      </variablelist>
4470
4470
4471
      <para>When reading an <acronym>IPv6</acronym> address, the
4471
      <para>When reading an <acronym>IPv6</acronym> address, the
4472
	canonical form is represented as
4472
	canonical form is represented as
4473
	<systemitem>x:x:x:x:x:x:x:x</systemitem>, where each
4473
	<systemitem>x:x:x:x:x:x:x:x</systemitem>, where each
4474
	<literal>x</literal> represents a 16 bit hex value.  An
4474
	<literal>x</literal> represents a 16 bit hex value.  An
4475
	example is
4475
	example is
4476
	<systemitem>FEBC:A574:382B:23C1:AA49:4592:4EFE:9982</systemitem>.</para>
4476
	<systemitem>FEBC:A574:382B:23C1:AA49:4592:4EFE:9982</systemitem>.</para>
4477
4477
4478
      <para>Often, an address will have long substrings of all zeros.
4478
      <para>Often, an address will have long substrings of all zeros.
4479
	A <literal>::</literal> (double colon) can be used to replace
4479
	A <literal>::</literal> (double colon) can be used to replace
4480
	one substring per address.  Also, up to three leading
4480
	one substring per address.  Also, up to three leading
4481
	<literal>0</literal>s per hex value can be omitted.  For
4481
	<literal>0</literal>s per hex value can be omitted.  For
4482
	example, <systemitem>fe80::1</systemitem> corresponds to the
4482
	example, <systemitem>fe80::1</systemitem> corresponds to the
4483
	canonical form
4483
	canonical form
4484
	<systemitem>fe80:0000:0000:0000:0000:0000:0000:0001</systemitem>.</para>
4484
	<systemitem>fe80:0000:0000:0000:0000:0000:0000:0001</systemitem>.</para>
4485
4485
4486
      <para>A third form is to write the last 32 bits using the well
4486
      <para>A third form is to write the last 32 bits using the well
4487
	known <acronym>IPv4</acronym> notation.  For example,
4487
	known <acronym>IPv4</acronym> notation.  For example,
4488
	<systemitem>2002::10.0.0.1</systemitem> corresponds to the
4488
	<systemitem>2002::10.0.0.1</systemitem> corresponds to the
4489
	hexadecimal canonical representation
4489
	hexadecimal canonical representation
4490
	<systemitem>2002:0000:0000:0000:0000:0000:0a00:0001</systemitem>,
4490
	<systemitem>2002:0000:0000:0000:0000:0000:0a00:0001</systemitem>,
4491
	which in turn is equivalent to
4491
	which in turn is equivalent to
4492
	<systemitem>2002::a00:1</systemitem>.</para>
4492
	<systemitem>2002::a00:1</systemitem>.</para>
4493
4493
4494
      <para>To view a &os; system's <acronym>IPv6 </acronym> address,
4494
      <para>To view a &os; system's <acronym>IPv6 </acronym> address,
4495
	use &man.ifconfig.8;:</para>
4495
	use &man.ifconfig.8;:</para>
4496
4496
4497
      <screen>&prompt.root; <userinput>ifconfig</userinput></screen>
4497
      <screen>&prompt.root; <userinput>ifconfig</userinput></screen>
4498
4498
4499
      <programlisting>rl0: flags=8943&lt;UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST&gt; mtu 1500
4499
      <programlisting>rl0: flags=8943&lt;UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST&gt; mtu 1500
4500
         inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255
4500
         inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255
4501
         inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1
4501
         inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1
4502
         ether 00:00:21:03:08:e1
4502
         ether 00:00:21:03:08:e1
4503
         media: Ethernet autoselect (100baseTX )
4503
         media: Ethernet autoselect (100baseTX )
4504
         status: active</programlisting>
4504
         status: active</programlisting>
4505
4505
4506
      <para>In this example, the <filename>rl0</filename> interface is
4506
      <para>In this example, the <filename>rl0</filename> interface is
4507
	using <systemitem>fe80::200:21ff:fe03:8e1%rl0</systemitem>, an
4507
	using <systemitem>fe80::200:21ff:fe03:8e1%rl0</systemitem>, an
4508
	auto-configured link-local address which was automatically
4508
	auto-configured link-local address which was automatically
4509
	generated from the <acronym>MAC</acronym> address.</para>
4509
	generated from the <acronym>MAC</acronym> address.</para>
4510
4510
4511
      <para>Some <acronym>IPv6</acronym> addresses are reserved.  A
4511
      <para>Some <acronym>IPv6</acronym> addresses are reserved.  A
4512
	summary of these reserved addresses is seen in <xref
4512
	summary of these reserved addresses is seen in <xref
4513
	  linkend="reservedip6"/>:</para>
4513
	  linkend="reservedip6"/>:</para>
4514
4514
4515
      <table xml:id="reservedip6" frame="none">
4515
      <table xml:id="reservedip6" frame="none">
4516
	<title>Reserved <acronym>IPv6</acronym> Addresses</title>
4516
	<title>Reserved <acronym>IPv6</acronym> Addresses</title>
4517
4517
4518
	<tgroup cols="4">
4518
	<tgroup cols="4">
4519
	  <thead>
4519
	  <thead>
4520
	    <row>
4520
	    <row>
4521
	      <entry><acronym>IPv6</acronym> address</entry>
4521
	      <entry><acronym>IPv6</acronym> address</entry>
4522
	      <entry>Prefixlength (Bits)</entry>
4522
	      <entry>Prefixlength (Bits)</entry>
4523
	      <entry>Description</entry>
4523
	      <entry>Description</entry>
4524
	      <entry>Notes</entry>
4524
	      <entry>Notes</entry>
4525
	    </row>
4525
	    </row>
4526
	  </thead>
4526
	  </thead>
4527
4527
4528
	  <tbody>
4528
	  <tbody>
4529
	    <row>
4529
	    <row>
4530
	      <entry><systemitem>::</systemitem></entry>
4530
	      <entry><systemitem>::</systemitem></entry>
4531
	      <entry>128 bits</entry>
4531
	      <entry>128 bits</entry>
4532
	      <entry>unspecified</entry>
4532
	      <entry>unspecified</entry>
4533
	      <entry>Equivalent to <systemitem
4533
	      <entry>Equivalent to <systemitem
4534
		  class="ipaddress">0.0.0.0</systemitem> in
4534
		  class="ipaddress">0.0.0.0</systemitem> in
4535
		<acronym>IPv4</acronym>.</entry>
4535
		<acronym>IPv4</acronym>.</entry>
4536
	    </row>
4536
	    </row>
4537
4537
4538
	    <row>
4538
	    <row>
4539
	      <entry><systemitem>::1</systemitem></entry>
4539
	      <entry><systemitem>::1</systemitem></entry>
4540
	      <entry>128 bits</entry>
4540
	      <entry>128 bits</entry>
4541
	      <entry>loopback address</entry>
4541
	      <entry>loopback address</entry>
4542
	      <entry>Equivalent to <systemitem
4542
	      <entry>Equivalent to <systemitem
4543
		  class="ipaddress">127.0.0.1</systemitem> in
4543
		  class="ipaddress">127.0.0.1</systemitem> in
4544
		<acronym>IPv4</acronym>.</entry>
4544
		<acronym>IPv4</acronym>.</entry>
4545
	    </row>
4545
	    </row>
4546
4546
4547
	    <row>
4547
	    <row>
4548
	      <entry><systemitem>::00:xx:xx:xx:xx</systemitem></entry>
4548
	      <entry><systemitem>::00:xx:xx:xx:xx</systemitem></entry>
4549
	      <entry>96 bits</entry>
4549
	      <entry>96 bits</entry>
4550
	      <entry>embedded <acronym>IPv4</acronym></entry>
4550
	      <entry>embedded <acronym>IPv4</acronym></entry>
4551
	      <entry>The lower 32 bits are the compatible
4551
	      <entry>The lower 32 bits are the compatible
4552
		<acronym>IPv4</acronym> address.</entry>
4552
		<acronym>IPv4</acronym> address.</entry>
4553
	    </row>
4553
	    </row>
4554
4554
4555
	    <row>
4555
	    <row>
4556
	      <entry><systemitem>::ff:xx:xx:xx:xx</systemitem></entry>
4556
	      <entry><systemitem>::ff:xx:xx:xx:xx</systemitem></entry>
4557
	      <entry>96 bits</entry>
4557
	      <entry>96 bits</entry>
4558
	      <entry><acronym>IPv4</acronym> mapped
4558
	      <entry><acronym>IPv4</acronym> mapped
4559
		<acronym>IPv6</acronym> address</entry>
4559
		<acronym>IPv6</acronym> address</entry>
4560
	      <entry>The lower 32 bits are the <acronym>IPv4</acronym>
4560
	      <entry>The lower 32 bits are the <acronym>IPv4</acronym>
4561
		address for hosts which do not support
4561
		address for hosts which do not support
4562
		<acronym>IPv6</acronym>.</entry>
4562
		<acronym>IPv6</acronym>.</entry>
4563
	    </row>
4563
	    </row>
4564
4564
4565
	    <row>
4565
	    <row>
4566
	      <entry><systemitem>fe80::/10</systemitem></entry>
4566
	      <entry><systemitem>fe80::/10</systemitem></entry>
4567
	      <entry>10 bits</entry>
4567
	      <entry>10 bits</entry>
4568
	      <entry>link-local</entry>
4568
	      <entry>link-local</entry>
4569
	      <entry>Equivalent to 169.254.0.0/16 in
4569
	      <entry>Equivalent to 169.254.0.0/16 in
4570
		<acronym>IPv4</acronym>.</entry>
4570
		<acronym>IPv4</acronym>.</entry>
4571
	    </row>
4571
	    </row>
4572
4572
4573
	    <row>
4573
	    <row>
4574
	      <entry><systemitem>fc00::/7</systemitem></entry>
4574
	      <entry><systemitem>fc00::/7</systemitem></entry>
4575
	      <entry>7 bits</entry>
4575
	      <entry>7 bits</entry>
4576
	      <entry>unique-local</entry>
4576
	      <entry>unique-local</entry>
4577
	      <entry>Unique local addresses are intended for local
4577
	      <entry>Unique local addresses are intended for local
4578
		communication and are only routable within a set of
4578
		communication and are only routable within a set of
4579
		cooperating sites.</entry>
4579
		cooperating sites.</entry>
4580
	    </row>
4580
	    </row>
4581
4581
4582
	    <row>
4582
	    <row>
4583
	      <entry><systemitem>ff00::</systemitem></entry>
4583
	      <entry><systemitem>ff00::</systemitem></entry>
4584
	      <entry>8 bits</entry>
4584
	      <entry>8 bits</entry>
4585
	      <entry>multicast</entry>
4585
	      <entry>multicast</entry>
4586
	      <entry>&nbsp;</entry>
4586
	      <entry>&nbsp;</entry>
4587
	    </row>
4587
	    </row>
4588
4588
4589
	    <row>
4589
	    <row>
4590
	      <entry><systemitem>2000::-3fff:: </systemitem></entry>
4590
	      <entry><systemitem>2000::-3fff:: </systemitem></entry>
4591
	      <entry>3 bits</entry>
4591
	      <entry>3 bits</entry>
4592
	      <entry>global unicast</entry>
4592
	      <entry>global unicast</entry>
4593
	      <entry>All global unicast addresses are assigned from
4593
	      <entry>All global unicast addresses are assigned from
4594
		this pool.  The first 3 bits are
4594
		this pool.  The first 3 bits are
4595
		<literal>001</literal>.</entry>
4595
		<literal>001</literal>.</entry>
4596
	    </row>
4596
	    </row>
4597
	  </tbody>
4597
	  </tbody>
4598
	</tgroup>
4598
	</tgroup>
4599
      </table>
4599
      </table>
4600
4600
4601
      <para>For further information on the structure of
4601
      <para>For further information on the structure of
4602
	<acronym>IPv6</acronym> addresses, refer to <link
4602
	<acronym>IPv6</acronym> addresses, refer to <link
4603
	  xlink:href="http://www.ietf.org/rfc/rfc3513.txt">RFC3513</link>.</para>
4603
	  xlink:href="http://www.ietf.org/rfc/rfc3513.txt">RFC3513</link>.</para>
4604
    </sect2>
4604
    </sect2>
4605
4605
4606
    <sect2>
4606
    <sect2>
4607
      <title>Configuring <acronym>IPv6</acronym></title>
4607
      <title>Configuring <acronym>IPv6</acronym></title>
4608
4608
4609
      <para>To configure a &os; system as an <acronym>IPv6</acronym>
4609
      <para>To configure a &os; system as an <acronym>IPv6</acronym>
4610
	client, add these two lines to
4610
	client, add these two lines to
4611
	<filename>rc.conf</filename>:</para>
4611
	<filename>rc.conf</filename>:</para>
4612
4612
4613
      <programlisting>ifconfig_<replaceable>rl0</replaceable>_ipv6="inet6 accept_rtadv"
4613
      <programlisting>ifconfig_<replaceable>rl0</replaceable>_ipv6="inet6 accept_rtadv"
4614
rtsold_enable="YES"</programlisting>
4614
rtsold_enable="YES"</programlisting>
4615
4615
4616
      <para>The first line enables the specified interface to receive
4616
      <para>The first line enables the specified interface to receive
4617
	router solicitation messages.  The second line enables the
4617
	router solicitation messages.  The second line enables the
4618
	router solicitation daemon, &man.rtsol.8;.</para>
4618
	router solicitation daemon, &man.rtsol.8;.</para>
4619
4619
4620
      <para>If the interface needs a statically assigned
4620
      <para>If the interface needs a statically assigned
4621
	<acronym>IPv6</acronym> address, add an entry to specify the
4621
	<acronym>IPv6</acronym> address, add an entry to specify the
4622
	static address and associated prefix length:</para>
4622
	static address and associated prefix length:</para>
4623
4623
4624
      <programlisting>ifconfig_<replaceable>rl0</replaceable>_ipv6="inet6 <replaceable>2001:db8:4672:6565:2026:5043:2d42:5344</replaceable> prefixlen <replaceable>64</replaceable>"</programlisting>
4624
      <programlisting>ifconfig_<replaceable>rl0</replaceable>_ipv6="inet6 <replaceable>2001:db8:4672:6565:2026:5043:2d42:5344</replaceable> prefixlen <replaceable>64</replaceable>"</programlisting>
4625
4625
4626
      <para>To assign a default router, specify its address:</para>
4626
      <para>To assign a default router, specify its address:</para>
4627
4627
4628
      <programlisting>ipv6_defaultrouter="<replaceable>2001:db8:4672:6565::1</replaceable>"</programlisting>
4628
      <programlisting>ipv6_defaultrouter="<replaceable>2001:db8:4672:6565::1</replaceable>"</programlisting>
4629
    </sect2>
4629
    </sect2>
4630
4630
4631
    <sect2>
4631
    <sect2>
4632
      <title>Connecting to a Provider</title>
4632
      <title>Connecting to a Provider</title>
4633
4633
4634
      <para>In order to connect to other <acronym>IPv6</acronym>
4634
      <para>In order to connect to other <acronym>IPv6</acronym>
4635
	networks, one must have a provider or a tunnel that supports
4635
	networks, one must have a provider or a tunnel that supports
4636
	<acronym>IPv6</acronym>:</para>
4636
	<acronym>IPv6</acronym>:</para>
4637
4637
4638
      <itemizedlist>
4638
      <itemizedlist>
4639
	<listitem>
4639
	<listitem>
4640
	  <para>Contact an Internet Service Provider to see if they
4640
	  <para>Contact an Internet Service Provider to see if they
4641
	    offer <acronym>IPv6</acronym>.</para>
4641
	    offer <acronym>IPv6</acronym>.</para>
4642
	</listitem>
4642
	</listitem>
4643
4643
4644
	<listitem>
4644
	<listitem>
4645
	  <para><link
4645
	  <para><link
4646
	      xlink:href="http://www.tunnelbroker.net">Hurricane
4646
	      xlink:href="http://www.tunnelbroker.net">Hurricane
4647
	      Electric</link> offers tunnels with end-points all
4647
	      Electric</link> offers tunnels with end-points all
4648
	    around the globe.</para>
4648
	    around the globe.</para>
4649
	</listitem>
4649
	</listitem>
4650
      </itemizedlist>
4650
      </itemizedlist>
4651
4651
4652
      <note>
4652
      <note>
4653
	<para>Install the <package>net/freenet6</package> package or
4653
	<para>Install the <package>net/freenet6</package> package or
4654
	  port for a dial-up connection.</para>
4654
	  port for a dial-up connection.</para>
4655
      </note>
4655
      </note>
4656
4656
4657
      <para>This section demonstrates how to take the directions from
4657
      <para>This section demonstrates how to take the directions from
4658
	a tunnel provider and convert them into
4658
	a tunnel provider and convert them into
4659
	<filename>/etc/rc.conf</filename> settings that will persist
4659
	<filename>/etc/rc.conf</filename> settings that will persist
4660
	through reboots.</para>
4660
	through reboots.</para>
4661
4661
4662
      <para>The first <filename>/etc/rc.conf</filename> entry creates
4662
      <para>The first <filename>/etc/rc.conf</filename> entry creates
4663
	the generic tunneling interface
4663
	the generic tunneling interface
4664
	<filename><replaceable>gif0</replaceable></filename>:</para>
4664
	<filename><replaceable>gif0</replaceable></filename>:</para>
4665
4665
4666
      <programlisting>cloned_interfaces="gif<replaceable>0</replaceable>"</programlisting>
4666
      <programlisting>cloned_interfaces="gif<replaceable>0</replaceable>"</programlisting>
4667
4667
4668
      <para>Next, configure that interface with the
4668
      <para>Next, configure that interface with the
4669
	<acronym>IPv4</acronym> addresses of the local and remote
4669
	<acronym>IPv4</acronym> addresses of the local and remote
4670
	endpoints.  Replace <replaceable>MY_IPv4_ADDR</replaceable>
4670
	endpoints.  Replace <replaceable>MY_IPv4_ADDR</replaceable>
4671
	and <replaceable>REMOTE_IPv4_ADDR</replaceable> with the
4671
	and <replaceable>REMOTE_IPv4_ADDR</replaceable> with the
4672
	actual <acronym>IPv4</acronym> addresses:</para>
4672
	actual <acronym>IPv4</acronym> addresses:</para>
4673
4673
4674
      <programlisting>create_args_gif0="tunnel <replaceable>MY_IPv4_ADDR REMOTE_IPv4_ADDR</replaceable>"</programlisting>
4674
      <programlisting>create_args_gif0="tunnel <replaceable>MY_IPv4_ADDR REMOTE_IPv4_ADDR</replaceable>"</programlisting>
4675
4675
4676
      <para>To apply the <acronym>IPv6</acronym> address that has been
4676
      <para>To apply the <acronym>IPv6</acronym> address that has been
4677
	assigned for use as the <acronym>IPv6</acronym> tunnel
4677
	assigned for use as the <acronym>IPv6</acronym> tunnel
4678
	endpoint, add this line, replacing
4678
	endpoint, add this line, replacing
4679
	<replaceable>MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR</replaceable>
4679
	<replaceable>MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR</replaceable>
4680
	with the assigned address:</para>
4680
	with the assigned address:</para>
4681
4681
4682
      <programlisting>ifconfig_gif0_ipv6="inet6 <replaceable>MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR</replaceable>"</programlisting>
4682
      <programlisting>ifconfig_gif0_ipv6="inet6 <replaceable>MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR</replaceable>"</programlisting>
4683
4683
4684
      <para>Then, set the default route for the other side of the
4684
      <para>Then, set the default route for the other side of the
4685
	<acronym>IPv6</acronym> tunnel.  Replace
4685
	<acronym>IPv6</acronym> tunnel.  Replace
4686
	<replaceable>MY_IPv6_REMOTE_TUNNEL_ENDPOINT_ADDR</replaceable>
4686
	<replaceable>MY_IPv6_REMOTE_TUNNEL_ENDPOINT_ADDR</replaceable>
4687
	with the default gateway address assigned by the
4687
	with the default gateway address assigned by the
4688
	provider:</para>
4688
	provider:</para>
4689
4689
4690
      <programlisting>ipv6_defaultrouter="<replaceable>MY_IPv6_REMOTE_TUNNEL_ENDPOINT_ADDR</replaceable>"</programlisting>
4690
      <programlisting>ipv6_defaultrouter="<replaceable>MY_IPv6_REMOTE_TUNNEL_ENDPOINT_ADDR</replaceable>"</programlisting>
4691
4691
4692
      <para>If the &os; system will route <acronym>IPv6</acronym>
4692
      <para>If the &os; system will route <acronym>IPv6</acronym>
4693
	packets between the rest of the network and the world, enable
4693
	packets between the rest of the network and the world, enable
4694
	the gateway using this line:</para>
4694
	the gateway using this line:</para>
4695
4695
4696
      <programlisting>ipv6_gateway_enable="YES"</programlisting>
4696
      <programlisting>ipv6_gateway_enable="YES"</programlisting>
4697
    </sect2>
4697
    </sect2>
4698
4698
4699
    <sect2>
4699
    <sect2>
4700
      <title>Router Advertisement and Host Auto Configuration</title>
4700
      <title>Router Advertisement and Host Auto Configuration</title>
4701
4701
4702
      <para>This section demonstrates how to setup &man.rtadvd.8; to
4702
      <para>This section demonstrates how to setup &man.rtadvd.8; to
4703
	advertise the <acronym>IPv6</acronym> default route.</para>
4703
	advertise the <acronym>IPv6</acronym> default route.</para>
4704
4704
4705
      <para>To enable &man.rtadvd.8;, add the following to
4705
      <para>To enable &man.rtadvd.8;, add the following to
4706
	<filename>/etc/rc.conf</filename>:</para>
4706
	<filename>/etc/rc.conf</filename>:</para>
4707
4707
4708
      <programlisting>rtadvd_enable="YES"</programlisting>
4708
      <programlisting>rtadvd_enable="YES"</programlisting>
4709
4709
4710
      <para>It is important to specify the interface on which to
4710
      <para>It is important to specify the interface on which to
4711
	do <acronym>IPv6</acronym> router solicitation.  For example,
4711
	do <acronym>IPv6</acronym> router solicitation.  For example,
4712
	to tell &man.rtadvd.8; to use
4712
	to tell &man.rtadvd.8; to use
4713
	<filename>rl0</filename>:</para>
4713
	<filename>rl0</filename>:</para>
4714
4714
4715
      <programlisting>rtadvd_interfaces="rl0"</programlisting>
4715
      <programlisting>rtadvd_interfaces="rl0"</programlisting>
4716
4716
4717
      <para>Next, create the configuration file,
4717
      <para>Next, create the configuration file,
4718
	<filename>/etc/rtadvd.conf</filename> as seen in this
4718
	<filename>/etc/rtadvd.conf</filename> as seen in this
4719
	example:</para>
4719
	example:</para>
4720
4720
4721
      <programlisting>rl0:\
4721
      <programlisting>rl0:\
4722
	:addrs#1:addr="2001:db8:1f11:246::":prefixlen#64:tc=ether:</programlisting>
4722
	:addrs#1:addr="2001:db8:1f11:246::":prefixlen#64:tc=ether:</programlisting>
4723
4723
4724
      <para>Replace <filename>rl0</filename> with the interface
4724
      <para>Replace <filename>rl0</filename> with the interface
4725
	to be used and <systemitem>2001:db8:1f11:246::</systemitem>
4725
	to be used and <systemitem>2001:db8:1f11:246::</systemitem>
4726
	with the prefix of the allocation.</para>
4726
	with the prefix of the allocation.</para>
4727
4727
4728
      <para>For a dedicated <systemitem
4728
      <para>For a dedicated <systemitem
4729
	  class="netmask">/64</systemitem> subnet, nothing else needs
4729
	  class="netmask">/64</systemitem> subnet, nothing else needs
4730
	to be changed.  Otherwise, change the
4730
	to be changed.  Otherwise, change the
4731
	<literal>prefixlen#</literal> to the correct value.</para>
4731
	<literal>prefixlen#</literal> to the correct value.</para>
4732
    </sect2>
4732
    </sect2>
4733
4733
4734
    <sect2>
4734
    <sect2>
4735
      <title><acronym>IPv6</acronym> and <acronym>IPv6</acronym>
4735
      <title><acronym>IPv6</acronym> and <acronym>IPv6</acronym>
4736
	Address Mapping</title>
4736
	Address Mapping</title>
4737
4737
4738
      <para>When <acronym>IPv6</acronym> is enabled on a server, there
4738
      <para>When <acronym>IPv6</acronym> is enabled on a server, there
4739
	may be a need to enable <acronym>IPv4</acronym> mapped
4739
	may be a need to enable <acronym>IPv4</acronym> mapped
4740
	<acronym>IPv6</acronym> address communication.  This
4740
	<acronym>IPv6</acronym> address communication.  This
4741
	compatibility option allows for <acronym>IPv4</acronym>
4741
	compatibility option allows for <acronym>IPv4</acronym>
4742
	addresses to be represented as <acronym>IPv6</acronym>
4742
	addresses to be represented as <acronym>IPv6</acronym>
4743
	addresses.  Permitting <acronym>IPv6</acronym> applications
4743
	addresses.  Permitting <acronym>IPv6</acronym> applications
4744
	to communicate with <acronym>IPv4</acronym> and vice versa
4744
	to communicate with <acronym>IPv4</acronym> and vice versa
4745
	may be a security issue.</para>
4745
	may be a security issue.</para>
4746
4746
4747
      <para>This option may not be required in most cases and is
4747
      <para>This option may not be required in most cases and is
4748
	available only for compatibility.  This option will allow
4748
	available only for compatibility.  This option will allow
4749
	<acronym>IPv6</acronym>-only applications to work with
4749
	<acronym>IPv6</acronym>-only applications to work with
4750
	<acronym>IPv4</acronym> in a dual stack environment.  This
4750
	<acronym>IPv4</acronym> in a dual stack environment.  This
4751
	is most useful for third party applications which may not
4751
	is most useful for third party applications which may not
4752
	support an <acronym>IPv6</acronym>-only environment.  To
4752
	support an <acronym>IPv6</acronym>-only environment.  To
4753
	enable this feature,
4753
	enable this feature,
4754
	add the following to <filename>/etc/rc.conf</filename>:</para>
4754
	add the following to <filename>/etc/rc.conf</filename>:</para>
4755
4755
4756
      <programlisting>ipv6_ipv4mapping="YES"</programlisting>
4756
      <programlisting>ipv6_ipv4mapping="YES"</programlisting>
4757
4757
4758
      <para>Reviewing the information in <acronym>RFC</acronym> 3493,
4758
      <para>Reviewing the information in <acronym>RFC</acronym> 3493,
4759
	section 3.6 and 3.7 as well as <acronym>RFC</acronym> 4038
4759
	section 3.6 and 3.7 as well as <acronym>RFC</acronym> 4038
4760
	section 4.2 may be useful to some administrators.</para>
4760
	section 4.2 may be useful to some administrators.</para>
4761
    </sect2>
4761
    </sect2>
4762
  </sect1>
4762
  </sect1>
4763
<!--
4763
<!--
4764
  <sect1 xml:id="network-atm">
4764
  <sect1 xml:id="network-atm">
4765
    <info><title>Asynchronous Transfer Mode (<acronym>ATM</acronym>)</title>
4765
    <info><title>Asynchronous Transfer Mode (<acronym>ATM</acronym>)</title>
4766
      <authorgroup>
4766
      <authorgroup>
4767
	<author>
4767
	<author>
4768
	  <personname>
4768
	  <personname>
4769
	    <firstname>Harti</firstname>
4769
	    <firstname>Harti</firstname>
4770
	    <surname>Brandt</surname>
4770
	    <surname>Brandt</surname>
4771
	  </personname>
4771
	  </personname>
4772
	  <contrib>Contributed by </contrib>
4772
	  <contrib>Contributed by </contrib>
4773
	</author>
4773
	</author>
4774
      </authorgroup>
4774
      </authorgroup>
4775
    </info>
4775
    </info>
4776
    <sect2>
4776
    <sect2>
4777
      <title>Configuring Classical <acronym>IP</acronym> over
4777
      <title>Configuring Classical <acronym>IP</acronym> over
4778
	<acronym>ATM</acronym></title>
4778
	<acronym>ATM</acronym></title>
4779
4779
4780
      <para>Classical <acronym>IP</acronym> over
4780
      <para>Classical <acronym>IP</acronym> over
4781
	<acronym>ATM</acronym> (<acronym>CLIP</acronym>) is the
4781
	<acronym>ATM</acronym> (<acronym>CLIP</acronym>) is the
4782
	simplest method to use Asynchronous Transfer Mode
4782
	simplest method to use Asynchronous Transfer Mode
4783
	(<acronym>ATM</acronym>) with <acronym>IP</acronym>.  It can
4783
	(<acronym>ATM</acronym>) with <acronym>IP</acronym>.  It can
4784
	be used with Switched Virtual Circuits
4784
	be used with Switched Virtual Circuits
4785
	(<acronym>SVC</acronym>s) and with Permanent Virtual Circuits
4785
	(<acronym>SVC</acronym>s) and with Permanent Virtual Circuits
4786
	(<acronym>PVC</acronym>s).  This section describes how to
4786
	(<acronym>PVC</acronym>s).  This section describes how to
4787
	set up a network based on <acronym>PVC</acronym>s.</para>
4787
	set up a network based on <acronym>PVC</acronym>s.</para>
4788
4788
4789
      <sect3>
4789
      <sect3>
4790
	<title>Fully Meshed Configurations</title>
4790
	<title>Fully Meshed Configurations</title>
4791
4791
4792
	<para>The first method to set up a <acronym>CLIP</acronym>
4792
	<para>The first method to set up a <acronym>CLIP</acronym>
4793
	  with <acronym>PVC</acronym>s is to connect each machine
4793
	  with <acronym>PVC</acronym>s is to connect each machine
4794
	  to each other machine in the network via a dedicated
4794
	  to each other machine in the network via a dedicated
4795
	  <acronym>PVC</acronym>.  While this is simple to
4795
	  <acronym>PVC</acronym>.  While this is simple to
4796
	  configure, it becomes impractical for a large number of
4796
	  configure, it becomes impractical for a large number of
4797
	  machines.  The following example supposes four machines in
4797
	  machines.  The following example supposes four machines in
4798
	  the network, each connected to the <acronym role="Asynchronous Transfer Mode">ATM</acronym> network
4798
	  the network, each connected to the <acronym role="Asynchronous Transfer Mode">ATM</acronym> network
4799
	  with an <acronym role="Asynchronous Transfer Mode">ATM</acronym> adapter
4799
	  with an <acronym role="Asynchronous Transfer Mode">ATM</acronym> adapter
4800
	  card.  The first step is the planning of the
4800
	  card.  The first step is the planning of the
4801
	  <acronym>IP</acronym> addresses and the <acronym role="Asynchronous Transfer Mode">ATM</acronym>
4801
	  <acronym>IP</acronym> addresses and the <acronym role="Asynchronous Transfer Mode">ATM</acronym>
4802
	  connections between the machines.  This example uses the
4802
	  connections between the machines.  This example uses the
4803
	  following:</para>
4803
	  following:</para>
4804
4804
4805
	<informaltable frame="none" pgwide="1">
4805
	<informaltable frame="none" pgwide="1">
4806
	  <tgroup cols="2">
4806
	  <tgroup cols="2">
4807
	    <colspec colwidth="1*"/>
4807
	    <colspec colwidth="1*"/>
4808
	    <colspec colwidth="1*"/>
4808
	    <colspec colwidth="1*"/>
4809
	    <thead>
4809
	    <thead>
4810
	      <row>
4810
	      <row>
4811
		<entry>Host</entry>
4811
		<entry>Host</entry>
4812
		<entry><acronym>IP</acronym> Address</entry>
4812
		<entry><acronym>IP</acronym> Address</entry>
4813
	      </row>
4813
	      </row>
4814
	    </thead>
4814
	    </thead>
4815
4815
4816
	    <tbody>
4816
	    <tbody>
4817
	      <row>
4817
	      <row>
4818
		<entry><systemitem>hostA</systemitem></entry>
4818
		<entry><systemitem>hostA</systemitem></entry>
4819
		<entry><systemitem class="ipaddress">192.168.173.1</systemitem></entry>
4819
		<entry><systemitem class="ipaddress">192.168.173.1</systemitem></entry>
4820
	      </row>
4820
	      </row>
4821
4821
4822
	      <row>
4822
	      <row>
4823
		<entry><systemitem>hostB</systemitem></entry>
4823
		<entry><systemitem>hostB</systemitem></entry>
4824
		<entry><systemitem class="ipaddress">192.168.173.2</systemitem></entry>
4824
		<entry><systemitem class="ipaddress">192.168.173.2</systemitem></entry>
4825
	      </row>
4825
	      </row>
4826
4826
4827
	      <row>
4827
	      <row>
4828
		<entry><systemitem>hostC</systemitem></entry>
4828
		<entry><systemitem>hostC</systemitem></entry>
4829
		<entry><systemitem class="ipaddress">192.168.173.3</systemitem></entry>
4829
		<entry><systemitem class="ipaddress">192.168.173.3</systemitem></entry>
4830
	      </row>
4830
	      </row>
4831
4831
4832
	      <row>
4832
	      <row>
4833
		<entry><systemitem>hostD</systemitem></entry>
4833
		<entry><systemitem>hostD</systemitem></entry>
4834
		<entry><systemitem class="ipaddress">192.168.173.4</systemitem></entry>
4834
		<entry><systemitem class="ipaddress">192.168.173.4</systemitem></entry>
4835
	      </row>
4835
	      </row>
4836
	    </tbody>
4836
	    </tbody>
4837
	  </tgroup>
4837
	  </tgroup>
4838
	</informaltable>
4838
	</informaltable>
4839
4839
4840
	<para>To build a fully meshed net, one <acronym>ATM</acronym>
4840
	<para>To build a fully meshed net, one <acronym>ATM</acronym>
4841
	  connection is needed between each pair of machines:</para>
4841
	  connection is needed between each pair of machines:</para>
4842
4842
4843
	<informaltable frame="none" pgwide="1">
4843
	<informaltable frame="none" pgwide="1">
4844
	  <tgroup cols="2">
4844
	  <tgroup cols="2">
4845
	    <colspec colwidth="1*"/>
4845
	    <colspec colwidth="1*"/>
4846
	    <colspec colwidth="1*"/>
4846
	    <colspec colwidth="1*"/>
4847
	    <thead>
4847
	    <thead>
4848
	      <row>
4848
	      <row>
4849
		<entry>Machines</entry>
4849
		<entry>Machines</entry>
4850
		<entry>VPI.VCI couple</entry>
4850
		<entry>VPI.VCI couple</entry>
4851
	      </row>
4851
	      </row>
4852
	    </thead>
4852
	    </thead>
4853
4853
4854
	    <tbody>
4854
	    <tbody>
4855
	      <row>
4855
	      <row>
4856
		<entry><systemitem>hostA</systemitem> -
4856
		<entry><systemitem>hostA</systemitem> -
4857
		  <systemitem>hostB</systemitem></entry>
4857
		  <systemitem>hostB</systemitem></entry>
4858
		<entry>0.100</entry>
4858
		<entry>0.100</entry>
4859
	      </row>
4859
	      </row>
4860
4860
4861
	      <row>
4861
	      <row>
4862
		<entry><systemitem>hostA</systemitem> -
4862
		<entry><systemitem>hostA</systemitem> -
4863
		  <systemitem>hostC</systemitem></entry>
4863
		  <systemitem>hostC</systemitem></entry>
4864
		<entry>0.101</entry>
4864
		<entry>0.101</entry>
4865
	      </row>
4865
	      </row>
4866
4866
4867
	      <row>
4867
	      <row>
4868
		<entry><systemitem>hostA</systemitem> -
4868
		<entry><systemitem>hostA</systemitem> -
4869
		  <systemitem>hostD</systemitem></entry>
4869
		  <systemitem>hostD</systemitem></entry>
4870
		<entry>0.102</entry>
4870
		<entry>0.102</entry>
4871
	      </row>
4871
	      </row>
4872
4872
4873
	      <row>
4873
	      <row>
4874
		<entry><systemitem>hostB</systemitem> -
4874
		<entry><systemitem>hostB</systemitem> -
4875
		  <systemitem>hostC</systemitem></entry>
4875
		  <systemitem>hostC</systemitem></entry>
4876
		<entry>0.103</entry>
4876
		<entry>0.103</entry>
4877
	      </row>
4877
	      </row>
4878
4878
4879
	      <row>
4879
	      <row>
4880
		<entry><systemitem>hostB</systemitem> -
4880
		<entry><systemitem>hostB</systemitem> -
4881
		  <systemitem>hostD</systemitem></entry>
4881
		  <systemitem>hostD</systemitem></entry>
4882
		<entry>0.104</entry>
4882
		<entry>0.104</entry>
4883
	      </row>
4883
	      </row>
4884
4884
4885
	      <row>
4885
	      <row>
4886
		<entry><systemitem>hostC</systemitem> -
4886
		<entry><systemitem>hostC</systemitem> -
4887
		  <systemitem>hostD</systemitem></entry>
4887
		  <systemitem>hostD</systemitem></entry>
4888
		<entry>0.105</entry>
4888
		<entry>0.105</entry>
4889
	      </row>
4889
	      </row>
4890
	    </tbody>
4890
	    </tbody>
4891
	  </tgroup>
4891
	  </tgroup>
4892
	</informaltable>
4892
	</informaltable>
4893
4893
4894
	<para>The Virtual Path Identifier <acronym>VPI</acronym> and
4894
	<para>The Virtual Path Identifier <acronym>VPI</acronym> and
4895
	  Virtual Channel Identifier <acronym>VCI</acronym> values
4895
	  Virtual Channel Identifier <acronym>VCI</acronym> values
4896
	  at each end of the connection may differ, but for
4896
	  at each end of the connection may differ, but for
4897
	  simplicity, this example assumes they are the same.  Next,
4897
	  simplicity, this example assumes they are the same.  Next,
4898
	  configure the <acronym>ATM</acronym> interfaces on each
4898
	  configure the <acronym>ATM</acronym> interfaces on each
4899
	  host:</para>
4899
	  host:</para>
4900
4900
4901
	<screen>hostA&prompt.root; <userinput>ifconfig hatm0 192.168.173.1 up</userinput>
4901
	<screen>hostA&prompt.root; <userinput>ifconfig hatm0 192.168.173.1 up</userinput>
4902
hostB&prompt.root; <userinput>ifconfig hatm0 192.168.173.2 up</userinput>
4902
hostB&prompt.root; <userinput>ifconfig hatm0 192.168.173.2 up</userinput>
4903
hostC&prompt.root; <userinput>ifconfig hatm0 192.168.173.3 up</userinput>
4903
hostC&prompt.root; <userinput>ifconfig hatm0 192.168.173.3 up</userinput>
4904
hostD&prompt.root; <userinput>ifconfig hatm0 192.168.173.4 up</userinput></screen>
4904
hostD&prompt.root; <userinput>ifconfig hatm0 192.168.173.4 up</userinput></screen>
4905
4905
4906
	<para>This example assumes that the <acronym>ATM</acronym>
4906
	<para>This example assumes that the <acronym>ATM</acronym>
4907
	  interface is <filename>hatm0</filename> on all hosts.
4907
	  interface is <filename>hatm0</filename> on all hosts.
4908
	  Next, the <acronym>PVC</acronym>s need to be configured on
4908
	  Next, the <acronym>PVC</acronym>s need to be configured on
4909
	  <systemitem>hostA</systemitem>.  This should already be
4909
	  <systemitem>hostA</systemitem>.  This should already be
4910
	  configured on the <acronym>ATM</acronym> switch; consult the
4910
	  configured on the <acronym>ATM</acronym> switch; consult the
4911
	  manual for the switch on how to do this.</para>
4911
	  manual for the switch on how to do this.</para>
4912
4912
4913
	<screen>hostA&prompt.root; <userinput>atmconfig natm add 192.168.173.2 hatm0 0 100 llc/snap ubr</userinput>
4913
	<screen>hostA&prompt.root; <userinput>atmconfig natm add 192.168.173.2 hatm0 0 100 llc/snap ubr</userinput>
4914
hostA&prompt.root; <userinput>atmconfig natm add 192.168.173.3 hatm0 0 101 llc/snap ubr</userinput>
4914
hostA&prompt.root; <userinput>atmconfig natm add 192.168.173.3 hatm0 0 101 llc/snap ubr</userinput>
4915
hostA&prompt.root; <userinput>atmconfig natm add 192.168.173.4 hatm0 0 102 llc/snap ubr</userinput>
4915
hostA&prompt.root; <userinput>atmconfig natm add 192.168.173.4 hatm0 0 102 llc/snap ubr</userinput>
4916
4916
4917
hostB&prompt.root; <userinput>atmconfig natm add 192.168.173.1 hatm0 0 100 llc/snap ubr</userinput>
4917
hostB&prompt.root; <userinput>atmconfig natm add 192.168.173.1 hatm0 0 100 llc/snap ubr</userinput>
4918
hostB&prompt.root; <userinput>atmconfig natm add 192.168.173.3 hatm0 0 103 llc/snap ubr</userinput>
4918
hostB&prompt.root; <userinput>atmconfig natm add 192.168.173.3 hatm0 0 103 llc/snap ubr</userinput>
4919
hostB&prompt.root; <userinput>atmconfig natm add 192.168.173.4 hatm0 0 104 llc/snap ubr</userinput>
4919
hostB&prompt.root; <userinput>atmconfig natm add 192.168.173.4 hatm0 0 104 llc/snap ubr</userinput>
4920
4920
4921
hostC&prompt.root; <userinput>atmconfig natm add 192.168.173.1 hatm0 0 101 llc/snap ubr</userinput>
4921
hostC&prompt.root; <userinput>atmconfig natm add 192.168.173.1 hatm0 0 101 llc/snap ubr</userinput>
4922
hostC&prompt.root; <userinput>atmconfig natm add 192.168.173.2 hatm0 0 103 llc/snap ubr</userinput>
4922
hostC&prompt.root; <userinput>atmconfig natm add 192.168.173.2 hatm0 0 103 llc/snap ubr</userinput>
4923
hostC&prompt.root; <userinput>atmconfig natm add 192.168.173.4 hatm0 0 105 llc/snap ubr</userinput>
4923
hostC&prompt.root; <userinput>atmconfig natm add 192.168.173.4 hatm0 0 105 llc/snap ubr</userinput>
4924
4924
4925
hostD&prompt.root; <userinput>atmconfig natm add 192.168.173.1 hatm0 0 102 llc/snap ubr</userinput>
4925
hostD&prompt.root; <userinput>atmconfig natm add 192.168.173.1 hatm0 0 102 llc/snap ubr</userinput>
4926
hostD&prompt.root; <userinput>atmconfig natm add 192.168.173.2 hatm0 0 104 llc/snap ubr</userinput>
4926
hostD&prompt.root; <userinput>atmconfig natm add 192.168.173.2 hatm0 0 104 llc/snap ubr</userinput>
4927
hostD&prompt.root; <userinput>atmconfig natm add 192.168.173.3 hatm0 0 105 llc/snap ubr</userinput></screen>
4927
hostD&prompt.root; <userinput>atmconfig natm add 192.168.173.3 hatm0 0 105 llc/snap ubr</userinput></screen>
4928
4928
4929
	<para>Other traffic contracts besides <literal>ubr</literal>
4929
	<para>Other traffic contracts besides <literal>ubr</literal>
4930
	  can be used if the <acronym>ATM</acronym> adapter supports
4930
	  can be used if the <acronym>ATM</acronym> adapter supports
4931
	  it.  In this case, the name of the traffic contract is
4931
	  it.  In this case, the name of the traffic contract is
4932
	  followed by the parameters of the traffic.  Help for the
4932
	  followed by the parameters of the traffic.  Help for the
4933
	  &man.atmconfig.8; tool can be obtained with:</para>
4933
	  &man.atmconfig.8; tool can be obtained with:</para>
4934
4934
4935
	<screen>&prompt.root; <userinput>atmconfig help natm add</userinput></screen>
4935
	<screen>&prompt.root; <userinput>atmconfig help natm add</userinput></screen>
4936
4936
4937
	<para>Refer to &man.atmconfig.8; for more information.</para>
4937
	<para>Refer to &man.atmconfig.8; for more information.</para>
4938
4938
4939
	<para>The same configuration can also be done via
4939
	<para>The same configuration can also be done via
4940
	  <filename>/etc/rc.conf</filename>.  These lines configure
4940
	  <filename>/etc/rc.conf</filename>.  These lines configure
4941
	  <systemitem>hostA</systemitem>:</para>
4941
	  <systemitem>hostA</systemitem>:</para>
4942
4942
4943
	<programlisting>network_interfaces="lo0 hatm0"
4943
	<programlisting>network_interfaces="lo0 hatm0"
4944
ifconfig_hatm0="inet 192.168.173.1 up"
4944
ifconfig_hatm0="inet 192.168.173.1 up"
4945
natm_static_routes="hostB hostC hostD"
4945
natm_static_routes="hostB hostC hostD"
4946
route_hostB="192.168.173.2 hatm0 0 100 llc/snap ubr"
4946
route_hostB="192.168.173.2 hatm0 0 100 llc/snap ubr"
4947
route_hostC="192.168.173.3 hatm0 0 101 llc/snap ubr"
4947
route_hostC="192.168.173.3 hatm0 0 101 llc/snap ubr"
4948
route_hostD="192.168.173.4 hatm0 0 102 llc/snap ubr"</programlisting>
4948
route_hostD="192.168.173.4 hatm0 0 102 llc/snap ubr"</programlisting>
4949
4949
4950
	<para>The current state of all <acronym>CLIP</acronym> routes
4950
	<para>The current state of all <acronym>CLIP</acronym> routes
4951
	  can be obtained with:</para>
4951
	  can be obtained with:</para>
4952
4952
4953
	<screen>hostA&prompt.root; <userinput>atmconfig natm show</userinput></screen>
4953
	<screen>hostA&prompt.root; <userinput>atmconfig natm show</userinput></screen>
4954
      </sect3>
4954
      </sect3>
4955
    </sect2>
4955
    </sect2>
4956
  </sect1>
4956
  </sect1>
4957
  -->
4957
  -->
4958
  <sect1 xml:id="carp">
4958
  <sect1 xml:id="carp">
4959
    <info>
4959
    <info>
4960
      <title>Common Address Redundancy Protocol
4960
      <title>Common Address Redundancy Protocol
4961
	(<acronym>CARP</acronym>)</title>
4961
	(<acronym>CARP</acronym>)</title>
4962
4962
4963
      <authorgroup>
4963
      <authorgroup>
4964
	<author>
4964
	<author>
4965
	  <personname>
4965
	  <personname>
4966
	    <firstname>Tom</firstname>
4966
	    <firstname>Tom</firstname>
4967
	    <surname>Rhodes</surname>
4967
	    <surname>Rhodes</surname>
4968
	  </personname>
4968
	  </personname>
4969
	  <contrib>Contributed by </contrib>
4969
	  <contrib>Contributed by </contrib>
4970
	</author>
4970
	</author>
4971
      </authorgroup>
4971
      </authorgroup>
4972
      <authorgroup>
4972
      <authorgroup>
4973
	<author>
4973
	<author>
4974
	  <personname>
4974
	  <personname>
4975
	    <firstname>Allan</firstname>
4975
	    <firstname>Allan</firstname>
4976
	    <surname>Jude</surname>
4976
	    <surname>Jude</surname>
4977
	  </personname>
4977
	  </personname>
4978
	  <contrib>Updated by </contrib>
4978
	  <contrib>Updated by </contrib>
4979
	</author>
4979
	</author>
4980
      </authorgroup>
4980
      </authorgroup>
4981
    </info>
4981
    </info>
4982
4982
4983
    <indexterm>
4983
    <indexterm>
4984
      <primary><acronym>CARP</acronym></primary>
4984
      <primary><acronym>CARP</acronym></primary>
4985
    </indexterm>
4985
    </indexterm>
4986
    <indexterm>
4986
    <indexterm>
4987
      <primary>Common Address Redundancy Protocol</primary>
4987
      <primary>Common Address Redundancy Protocol</primary>
4988
    </indexterm>
4988
    </indexterm>
4989
4989
4990
    <para>The Common Address Redundancy Protocol
4990
    <para>The Common Address Redundancy Protocol
4991
      (<acronym>CARP</acronym>) allows multiple hosts to share the
4991
      (<acronym>CARP</acronym>) allows multiple hosts to share the
4992
      same <acronym>IP</acronym> address and Virtual Host ID
4992
      same <acronym>IP</acronym> address and Virtual Host ID
4993
      (<acronym>VHID</acronym>) in order to provide <firstterm>high
4993
      (<acronym>VHID</acronym>) in order to provide <firstterm>high
4994
      availability</firstterm> for one or more services.  This means
4994
      availability</firstterm> for one or more services.  This means
4995
      that one or more hosts can fail, and the other hosts will
4995
      that one or more hosts can fail, and the other hosts will
4996
      transparently take over so that users do not see a service
4996
      transparently take over so that users do not see a service
4997
      failure.</para>
4997
      failure.</para>
4998
4998
4999
    <para>In addition to the shared <acronym>IP</acronym> address,
4999
    <para>In addition to the shared <acronym>IP</acronym> address,
5000
      each host has its own <acronym>IP</acronym> address for
5000
      each host has its own <acronym>IP</acronym> address for
5001
      management and configuration.  All of the machines that share an
5001
      management and configuration.  All of the machines that share an
5002
      <acronym>IP</acronym> address have the same
5002
      <acronym>IP</acronym> address have the same
5003
      <acronym>VHID</acronym>.  The <acronym>VHID</acronym> for each
5003
      <acronym>VHID</acronym>.  The <acronym>VHID</acronym> for each
5004
      virtual <acronym>IP</acronym> address must be unique across the
5004
      virtual <acronym>IP</acronym> address must be unique across the
5005
      broadcast domain of the network interface.</para>
5005
      broadcast domain of the network interface.</para>
5006
5006
5007
    <para>High availability using <acronym>CARP</acronym> is built
5007
    <para>High availability using <acronym>CARP</acronym> is built
5008
      into &os;, though the steps to configure it vary slightly
5008
      into &os;, though the steps to configure it vary slightly
5009
      depending upon the &os; version.  This section provides the same
5009
      depending upon the &os; version.  This section provides the same
5010
      example configuration for versions before and equal to or after
5010
      example configuration for versions before and equal to or after
5011
      &os;&nbsp;10.</para>
5011
      &os;&nbsp;10.</para>
5012
5012
5013
    <para>This example configures failover support with three hosts,
5013
    <para>This example configures failover support with three hosts,
5014
      all with unique <acronym>IP</acronym> addresses, but providing
5014
      all with unique <acronym>IP</acronym> addresses, but providing
5015
      the same web content.  It has two different masters named
5015
      the same web content.  It has two different masters named
5016
      <systemitem>hosta.example.org</systemitem> and
5016
      <systemitem>hosta.example.org</systemitem> and
5017
      <systemitem>hostb.example.org</systemitem>, with a shared backup
5017
      <systemitem>hostb.example.org</systemitem>, with a shared backup
5018
      named <systemitem>hostc.example.org</systemitem>.</para>
5018
      named <systemitem>hostc.example.org</systemitem>.</para>
5019
5019
5020
    <para>These machines are load balanced with a Round Robin
5020
    <para>These machines are load balanced with a Round Robin
5021
      <acronym>DNS</acronym> configuration.  The master and backup
5021
      <acronym>DNS</acronym> configuration.  The master and backup
5022
      machines are configured identically except for their hostnames
5022
      machines are configured identically except for their hostnames
5023
      and management <acronym>IP</acronym> addresses.  These servers
5023
      and management <acronym>IP</acronym> addresses.  These servers
5024
      must have the same configuration and run the same services.
5024
      must have the same configuration and run the same services.
5025
      When the failover occurs, requests to the service on the shared
5025
      When the failover occurs, requests to the service on the shared
5026
      <acronym>IP</acronym> address can only be answered correctly if
5026
      <acronym>IP</acronym> address can only be answered correctly if
5027
      the backup server has access to the same content.  The backup
5027
      the backup server has access to the same content.  The backup
5028
      machine has two additional <acronym>CARP</acronym> interfaces,
5028
      machine has two additional <acronym>CARP</acronym> interfaces,
5029
      one for each of the master content server's
5029
      one for each of the master content server's
5030
      <acronym>IP</acronym> addresses.  When a failure occurs, the
5030
      <acronym>IP</acronym> addresses.  When a failure occurs, the
5031
      backup server will pick up the failed master machine's
5031
      backup server will pick up the failed master machine's
5032
      <acronym>IP</acronym> address.</para>
5032
      <acronym>IP</acronym> address.</para>
5033
5033
5034
    <sect2 xml:id="carp-10x">
5034
    <sect2 xml:id="carp-10x">
5035
      <title>Using <acronym>CARP</acronym> on &os;&nbsp;10 and
5035
      <title>Using <acronym>CARP</acronym> on &os;&nbsp;10 and
5036
	Later</title>
5036
	Later</title>
5037
5037
5038
      <para>Enable boot-time support for <acronym>CARP</acronym> by
5038
      <para>Enable boot-time support for <acronym>CARP</acronym> by
5039
	adding an entry for the <filename>carp.ko</filename> kernel
5039
	adding an entry for the <filename>carp.ko</filename> kernel
5040
	module in <filename>/boot/loader.conf</filename>:</para>
5040
	module in <filename>/boot/loader.conf</filename>:</para>
5041
5041
5042
      <programlisting>carp_load="YES"</programlisting>
5042
      <programlisting>carp_load="YES"</programlisting>
5043
5043
5044
      <para>To load the module now without rebooting:</para>
5044
      <para>To load the module now without rebooting:</para>
5045
5045
5046
      <screen>&prompt.root; <userinput>kldload carp</userinput></screen>
5046
      <screen>&prompt.root; <userinput>kldload carp</userinput></screen>
5047
5047
5048
      <para>For users who prefer to use a custom kernel, include the
5048
      <para>For users who prefer to use a custom kernel, include the
5049
	following line in the custom kernel configuration file and
5049
	following line in the custom kernel configuration file and
5050
	compile the kernel as described in <xref
5050
	compile the kernel as described in <xref
5051
	  linkend="kernelconfig"/>:</para>
5051
	  linkend="kernelconfig"/>:</para>
5052
5052
5053
      <programlisting>device	carp</programlisting>
5053
      <programlisting>device	carp</programlisting>
5054
5054
5055
      <para>The hostname, management <acronym>IP</acronym> address and
5055
      <para>The hostname, management <acronym>IP</acronym> address and
5056
	subnet mask, shared <acronym>IP</acronym> address, and
5056
	subnet mask, shared <acronym>IP</acronym> address, and
5057
	<acronym>VHID</acronym> are all set by adding entries to
5057
	<acronym>VHID</acronym> are all set by adding entries to
5058
	<filename>/etc/rc.conf</filename>.  This example is for
5058
	<filename>/etc/rc.conf</filename>.  This example is for
5059
	<systemitem>hosta.example.org</systemitem>:</para>
5059
	<systemitem>hosta.example.org</systemitem>:</para>
5060
5060
5061
      <programlisting>hostname="<replaceable>hosta.example.org</replaceable>"
5061
      <programlisting>hostname="<replaceable>hosta.example.org</replaceable>"
5062
ifconfig_<replaceable>em0</replaceable>="inet <replaceable>192.168.1.3</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5062
ifconfig_<replaceable>em0</replaceable>="inet <replaceable>192.168.1.3</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5063
ifconfig_<replaceable>em0</replaceable>_alias0="inet vhid <replaceable>1</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.50</replaceable>/32"</programlisting>
5063
ifconfig_<replaceable>em0</replaceable>_alias0="inet vhid <replaceable>1</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.50</replaceable>/32"</programlisting>
5064
5064
5065
      <para>The next set of entries are for
5065
      <para>The next set of entries are for
5066
	<systemitem>hostb.example.org</systemitem>.  Since it
5066
	<systemitem>hostb.example.org</systemitem>.  Since it
5067
	represents a second master, it uses a different shared
5067
	represents a second master, it uses a different shared
5068
	<acronym>IP</acronym> address and <acronym>VHID</acronym>.
5068
	<acronym>IP</acronym> address and <acronym>VHID</acronym>.
5069
	However, the passwords specified with <option>pass</option>
5069
	However, the passwords specified with <option>pass</option>
5070
	must be identical as <acronym>CARP</acronym> will only listen
5070
	must be identical as <acronym>CARP</acronym> will only listen
5071
	to and accept advertisements from machines with the correct
5071
	to and accept advertisements from machines with the correct
5072
	password.</para>
5072
	password.</para>
5073
5073
5074
      <programlisting>hostname="<replaceable>hostb.example.org</replaceable>"
5074
      <programlisting>hostname="<replaceable>hostb.example.org</replaceable>"
5075
ifconfig_<replaceable>em0</replaceable>="inet <replaceable>192.168.1.4</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5075
ifconfig_<replaceable>em0</replaceable>="inet <replaceable>192.168.1.4</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5076
ifconfig_<replaceable>em0</replaceable>_alias0="inet vhid <replaceable>2</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.51</replaceable>/32"</programlisting>
5076
ifconfig_<replaceable>em0</replaceable>_alias0="inet vhid <replaceable>2</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.51</replaceable>/32"</programlisting>
5077
5077
5078
      <para>The third machine,
5078
      <para>The third machine,
5079
	<systemitem>hostc.example.org</systemitem>, is configured to
5079
	<systemitem>hostc.example.org</systemitem>, is configured to
5080
	handle failover from either master.  This machine is
5080
	handle failover from either master.  This machine is
5081
	configured with two <acronym>CARP</acronym>
5081
	configured with two <acronym>CARP</acronym>
5082
	<acronym>VHID</acronym>s, one to handle the virtual
5082
	<acronym>VHID</acronym>s, one to handle the virtual
5083
	<acronym>IP</acronym> address for each of the master hosts.
5083
	<acronym>IP</acronym> address for each of the master hosts.
5084
	The <acronym>CARP</acronym> advertising skew,
5084
	The <acronym>CARP</acronym> advertising skew,
5085
	<option>advskew</option>, is set to ensure that the backup
5085
	<option>advskew</option>, is set to ensure that the backup
5086
	host advertises later than the master, since
5086
	host advertises later than the master, since
5087
	<option>advskew</option> controls the order of precedence when
5087
	<option>advskew</option> controls the order of precedence when
5088
	there are multiple backup servers.</para>
5088
	there are multiple backup servers.</para>
5089
5089
5090
      <programlisting>hostname="hostc.example.org"
5090
      <programlisting>hostname="hostc.example.org"
5091
ifconfig_<replaceable>em0</replaceable>="inet <replaceable>192.168.1.5</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5091
ifconfig_<replaceable>em0</replaceable>="inet <replaceable>192.168.1.5</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5092
ifconfig_<replaceable>em0</replaceable>_alias0="inet vhid <replaceable>1</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.50</replaceable>/32"
5092
ifconfig_<replaceable>em0</replaceable>_alias0="inet vhid <replaceable>1</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.50</replaceable>/32"
5093
ifconfig_<replaceable>em0</replaceable>_alias1="inet vhid <replaceable>2</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.51</replaceable>/32"</programlisting>
5093
ifconfig_<replaceable>em0</replaceable>_alias1="inet vhid <replaceable>2</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> alias <replaceable>192.168.1.51</replaceable>/32"</programlisting>
5094
5094
5095
      <para>Having two <acronym>CARP</acronym>
5095
      <para>Having two <acronym>CARP</acronym>
5096
	<acronym>VHID</acronym>s configured means that
5096
	<acronym>VHID</acronym>s configured means that
5097
	<systemitem>hostc.example.org</systemitem> will notice if
5097
	<systemitem>hostc.example.org</systemitem> will notice if
5098
	either of the master servers becomes unavailable.  If a master
5098
	either of the master servers becomes unavailable.  If a master
5099
	fails to advertise before the backup server, the backup server
5099
	fails to advertise before the backup server, the backup server
5100
	will pick up the shared <acronym>IP</acronym> address until
5100
	will pick up the shared <acronym>IP</acronym> address until
5101
	the master becomes available again.</para>
5101
	the master becomes available again.</para>
5102
5102
5103
      <note>
5103
      <note>
5104
	<para>Preemption is disabled by default.  If preemption has
5104
	<para>Preemption is disabled by default.  If preemption has
5105
	  been enabled, <systemitem>hostc.example.org</systemitem>
5105
	  been enabled, <systemitem>hostc.example.org</systemitem>
5106
	  might not release the virtual <acronym>IP</acronym> address
5106
	  might not release the virtual <acronym>IP</acronym> address
5107
	  back to the original master server.  The administrator
5107
	  back to the original master server.  The administrator
5108
	  can force the backup server to return the
5108
	  can force the backup server to return the
5109
	  <acronym>IP</acronym> address to the master with the
5109
	  <acronym>IP</acronym> address to the master with the
5110
	  command:</para>
5110
	  command:</para>
5111
5111
5112
	<screen>&prompt.root; <userinput>ifconfig em0 vhid 1 state backup</userinput></screen>
5112
	<screen>&prompt.root; <userinput>ifconfig em0 vhid 1 state backup</userinput></screen>
5113
      </note>
5113
      </note>
5114
5114
5115
      <para>Once the configuration is complete, either restart
5115
      <para>Once the configuration is complete, either restart
5116
	networking or reboot each system.  High availability is now
5116
	networking or reboot each system.  High availability is now
5117
	enabled.</para>
5117
	enabled.</para>
5118
5118
5119
      <para><acronym>CARP</acronym> functionality can be controlled
5119
      <para><acronym>CARP</acronym> functionality can be controlled
5120
	via several &man.sysctl.8; variables documented in the
5120
	via several &man.sysctl.8; variables documented in the
5121
	&man.carp.4; manual pages.  Other actions can be triggered
5121
	&man.carp.4; manual pages.  Other actions can be triggered
5122
	from <acronym>CARP</acronym> events by using
5122
	from <acronym>CARP</acronym> events by using
5123
	&man.devd.8;.</para>
5123
	&man.devd.8;.</para>
5124
    </sect2>
5124
    </sect2>
5125
5125
5126
    <sect2 xml:id="carp-9x">
5126
    <sect2 xml:id="carp-9x">
5127
      <title>Using <acronym>CARP</acronym> on &os;&nbsp;9 and
5127
      <title>Using <acronym>CARP</acronym> on &os;&nbsp;9 and
5128
	Earlier</title>
5128
	Earlier</title>
5129
5129
5130
      <para>The configuration for these versions of &os; is similar to
5130
      <para>The configuration for these versions of &os; is similar to
5131
	the one described in the previous section, except that a
5131
	the one described in the previous section, except that a
5132
	<acronym>CARP</acronym> device must first be created and
5132
	<acronym>CARP</acronym> device must first be created and
5133
	referred to in the configuration.</para>
5133
	referred to in the configuration.</para>
5134
5134
5135
      <para>Enable boot-time support for <acronym>CARP</acronym> by
5135
      <para>Enable boot-time support for <acronym>CARP</acronym> by
5136
	loading the <filename>if_carp.ko</filename> kernel module in
5136
	loading the <filename>if_carp.ko</filename> kernel module in
5137
	<filename>/boot/loader.conf</filename>:</para>
5137
	<filename>/boot/loader.conf</filename>:</para>
5138
5138
5139
      <programlisting>if_carp_load="YES"</programlisting>
5139
      <programlisting>if_carp_load="YES"</programlisting>
5140
5140
5141
     <para>To load the module now without rebooting:</para>
5141
     <para>To load the module now without rebooting:</para>
5142
5142
5143
      <screen>&prompt.root; <userinput>kldload carp</userinput></screen>
5143
      <screen>&prompt.root; <userinput>kldload carp</userinput></screen>
5144
5144
5145
      <para>For users who prefer to use a custom kernel, include the
5145
      <para>For users who prefer to use a custom kernel, include the
5146
	following line in the custom kernel configuration file and
5146
	following line in the custom kernel configuration file and
5147
	compile the kernel as described in <xref
5147
	compile the kernel as described in <xref
5148
	  linkend="kernelconfig"/>:</para>
5148
	  linkend="kernelconfig"/>:</para>
5149
5149
5150
      <programlisting>device	carp</programlisting>
5150
      <programlisting>device	carp</programlisting>
5151
5151
5152
      <para>Next, on each host, create a <acronym>CARP</acronym>
5152
      <para>Next, on each host, create a <acronym>CARP</acronym>
5153
	device:</para>
5153
	device:</para>
5154
5154
5155
      <screen>&prompt.root; <userinput>ifconfig carp0 create</userinput></screen>
5155
      <screen>&prompt.root; <userinput>ifconfig carp0 create</userinput></screen>
5156
5156
5157
      <para>Set the hostname, management <acronym>IP</acronym>
5157
      <para>Set the hostname, management <acronym>IP</acronym>
5158
	address, the shared <acronym>IP</acronym> address, and
5158
	address, the shared <acronym>IP</acronym> address, and
5159
	<acronym>VHID</acronym> by adding the required lines to
5159
	<acronym>VHID</acronym> by adding the required lines to
5160
	<filename>/etc/rc.conf</filename>.  Since a virtual
5160
	<filename>/etc/rc.conf</filename>.  Since a virtual
5161
	<acronym>CARP</acronym> device is used instead of an alias,
5161
	<acronym>CARP</acronym> device is used instead of an alias,
5162
	the actual subnet mask of <literal>/24</literal> is used
5162
	the actual subnet mask of <literal>/24</literal> is used
5163
	instead of <literal>/32</literal>.  Here are the entries for
5163
	instead of <literal>/32</literal>.  Here are the entries for
5164
	<systemitem>hosta.example.org</systemitem>:</para>
5164
	<systemitem>hosta.example.org</systemitem>:</para>
5165
5165
5166
      <programlisting>hostname="<replaceable>hosta.example.org</replaceable>"
5166
      <programlisting>hostname="<replaceable>hosta.example.org</replaceable>"
5167
ifconfig_<replaceable>fxp0</replaceable>="inet <replaceable>192.168.1.3</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5167
ifconfig_<replaceable>fxp0</replaceable>="inet <replaceable>192.168.1.3</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5168
cloned_interfaces="carp0"
5168
cloned_interfaces="carp0"
5169
ifconfig_carp0="vhid <replaceable>1</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.50/24</replaceable>"</programlisting>
5169
ifconfig_carp0="vhid <replaceable>1</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.50/24</replaceable>"</programlisting>
5170
5170
5171
      <para>On <systemitem>hostb.example.org</systemitem>:</para>
5171
      <para>On <systemitem>hostb.example.org</systemitem>:</para>
5172
5172
5173
      <programlisting>hostname="<replaceable>hostb.example.org</replaceable>"
5173
      <programlisting>hostname="<replaceable>hostb.example.org</replaceable>"
5174
ifconfig_<replaceable>fxp0</replaceable>="inet <replaceable>192.168.1.4</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5174
ifconfig_<replaceable>fxp0</replaceable>="inet <replaceable>192.168.1.4</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5175
cloned_interfaces="carp0"
5175
cloned_interfaces="carp0"
5176
ifconfig_carp0="vhid <replaceable>2</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.51/24</replaceable>"</programlisting>
5176
ifconfig_carp0="vhid <replaceable>2</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.51/24</replaceable>"</programlisting>
5177
5177
5178
      <para>The third machine,
5178
      <para>The third machine,
5179
	<systemitem>hostc.example.org</systemitem>, is configured to
5179
	<systemitem>hostc.example.org</systemitem>, is configured to
5180
	handle failover from either of the master hosts:</para>
5180
	handle failover from either of the master hosts:</para>
5181
5181
5182
      <programlisting>hostname="<replaceable>hostc.example.org</replaceable>"
5182
      <programlisting>hostname="<replaceable>hostc.example.org</replaceable>"
5183
ifconfig_<replaceable>fxp0</replaceable>="inet <replaceable>192.168.1.5</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5183
ifconfig_<replaceable>fxp0</replaceable>="inet <replaceable>192.168.1.5</replaceable> netmask <replaceable>255.255.255.0</replaceable>"
5184
cloned_interfaces="carp0 carp1"
5184
cloned_interfaces="carp0 carp1"
5185
ifconfig_carp0="vhid <replaceable>1</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.50/24</replaceable>"
5185
ifconfig_carp0="vhid <replaceable>1</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.50/24</replaceable>"
5186
ifconfig_carp1="vhid <replaceable>2</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.51/24</replaceable>"</programlisting>
5186
ifconfig_carp1="vhid <replaceable>2</replaceable> advskew <replaceable>100</replaceable> pass <replaceable>testpass</replaceable> <replaceable>192.168.1.51/24</replaceable>"</programlisting>
5187
5187
5188
      <note>
5188
      <note>
5189
	<para>Preemption is disabled in the GENERIC &os; kernel.  If
5189
	<para>Preemption is disabled in the GENERIC &os; kernel.  If
5190
	  preemption has been enabled with a custom kernel,
5190
	  preemption has been enabled with a custom kernel,
5191
	  <systemitem>hostc.example.org</systemitem> may not release
5191
	  <systemitem>hostc.example.org</systemitem> may not release
5192
	  the <acronym>IP</acronym> address back to the original
5192
	  the <acronym>IP</acronym> address back to the original
5193
	  content server.  The administrator can force the backup
5193
	  content server.  The administrator can force the backup
5194
	  server to return the <acronym>IP</acronym> address to the
5194
	  server to return the <acronym>IP</acronym> address to the
5195
	  master with the command:</para>
5195
	  master with the command:</para>
5196
5196
5197
	<screen>&prompt.root; <userinput>ifconfig carp0 down &amp;&amp; ifconfig carp0 up</userinput></screen>
5197
	<screen>&prompt.root; <userinput>ifconfig carp0 down &amp;&amp; ifconfig carp0 up</userinput></screen>
5198
5198
5199
	<para>This should be done on the <filename>carp</filename>
5199
	<para>This should be done on the <filename>carp</filename>
5200
	  interface which corresponds to the correct host.</para>
5200
	  interface which corresponds to the correct host.</para>
5201
      </note>
5201
      </note>
5202
5202
5203
      <para>Once the configuration is complete, either restart
5203
      <para>Once the configuration is complete, either restart
5204
	networking or reboot each system.  High availability is now
5204
	networking or reboot each system.  High availability is now
5205
	enabled.</para>
5205
	enabled.</para>
5206
    </sect2>
5206
    </sect2>
5207
  </sect1>
5207
  </sect1>
5208
  <sect1 xml:id="network-vlan">
5208
  <sect1 xml:id="network-vlan">
5209
    <info>
5209
    <info>
5210
      <title>VLANs</title>
5210
      <title>VLANs</title>
5211
    </info>
5211
    </info>
5212
5212
5213
    <indexterm>
5213
    <indexterm>
5214
      <primary><acronym>VLANs</acronym></primary>
5214
      <primary><acronym>VLANs</acronym></primary>
5215
    </indexterm>
5215
    </indexterm>
5216
    <indexterm>
5216
    <indexterm>
5217
      <primary>Virtual LANs</primary>
5217
      <primary>Virtual LANs</primary>
5218
    </indexterm>
5218
    </indexterm>
5219
5219
5220
    <para><acronym>VLANs</acronym> are a way of virtually dividing up
5220
    <para><acronym>VLANs</acronym> are a way of virtually dividing up
5221
      a network into many different subnetworks.  Each will have its
5221
      a network into many different subnetworks.  Each will have its
5222
      own broadcast domain and be isolated from the rest of the
5222
      own broadcast domain and be isolated from the rest of the
5223
      <acronym>VLANs</acronym>.</para>
5223
      <acronym>VLANs</acronym>.</para>
5224
5224
5225
    <para>On &os;, <acronym>VLANs</acronym> must be supported by the
5225
    <para>On &os;, <acronym>VLANs</acronym> must be supported by the
5226
      network card driver.  To see which drivers support vlans, refer
5226
      network card driver.  To see which drivers support vlans, refer
5227
      to the &man.vlan.4; manual page.</para>
5227
      to the &man.vlan.4; manual page.</para>
5228
5228
5229
    <para>When configuring a <acronym>VLAN</acronym>, a couple pieces
5229
    <para>When configuring a <acronym>VLAN</acronym>, a couple pieces
5230
      of information must be known.  First, which network interface?
5230
      of information must be known.  First, which network interface?
5231
      Second, what is the <acronym>VLAN</acronym> tag?</para>
5231
      Second, what is the <acronym>VLAN</acronym> tag?</para>
5232
5232
5233
    <para>To configure <acronym>VLANs</acronym> at run time, with a
5233
    <para>To configure <acronym>VLANs</acronym> at run time, with a
5234
      <acronym>NIC</acronym> of <literal>em0</literal> and a
5234
      <acronym>NIC</acronym> of <literal>em0</literal> and a
5235
      <acronym>VLAN</acronym> tag of <systemitem>5</systemitem>.  The
5235
      <acronym>VLAN</acronym> tag of <systemitem>5</systemitem>.  The
5236
      command would look like this:</para>
5236
      command would look like this:</para>
5237
5237
5238
    <screen>&prompt.root; <userinput>ifconfig <replaceable>em0.5</replaceable> create vlan <replaceable>5</replaceable> vlandev <replaceable>em0</replaceable> inet 192.168.20.20/24</userinput></screen>
5238
    <screen>&prompt.root; <userinput>ifconfig <replaceable>em0.5</replaceable> create vlan <replaceable>5</replaceable> vlandev <replaceable>em0</replaceable> inet 192.168.20.20/24</userinput></screen>
5239
5239
5240
    <note>
5240
    <note>
5241
      <para>See how the interface name includes the
5241
      <para>See how the interface name includes the
5242
	<acronym>NIC</acronym> driver name and the
5242
	<acronym>NIC</acronym> driver name and the
5243
	<acronym>VLAN</acronym> tag, separated by a period?  This is a
5243
	<acronym>VLAN</acronym> tag, separated by a period?  This is a
5244
	best practice to make maintaining the <acronym>VLAN</acronym>
5244
	best practice to make maintaining the <acronym>VLAN</acronym>
5245
	configuration easy when many <acronym>VLANs</acronym> are
5245
	configuration easy when many <acronym>VLANs</acronym> are
5246
	present on a machine.</para>
5246
	present on a machine.</para>
5247
    </note>
5247
    </note>
5248
5248
5249
    <para>To configure <acronym>VLANs</acronym> at boot time,
5249
    <para>To configure <acronym>VLANs</acronym> at boot time,
5250
      <filename>/etc/rc.conf</filename> must be updated.  To duplicate
5250
      <filename>/etc/rc.conf</filename> must be updated.  To duplicate
5251
      the configuration above, the following will need to be
5251
      the configuration above, the following will need to be
5252
      added:</para>
5252
      added:</para>
5253
5253
5254
    <programlisting>vlans_<replaceable>em0</replaceable>="<replaceable>5</replaceable>"
5254
    <programlisting>vlans_<replaceable>em0</replaceable>="<replaceable>5</replaceable>"
5255
ifconfig_<replaceable>em0</replaceable>_<replaceable>5</replaceable>="inet 192.168.20.20/24"</programlisting>
5255
ifconfig_<replaceable>em0</replaceable>_<replaceable>5</replaceable>="inet 192.168.20.20/24"</programlisting>
5256
5256
5257
    <para>Additional <acronym>VLANs</acronym> may be added, by simply
5257
    <para>Additional <acronym>VLANs</acronym> may be added, by simply
5258
      adding the tag to the
5258
      adding the tag to the
5259
      <literal>vlans_<replaceable>em0</replaceable></literal>
5259
      <literal>vlans_<replaceable>em0</replaceable></literal>
5260
      field and adding an additional line configuring the network on
5260
      field and adding an additional line configuring the network on
5261
      that <acronym>VLAN</acronym> tag's interface.</para>
5261
      that <acronym>VLAN</acronym> tag's interface.</para>
5262
  </sect1>
5262
  </sect1>
5263
</chapter>
5263
</chapter>

Return to bug 219966