]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/if_bridge.4
- Document support for Realtek ALC660 and Analog Devices AD1988B.
[FreeBSD/FreeBSD.git] / share / man / man4 / if_bridge.4
1 .\"     $NetBSD: bridge.4,v 1.5 2004/01/31 20:14:11 jdc Exp $
2 .\"
3 .\" Copyright 2001 Wasabi Systems, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed for the NetBSD Project by
19 .\"     Wasabi Systems, Inc.
20 .\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21 .\"    or promote products derived from this software without specific prior
22 .\"    written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
28 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 .\" POSSIBILITY OF SUCH DAMAGE.
35 .\"
36 .\" $FreeBSD$
37 .\"
38 .Dd January 20, 2007
39 .Dt IF_BRIDGE 4
40 .Os
41 .Sh NAME
42 .Nm if_bridge
43 .Nd network bridge device
44 .Sh SYNOPSIS
45 To compile this driver into the kernel,
46 place the following line in your
47 kernel configuration file:
48 .Bd -ragged -offset indent
49 .Cd "device if_bridge"
50 .Ed
51 .Pp
52 Alternatively, to load the driver as a
53 module at boot time, place the following lines in
54 .Xr loader.conf 5 :
55 .Bd -literal -offset indent
56 if_bridge_load="YES"
57 bridgestp_load="YES"
58 .Ed
59 .Sh DESCRIPTION
60 The
61 .Nm
62 driver creates a logical link between two or more IEEE 802 networks
63 that use the same (or
64 .Dq "similar enough" )
65 framing format.
66 For example, it is possible to bridge Ethernet and 802.11 networks together,
67 but it is not possible to bridge Ethernet and Token Ring together.
68 .Pp
69 Each
70 .Nm
71 interface is created at runtime using interface cloning.
72 This is
73 most easily done with the
74 .Xr ifconfig 8
75 .Cm create
76 command or using the
77 .Va cloned_interfaces
78 variable in
79 .Xr rc.conf 5 .
80 .Pp
81 The
82 .Nm
83 interface randomly chooses a link (MAC) address in the range reserved for
84 locally administered addresses when it is created.
85 This address is guaranteed to be unique
86 .Em only
87 across all
88 .Nm
89 interfaces on the local machine.
90 Thus you can theoretically have two bridges on the different machines with
91 the same link addresses.
92 The address can be changed by assigning the desired link address using
93 .Xr ifconfig 8 .
94 .Pp
95 A bridge can be used to provide several services, such as a simple
96 802.11-to-Ethernet bridge for wireless hosts, and traffic isolation.
97 .Pp
98 A bridge works like a hub, forwarding traffic from one interface
99 to another.
100 Multicast and broadcast packets are always forwarded to all
101 interfaces that are part of the bridge.
102 For unicast traffic, the bridge learns which MAC addresses are associated
103 with which interfaces and will forward the traffic selectively.
104 .Pp
105 All the bridged member interfaces need to be up in order to pass network traffic.
106 These can be enabled using
107 .Xr ifconfig 8
108 or
109 .Va ifconfig_ Ns Ao Ar interface Ac Ns Li ="up"
110 in
111 .Xr rc.conf 5 .
112 .Pp
113 The MTU of the first member interface to be added is used as the bridge MTU.
114 All additional members are required to have exactly the same value.
115 .Pp
116 The TXCSUM capability is disabled for any interface added to the bridge, and it
117 is restored when the interface is removed again.
118 .Pp
119 The bridge supports
120 .Dq monitor mode ,
121 where the packets are discarded after
122 .Xr bpf 4
123 processing, and are not processed or forwarded further.
124 This can be used to multiplex the input of two or more interfaces into a single
125 .Xr bpf 4
126 stream.
127 This is useful for reconstructing the traffic for network taps
128 that transmit the RX/TX signals out through two separate interfaces.
129 .Sh SPANNING TREE
130 The
131 .Nm
132 driver implements the Rapid Spanning Tree Protocol (RSTP or 802.1w) with
133 backwards compatibility with the legacy Spanning Tree Protocol (STP).
134 Spanning Tree is used to detect and remove loops in a network topology.
135 .Pp
136 RSTP provides faster spanning tree convergence than legacy STP, the protocol
137 will exchange information with neighbouring switches to quickly transition to
138 forwarding without creating loops.
139 .Pp
140 The code will default to RSTP mode but will downgrade any port connected to a
141 legacy STP network so is fully backward compatible.
142 A bridge can be forced to operate in STP mode without rapid state transitions
143 via the
144 .Va proto
145 command in
146 .Xr ifconfig 8 .
147 .Pp
148 The bridge can log STP port changes to
149 .Xr syslog 3
150 by enabling the
151 .Va net.link.bridge.log_stp
152 variable using
153 .Xr sysctl 8 .
154 .Pp
155 .Sh PACKET FILTERING
156 Packet filtering can be used with any firewall package that hooks in via the
157 .Xr pfil 9
158 framework.
159 When filtering is enabled, bridged packets will pass through the filter
160 inbound on the originating interface, on the bridge interface and outbound on
161 the appropriate interfaces.
162 Either stage can be disabled.
163 The filtering behaviour can be controlled using
164 .Xr sysctl 8 :
165 .Bl -tag -width ".Va net.link.bridge.pfil_onlyip"
166 .It Va net.link.bridge.pfil_onlyip
167 Controls the handling of non-IP packets which are not passed to
168 .Xr pfil 9 .
169 Set to
170 .Li 1
171 to only allow IP packets to pass (subject to firewall rules), set to
172 .Li 0
173 to unconditionally pass all non-IP Ethernet frames.
174 .It Va net.link.bridge.pfil_member
175 Set to
176 .Li 1
177 to enable filtering on the incoming and outgoing member interfaces, set
178 to
179 .Li 0
180 to disable it.
181 .It Va net.link.bridge.pfil_bridge
182 Set to
183 .Li 1
184 to enable filtering on the bridge interface, set
185 to
186 .Li 0
187 to disable it.
188 .It Va net.link.bridge.ipfw
189 Set to
190 .Li 1
191 to enable layer2 filtering with
192 .Xr ipfirewall 4 ,
193 set to
194 .Li 0
195 to disable it.
196 This needs to be enabled for
197 .Xr dummynet 4
198 support.
199 When
200 .Va ipfw
201 is enabled,
202 .Va pfil_bridge
203 and
204 .Va pfil_member
205 will be disabled so that IPFW
206 is not run twice; these can be re-enabled if desired.
207 .It Va net.link.bridge.ipfw_arp
208 Set to
209 .Li 1
210 to enable layer2 ARP filtering with
211 .Xr ipfirewall 4 ,
212 set to
213 .Li 0
214 to disable it.
215 Requires
216 .Va ipfw
217 to be enabled.
218 .El
219 .Pp
220 ARP and REVARP packets are forwarded without being filtered and others
221 that are not IP nor IPv6 packets are not forwarded when
222 .Va pfil_onlyip
223 is enabled.
224 IPFW can filter Ethernet types using
225 .Cm mac-type
226 so all packets are passed to
227 the filter for processing.
228 .Pp
229 The packets originating from the bridging host will be seen by
230 the filter on the interface that is looked up in the routing
231 table.
232 .Pp
233 The packets destined to the bridging host will be seen by the filter
234 on the interface with the MAC address equal to the packet's destination
235 MAC.
236 There are situations when some of the bridge members are sharing
237 the same MAC address (for example the
238 .Xr vlan 4
239 interfaces: they are currenly sharing the
240 MAC address of the parent physical interface).
241 It is not possible to distinguish between these interfaces using
242 their MAC address, excluding the case when the packet's destination
243 MAC address is equal to the MAC address of the interface on which
244 the packet was entered to the system.
245 In this case the filter will see the incoming packet on this
246 interface.
247 In all other cases the interface seen by the packet filter is chosen
248 from the list of bridge members with the same MAC address and the
249 result strongly depends on the member addition sequence and the
250 actual implementation of
251 .Nm .
252 It is not recommended to rely on the order chosen by the current
253 .Nm
254 implementation: it can be changed in the future.
255 .Pp
256 The previous paragraph is best illustrated with the following
257 pictures.
258 Let
259 .Bl -bullet
260 .It
261 the MAC address of the incoming packet's destination is
262 .Nm nn:nn:nn:nn:nn:nn ,
263 .It
264 the interface on which packet entered the system is
265 .Nm ifX ,
266 .It
267 .Nm ifX
268 MAC address is
269 .Nm xx:xx:xx:xx:xx:xx ,
270 .It
271 there are possibly other bridge members with the same MAC address
272 .Nm xx:xx:xx:xx:xx:xx ,
273 .It
274 the bridge has more than one interface that are sharing the
275 same MAC address
276 .Nm yy:yy:yy:yy:yy:yy ;
277 we will call them
278 .Nm vlanY1 ,
279 .Nm vlanY2 ,
280 etc.
281 .El
282 .Pp
283 Then if the MAC address
284 .Nm nn:nn:nn:nn:nn:nn
285 is equal to the
286 .Nm xx:xx:xx:xx:xx:xx
287 then the filter will see the packet on the interface
288 .Nm ifX
289 no matter if there are any other bridge members carrying the same
290 MAC address.
291 But if the MAC address
292 .Nm nn:nn:nn:nn:nn:nn
293 is equal to the
294 .Nm yy:yy:yy:yy:yy:yy
295 then the interface that will be seen by the filter is one of the
296 .Nm vlanYn .
297 It is not possible to predict the name of the actual interface
298 without the knowledge of the system state and the
299 .Nm
300 implementation details.
301 .Pp
302 This problem arises for any bridge members that are sharing the same
303 MAC address, not only to the
304 .Xr vlan 4
305 ones: they we taken just as the example of such situation.
306 So if one wants the filter the locally destined packets based on
307 their interface name, one should be aware of this implication.
308 The described situation will appear at least on the filtering bridges
309 that are doing IP-forwarding; in some of such cases it is better
310 to assign the IP address only to the
311 .Nm
312 interface and not to the bridge members.
313 But your mileage may vary.
314 .Sh EXAMPLES
315 The following when placed in the file
316 .Pa /etc/rc.conf
317 will cause a bridge called
318 .Dq Li bridge0
319 to be created, and will add the interfaces
320 .Dq Li ath0
321 and
322 .Dq Li fxp0
323 to the bridge, and then enable packet forwarding.
324 Such a configuration could be used to implement a simple
325 802.11-to-Ethernet bridge (assuming the 802.11 interface is
326 in ad-hoc mode).
327 .Bd -literal -offset indent
328 cloned_interfaces="bridge0"
329 ifconfig_bridge0="addm ath0 addm fxp0 up"
330 .Ed
331 .Pp
332 For the bridge to forward packets all member interfaces and the bridge need
333 to be up.
334 The above example would also require:
335 .Bd -literal -offset indent
336 ifconfig_ath0="up ssid my_ap mode 11g mediaopt hostap"
337 ifconfig_fxp0="up"
338 .Ed
339 .Pp
340 Consider a system with two 4-port Ethernet boards.
341 The following will cause a bridge consisting of all 8 ports with Rapid Spanning
342 Tree enabled to be created:
343 .Bd -literal -offset indent
344 ifconfig bridge0 create
345 ifconfig bridge0 \e
346     addm fxp0 stp fxp0 \e
347     addm fxp1 stp fxp1 \e
348     addm fxp2 stp fxp2 \e
349     addm fxp3 stp fxp3 \e
350     addm fxp4 stp fxp4 \e
351     addm fxp5 stp fxp5 \e
352     addm fxp6 stp fxp6 \e
353     addm fxp7 stp fxp7 \e
354     up
355 .Ed
356 .Pp
357 The bridge can be used as a regular host interface at the same time as bridging
358 between its member ports.
359 In this example, the bridge connects em0 and em1, and will receive its IP
360 address through DHCP:
361 .Bd -literal -offset indent
362 cloned_interfaces="bridge0"
363 ifconfig_bridge0="addm em0 addm em1 DHCP"
364 ifconfig_em0="up"
365 ifconfig_em1="up"
366 .Ed
367 .Pp
368 The bridge can tunnel Ethernet across an IP internet using the EtherIP
369 protocol.
370 This can be combined with
371 .Xr ipsec 4
372 to provide an encrypted connection.
373 Create a
374 .Xr gif 4
375 interface and set the local and remote IP addresses for the
376 tunnel, these are reversed on the remote bridge.
377 .Bd -literal -offset indent
378 ifconfig gif0 create
379 ifconfig gif0 tunnel 1.2.3.4 5.6.7.8 up
380 ifconfig bridge0 create
381 ifconfig bridge0 addm fxp0 addm gif0 up
382 .Ed
383 .Sh SEE ALSO
384 .Xr gif 4 ,
385 .Xr ipf 4 ,
386 .Xr ipfw 4 ,
387 .Xr pf 4 ,
388 .Xr ifconfig 8
389 .Sh HISTORY
390 The
391 .Nm
392 driver first appeared in
393 .Fx 6.0 .
394 .Sh AUTHORS
395 .An -nosplit
396 The
397 .Nm bridge
398 driver was originally written by
399 .An Jason L. Wright
400 .Aq jason@thought.net
401 as part of an undergraduate independent study at the University of
402 North Carolina at Greensboro.
403 .Pp
404 This version of the
405 .Nm
406 driver has been heavily modified from the original version by
407 .An Jason R. Thorpe
408 .Aq thorpej@wasabisystems.com .
409 .Pp
410 Rapid Spanning Tree Protocol (RSTP) support was added by
411 .An Andrew Thompson
412 .Aq thompsa@FreeBSD.org .
413 .Sh BUGS
414 The
415 .Nm
416 driver currently supports only Ethernet and Ethernet-like (e.g., 802.11)
417 network devices, with exactly the same interface MTU size as the bridge device.
418 .Pp
419 Only wireless interfaces in hostap mode can be bridged due to the 802.11
420 framing format, bridging a wireless client is not supported yet.