]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/man/man4/bridge.4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / man / man4 / 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 July 27, 2013
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 If
96 .Xr sysctl 8
97 node
98 .Va net.link.bridge.inherit_mac
99 has non-zero value, newly created bridge will inherit MAC address
100 from its first member instead of choosing random link-level address.
101 This will provide more predictable bridge MAC without any
102 additional configuration, but currently this feature is known
103 to break some L2 protocols, for example PPPoE that is provided
104 by
105 .Xr ng_pppoe 4
106 and
107 .Xr ppp 8 .
108 Now this feature is considered as experimental and is turned off
109 by-default.
110 .Pp
111 A bridge can be used to provide several services, such as a simple
112 802.11-to-Ethernet bridge for wireless hosts, and traffic isolation.
113 .Pp
114 A bridge works like a switch, forwarding traffic from one interface
115 to another.
116 Multicast and broadcast packets are always forwarded to all
117 interfaces that are part of the bridge.
118 For unicast traffic, the bridge learns which MAC addresses are associated
119 with which interfaces and will forward the traffic selectively.
120 .Pp
121 All the bridged member interfaces need to be up in order to pass network traffic.
122 These can be enabled using
123 .Xr ifconfig 8
124 or
125 .Va ifconfig_ Ns Ao Ar interface Ac Ns Li ="up"
126 in
127 .Xr rc.conf 5 .
128 .Pp
129 The MTU of the first member interface to be added is used as the bridge MTU.
130 All additional members are required to have exactly the same value.
131 .Pp
132 The TXCSUM capability is disabled for any interface added to the bridge, and it
133 is restored when the interface is removed again.
134 .Pp
135 The bridge supports
136 .Dq monitor mode ,
137 where the packets are discarded after
138 .Xr bpf 4
139 processing, and are not processed or forwarded further.
140 This can be used to multiplex the input of two or more interfaces into a single
141 .Xr bpf 4
142 stream.
143 This is useful for reconstructing the traffic for network taps
144 that transmit the RX/TX signals out through two separate interfaces.
145 .Sh IPV6 SUPPORT
146 .Nm
147 supports the
148 .Li AF_INET6
149 address family on bridge interfaces.
150 The following
151 .Xr rc.conf 5
152 variable configures an IPv6 link-local address on
153 .Li bridge0
154 interface:
155 .Bd -literal -offset indent
156 ifconfig_bridge0_ipv6="up"
157 .Ed
158 .Pp
159 or in a more explicit manner:
160 .Bd -literal -offset indent
161 ifconfig_bridge0_ipv6="inet6 auto_linklocal"
162 .Ed
163 .Pp
164 However, the
165 .Li AF_INET6
166 address family has a concept of scope zone.
167 Bridging multiple interfaces change the zone configuration because
168 multiple links are merged to each other and form a new single link
169 while the member interfaces still work individually.
170 This means each member interface still has a separate link-local scope
171 zone and the
172 .Nm
173 interface has another single,
174 aggregated link-local scope zone at the same time.
175 This situation is clearly against the description
176 .Qq zones of the same scope cannot overlap
177 in Section 5,
178 RFC 4007.
179 Although it works in most cases,
180 it can cause some conterintuitive or undesirable behavior in some
181 edge cases when both of the
182 .Nm
183 interface and one of the member interface have an IPv6 address
184 and applications use both of them.
185 .Pp
186 To prevent this situation,
187 .Nm
188 checks whether a link-local scoped IPv6 address is configured on
189 a member interface to be added and the
190 .Nm
191 interface.
192 When the
193 .Nm
194 interface has IPv6 addresses,
195 IPv6 addresses on the member interface will be automatically removed
196 before the interface is added.
197 .Pp
198 This behavior can be disabled by setting
199 .Xr sysctl 8
200 variable
201 .Va net.link.bridge.allow_llz_overlap
202 to
203 .Li 1 .
204 .Pp
205 Note that
206 .Li ACCEPT_RTADV
207 and
208 .Li AUTO_LINKLOCAL
209 interface flag are not enabled by default on
210 .Nm
211 interface even when
212 .Va net.inet6.ip6.accept_rtadv
213 and/or
214 .Va net.inet6.ip6.auto_linklocal
215 is set to
216 .Li 1 .
217 .Sh SPANNING TREE
218 The
219 .Nm
220 driver implements the Rapid Spanning Tree Protocol (RSTP or 802.1w) with
221 backwards compatibility with the legacy Spanning Tree Protocol (STP).
222 Spanning Tree is used to detect and remove loops in a network topology.
223 .Pp
224 RSTP provides faster spanning tree convergence than legacy STP, the protocol
225 will exchange information with neighbouring switches to quickly transition to
226 forwarding without creating loops.
227 .Pp
228 The code will default to RSTP mode but will downgrade any port connected to a
229 legacy STP network so is fully backward compatible.
230 A bridge can be forced to operate in STP mode without rapid state transitions
231 via the
232 .Va proto
233 command in
234 .Xr ifconfig 8 .
235 .Pp
236 The bridge can log STP port changes to
237 .Xr syslog 3
238 by enabling the
239 .Va net.link.bridge.log_stp
240 variable using
241 .Xr sysctl 8 .
242 .Pp
243 .Sh PACKET FILTERING
244 Packet filtering can be used with any firewall package that hooks in via the
245 .Xr pfil 9
246 framework.
247 When filtering is enabled, bridged packets will pass through the filter
248 inbound on the originating interface, on the bridge interface and outbound on
249 the appropriate interfaces.
250 Either stage can be disabled.
251 The filtering behaviour can be controlled using
252 .Xr sysctl 8 :
253 .Bl -tag -width ".Va net.link.bridge.pfil_onlyip"
254 .It Va net.link.bridge.pfil_onlyip
255 Controls the handling of non-IP packets which are not passed to
256 .Xr pfil 9 .
257 Set to
258 .Li 1
259 to only allow IP packets to pass (subject to firewall rules), set to
260 .Li 0
261 to unconditionally pass all non-IP Ethernet frames.
262 .It Va net.link.bridge.pfil_member
263 Set to
264 .Li 1
265 to enable filtering on the incoming and outgoing member interfaces, set
266 to
267 .Li 0
268 to disable it.
269 .It Va net.link.bridge.pfil_bridge
270 Set to
271 .Li 1
272 to enable filtering on the bridge interface, set
273 to
274 .Li 0
275 to disable it.
276 .It Va net.link.bridge.pfil_local_phys
277 Set to
278 .Li 1
279 to additionally filter on the physical interface for locally destined packets.
280 Set to
281 .Li 0
282 to disable this feature.
283 .It Va net.link.bridge.ipfw
284 Set to
285 .Li 1
286 to enable layer2 filtering with
287 .Xr ipfirewall 4 ,
288 set to
289 .Li 0
290 to disable it.
291 This needs to be enabled for
292 .Xr dummynet 4
293 support.
294 When
295 .Va ipfw
296 is enabled,
297 .Va pfil_bridge
298 and
299 .Va pfil_member
300 will be disabled so that IPFW
301 is not run twice; these can be re-enabled if desired.
302 .It Va net.link.bridge.ipfw_arp
303 Set to
304 .Li 1
305 to enable layer2 ARP filtering with
306 .Xr ipfirewall 4 ,
307 set to
308 .Li 0
309 to disable it.
310 Requires
311 .Va ipfw
312 to be enabled.
313 .El
314 .Pp
315 ARP and REVARP packets are forwarded without being filtered and others
316 that are not IP nor IPv6 packets are not forwarded when
317 .Va pfil_onlyip
318 is enabled.
319 IPFW can filter Ethernet types using
320 .Cm mac-type
321 so all packets are passed to
322 the filter for processing.
323 .Pp
324 The packets originating from the bridging host will be seen by
325 the filter on the interface that is looked up in the routing
326 table.
327 .Pp
328 The packets destined to the bridging host will be seen by the filter
329 on the interface with the MAC address equal to the packet's destination
330 MAC.
331 There are situations when some of the bridge members are sharing
332 the same MAC address (for example the
333 .Xr vlan 4
334 interfaces: they are currently sharing the
335 MAC address of the parent physical interface).
336 It is not possible to distinguish between these interfaces using
337 their MAC address, excluding the case when the packet's destination
338 MAC address is equal to the MAC address of the interface on which
339 the packet was entered to the system.
340 In this case the filter will see the incoming packet on this
341 interface.
342 In all other cases the interface seen by the packet filter is chosen
343 from the list of bridge members with the same MAC address and the
344 result strongly depends on the member addition sequence and the
345 actual implementation of
346 .Nm .
347 It is not recommended to rely on the order chosen by the current
348 .Nm
349 implementation: it can be changed in the future.
350 .Pp
351 The previous paragraph is best illustrated with the following
352 pictures.
353 Let
354 .Bl -bullet
355 .It
356 the MAC address of the incoming packet's destination is
357 .Nm nn:nn:nn:nn:nn:nn ,
358 .It
359 the interface on which packet entered the system is
360 .Nm ifX ,
361 .It
362 .Nm ifX
363 MAC address is
364 .Nm xx:xx:xx:xx:xx:xx ,
365 .It
366 there are possibly other bridge members with the same MAC address
367 .Nm xx:xx:xx:xx:xx:xx ,
368 .It
369 the bridge has more than one interface that are sharing the
370 same MAC address
371 .Nm yy:yy:yy:yy:yy:yy ;
372 we will call them
373 .Nm vlanY1 ,
374 .Nm vlanY2 ,
375 etc.
376 .El
377 .Pp
378 Then if the MAC address
379 .Nm nn:nn:nn:nn:nn:nn
380 is equal to the
381 .Nm xx:xx:xx:xx:xx:xx
382 then the filter will see the packet on the interface
383 .Nm ifX
384 no matter if there are any other bridge members carrying the same
385 MAC address.
386 But if the MAC address
387 .Nm nn:nn:nn:nn:nn:nn
388 is equal to the
389 .Nm yy:yy:yy:yy:yy:yy
390 then the interface that will be seen by the filter is one of the
391 .Nm vlanYn .
392 It is not possible to predict the name of the actual interface
393 without the knowledge of the system state and the
394 .Nm
395 implementation details.
396 .Pp
397 This problem arises for any bridge members that are sharing the same
398 MAC address, not only to the
399 .Xr vlan 4
400 ones: they we taken just as the example of such situation.
401 So if one wants the filter the locally destined packets based on
402 their interface name, one should be aware of this implication.
403 The described situation will appear at least on the filtering bridges
404 that are doing IP-forwarding; in some of such cases it is better
405 to assign the IP address only to the
406 .Nm
407 interface and not to the bridge members.
408 Enabling
409 .Va net.link.bridge.pfil_local_phys
410 will let you do the additional filtering on the physical interface.
411 .Sh EXAMPLES
412 The following when placed in the file
413 .Pa /etc/rc.conf
414 will cause a bridge called
415 .Dq Li bridge0
416 to be created, and will add the interfaces
417 .Dq Li wlan0
418 and
419 .Dq Li fxp0
420 to the bridge, and then enable packet forwarding.
421 Such a configuration could be used to implement a simple
422 802.11-to-Ethernet bridge (assuming the 802.11 interface is
423 in ad-hoc mode).
424 .Bd -literal -offset indent
425 cloned_interfaces="bridge0"
426 ifconfig_bridge0="addm wlan0 addm fxp0 up"
427 .Ed
428 .Pp
429 For the bridge to forward packets all member interfaces and the bridge need
430 to be up.
431 The above example would also require:
432 .Bd -literal -offset indent
433 create_args_wlan0="wlanmode hostap"
434 ifconfig_wlan0="up ssid my_ap mode 11g"
435 ifconfig_fxp0="up"
436 .Ed
437 .Pp
438 Consider a system with two 4-port Ethernet boards.
439 The following will cause a bridge consisting of all 8 ports with Rapid Spanning
440 Tree enabled to be created:
441 .Bd -literal -offset indent
442 ifconfig bridge0 create
443 ifconfig bridge0 \e
444     addm fxp0 stp fxp0 \e
445     addm fxp1 stp fxp1 \e
446     addm fxp2 stp fxp2 \e
447     addm fxp3 stp fxp3 \e
448     addm fxp4 stp fxp4 \e
449     addm fxp5 stp fxp5 \e
450     addm fxp6 stp fxp6 \e
451     addm fxp7 stp fxp7 \e
452     up
453 .Ed
454 .Pp
455 The bridge can be used as a regular host interface at the same time as bridging
456 between its member ports.
457 In this example, the bridge connects em0 and em1, and will receive its IP
458 address through DHCP:
459 .Bd -literal -offset indent
460 cloned_interfaces="bridge0"
461 ifconfig_bridge0="addm em0 addm em1 DHCP"
462 ifconfig_em0="up"
463 ifconfig_em1="up"
464 .Ed
465 .Pp
466 The bridge can tunnel Ethernet across an IP internet using the EtherIP
467 protocol.
468 This can be combined with
469 .Xr ipsec 4
470 to provide an encrypted connection.
471 Create a
472 .Xr gif 4
473 interface and set the local and remote IP addresses for the
474 tunnel, these are reversed on the remote bridge.
475 .Bd -literal -offset indent
476 ifconfig gif0 create
477 ifconfig gif0 tunnel 1.2.3.4 5.6.7.8 up
478 ifconfig bridge0 create
479 ifconfig bridge0 addm fxp0 addm gif0 up
480 .Ed
481 .Pp
482 Note that
483 .Fx
484 6.1, 6.2, 6.3, 7.0, 7.1, and 7.2 have a bug in the EtherIP protocol.
485 For more details and workaround, see
486 .Xr gif 4
487 manual page.
488 .Sh SEE ALSO
489 .Xr gif 4 ,
490 .Xr ipf 4 ,
491 .Xr ipfw 4 ,
492 .Xr pf 4 ,
493 .Xr ifconfig 8
494 .Sh HISTORY
495 The
496 .Nm
497 driver first appeared in
498 .Fx 6.0 .
499 .Sh AUTHORS
500 .An -nosplit
501 The
502 .Nm bridge
503 driver was originally written by
504 .An Jason L. Wright
505 .Aq jason@thought.net
506 as part of an undergraduate independent study at the University of
507 North Carolina at Greensboro.
508 .Pp
509 This version of the
510 .Nm
511 driver has been heavily modified from the original version by
512 .An Jason R. Thorpe
513 .Aq thorpej@wasabisystems.com .
514 .Pp
515 Rapid Spanning Tree Protocol (RSTP) support was added by
516 .An Andrew Thompson
517 .Aq thompsa@FreeBSD.org .
518 .Sh BUGS
519 The
520 .Nm
521 driver currently supports only Ethernet and Ethernet-like (e.g., 802.11)
522 network devices, with exactly the same interface MTU size as the bridge device.