1db37145fSSimon Schubert.\" Copyright 2001 Wasabi Systems, Inc. 2db37145fSSimon Schubert.\" All rights reserved. 3db37145fSSimon Schubert.\" 4db37145fSSimon Schubert.\" Written by Jason R. Thorpe for Wasabi Systems, Inc. 53677aae9SMatthew Dillon.\" Spanning tree modifications by Matthew Dillon 6db37145fSSimon Schubert.\" 7db37145fSSimon Schubert.\" Redistribution and use in source and binary forms, with or without 8db37145fSSimon Schubert.\" modification, are permitted provided that the following conditions 9db37145fSSimon Schubert.\" are met: 10db37145fSSimon Schubert.\" 1. Redistributions of source code must retain the above copyright 11db37145fSSimon Schubert.\" notice, this list of conditions and the following disclaimer. 12db37145fSSimon Schubert.\" 2. Redistributions in binary form must reproduce the above copyright 13db37145fSSimon Schubert.\" notice, this list of conditions and the following disclaimer in the 14db37145fSSimon Schubert.\" documentation and/or other materials provided with the distribution. 15db37145fSSimon Schubert.\" 3. All advertising materials mentioning features or use of this software 16db37145fSSimon Schubert.\" must display the following acknowledgement: 17db37145fSSimon Schubert.\" This product includes software developed for the NetBSD Project by 18db37145fSSimon Schubert.\" Wasabi Systems, Inc. 19db37145fSSimon Schubert.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse 20db37145fSSimon Schubert.\" or promote products derived from this software without specific prior 21db37145fSSimon Schubert.\" written permission. 22db37145fSSimon Schubert.\" 23db37145fSSimon Schubert.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 24db37145fSSimon Schubert.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25db37145fSSimon Schubert.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26db37145fSSimon Schubert.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 27db37145fSSimon Schubert.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28db37145fSSimon Schubert.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29db37145fSSimon Schubert.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30db37145fSSimon Schubert.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31db37145fSSimon Schubert.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32db37145fSSimon Schubert.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33db37145fSSimon Schubert.\" POSSIBILITY OF SUCH DAMAGE. 34db37145fSSimon Schubert.\" 35db37145fSSimon Schubert.\" 36*93f7425fSRoy Marples.Dd June 20, 2024 37db37145fSSimon Schubert.Dt BRIDGE 4 38db37145fSSimon Schubert.Os 39db37145fSSimon Schubert.Sh NAME 40db37145fSSimon Schubert.Nm bridge 41db37145fSSimon Schubert.Nd network bridge device 42db37145fSSimon Schubert.Sh SYNOPSIS 43db37145fSSimon Schubert.Cd "pseudo-device bridge" 44db37145fSSimon Schubert.Sh DESCRIPTION 45db37145fSSimon SchubertThe 46db37145fSSimon Schubert.Nm 47db37145fSSimon Schubertdriver creates a logical link between two or more IEEE 802 networks 48db37145fSSimon Schubertthat use the same (or 49db37145fSSimon Schubert.Dq similar enough ) 50db37145fSSimon Schubertframing format. 51db37145fSSimon SchubertFor example, it is possible to bridge Ethernet and 802.11 networks together, 52db37145fSSimon Schubertbut it is not possible to bridge Ethernet and Token Ring together. 53db37145fSSimon Schubert.Pp 54db37145fSSimon SchubertTo use 559b5a9965SSascha Wildner.Nm , 56db37145fSSimon Schubertthe administrator must first create the interface and configure 57db37145fSSimon Schubertthe bridge parameters. 58db37145fSSimon SchubertThe bridge is created using the 59db37145fSSimon Schubert.Xr ifconfig 8 60db37145fSSimon Schubert.Cm create 61db37145fSSimon Schubertsubcommand. 6245eff2e9SSascha WildnerSee the 6345eff2e9SSascha Wildner.Xr ifconfig 8 6445eff2e9SSascha Wildnermanual page for further information on configuring bridges. 65db37145fSSimon Schubert.Pp 66db37145fSSimon SchubertA bridge can be used to provide several services, such as a simple 67db37145fSSimon Schubert802.11-to-Ethernet bridge for wireless hosts, and traffic isolation. 68db37145fSSimon Schubert.Pp 69db37145fSSimon SchubertA bridge works like a hub, forwarding traffic from one interface 70db37145fSSimon Schubertto another. 71db37145fSSimon SchubertMulticast and broadcast packets are always forwarded to all 72db37145fSSimon Schubertinterfaces that are part of the bridge. 73db37145fSSimon SchubertFor unicast traffic, the bridge learns which MAC addresses are associated 74db37145fSSimon Schubertwith which interfaces and will forward the traffic selectively. 75f77968fbSMatthew DillonBy default the bridge can keep track of 4096 MAC addresses. 76db37145fSSimon Schubert.Pp 77be02a6a0SMatthew DillonThe bridge operates in a safe mode by default, setting the MAC source in 78be02a6a0SMatthew Dillonthe link header on outgoing packets to the outgoing interface MAC. 79be02a6a0SMatthew DillonThis reduces the chance that the layer-2 switching in your switches 80be02a6a0SMatthew Dillonwill become confused. 811e858374SMatthew Dillon.Pp 821e858374SMatthew DillonThe bridge supports various special features via 831e858374SMatthew Dillon.Cm link 841e858374SMatthew Dillonoptions. 857a99a444SSascha Wildner.Bl -tag -width indent 861e858374SMatthew Dillon.It Cm link0 871e858374SMatthew DillonThe link0 option enables transparent bridging mode. 881e858374SMatthew DillonThe bridge will make every effort to retain the ethernet header 891e858374SMatthew Dillonwhen forwarding packets between interfaces, making the bridging 901e858374SMatthew Dillonfunction work more like a hardware bridge device. 911e858374SMatthew Dillon.It Cm link1 921e858374SMatthew DillonThe link1 option enables keepalive transmission and automatically 931e858374SMatthew Dillonplaces a member into a special blocked mode if no keepalive reception 941e858374SMatthew Dillonoccurs. 951e858374SMatthew DillonIf either sides of the link uses this option then both sides must use 961e858374SMatthew Dillonthis option. 97448d94c1SAntonio Huete JimenezThis option is implemented by sending CFG updates on the hello interval 981e858374SMatthew Dillonto the remote. 991e858374SMatthew DillonThe link is considered lost after 10 intervals (typically 20 seconds). 1001e858374SMatthew Dillon.It Cm link2 101e6720526SMatthew DillonThe link2 option enables channel bonding (see also ifbondweight, ifpriority). 1021e858374SMatthew DillonAll member interfaces with the same mac address are considered to 103e6720526SMatthew Dillonbe in a bonding group. Packets will be sent on the highest priority 104e6720526SMatthew Dilloninterface(s) in the bonding group, and will round-robin output interfaces 105e6720526SMatthew Dillonwhen multiple (highest priority) interfaces have the same priority. 1061e858374SMatthew DillonWhen something like 1071e858374SMatthew Dillon.Xr tap 4 1081e858374SMatthew Dillonis used, you can manually control or copy the mac to create bonding groups. 1091e858374SMatthew DillonWhen interface bonding is enabled normally blocked interfaces belonging 1101e858374SMatthew Dillonto the same bonding group as an active forwarding interface will be 1111e858374SMatthew Dillonchanged to the bonding state. 1121e858374SMatthew DillonBoth sides of link the member represents must operate in bonding mode 1131e858374SMatthew Dillonfor this to work, otherwise the remote end may decide to throw away 1141e858374SMatthew Dillonhalf your packets. 1157a99a444SSascha Wildner.El 116be02a6a0SMatthew Dillon.Pp 117be02a6a0SMatthew DillonIf your network becomes glitchy, with long pauses in tcp sessions, then 118be02a6a0SMatthew Dillontransparent bridging mode is likely the cause. This mode should only be 119be02a6a0SMatthew Dillonused when you are bridging networks with devices that do MAC-based security 120be02a6a0SMatthew Dillonor firewalling (for example, the supremely braindead at&t uverse router), 121be02a6a0SMatthew Dillonor which impose severe limitations on MAC:IP assignments. 122be02a6a0SMatthew Dillon.Pp 1231e858374SMatthew DillonIf member interfaces constantly enter a 'blocked (link1)' state then the 1241e858374SMatthew Dillonother end of those interfaces is not implementing the link1 keepalive. 1251e858374SMatthew DillonBoth sides must implement the keepalive. 1261e858374SMatthew Dillon.Pp 1271e858374SMatthew DillonIf you get an enormous amount of packet loss and are using link2-based 1281e858374SMatthew Dillonbonding, then the other side of those member interfaces are probably 1291e858374SMatthew Dillonnot implementing link2-based bonding. 1301e858374SMatthew Dillon.Pp 131db37145fSSimon SchubertThe 132db37145fSSimon Schubert.Nm 133db37145fSSimon Schubertdriver implements the IEEE 802.1D Spanning Tree protocol (STP). 134db37145fSSimon SchubertSpanning Tree is used to detect and remove loops in a network topology. 135db37145fSSimon Schubert.Pp 136db37145fSSimon SchubertPacket filtering can be used with any firewall package that hooks in via the 137db37145fSSimon Schubert.Xr pfil 9 138db37145fSSimon Schubertframework. 139db37145fSSimon SchubertWhen filtering is enabled, bridged packets will pass through the filter 140db37145fSSimon Schubertinbound on the originating interface, on the bridge interface and outbound on 141db37145fSSimon Schubertthe appropriate interfaces. 142*93f7425fSRoy MarplesEither stage can be disabled as well as the filtering of non IP and IPv6 143*93f7425fSRoy Marplespackets. 144*93f7425fSRoy MarplesNote that ARP and REVARP packets are always forwarded without being filtered. 145*93f7425fSRoy Marples.Pp 146*93f7425fSRoy MarplesThis behaviour can be controlled using 147db37145fSSimon Schubert.Xr sysctl 8 : 148db37145fSSimon SchubertSet 149db37145fSSimon Schubert.Va net.link.bridge.pfil_member 150db37145fSSimon Schubertto 151db37145fSSimon Schubert.Li 1 152*93f7425fSRoy Marplesto enable filtering on the incoming and outgoing member interfaces, 153*93f7425fSRoy Marplesset 154db37145fSSimon Schubert.Va net.link.bridge.pfil_bridge 155db37145fSSimon Schubertto 156db37145fSSimon Schubert.Li 1 157*93f7425fSRoy Marplesto enable filtering on the bridge interface 158*93f7425fSRoy Marplesand set 159*93f7425fSRoy Marples.Va net.link.bridge.pfil_onlyip 160*93f7425fSRoy Marplesto 161*93f7425fSRoy Marples.Li 1 162*93f7425fSRoy Marplesto only allow IP and IPv6 packets to be forawarded when filtering is 163db37145fSSimon Schubertenabled. 164*93f7425fSRoy MarplesFor example, setting 165*93f7425fSRoy Marples.Va net.link.bridge.pfil_onlyip 166*93f7425fSRoy Marplesto 167*93f7425fSRoy Marples.Li 0 168*93f7425fSRoy Marpleswould allow PPPoE traffic over the bridge. 169*93f7425fSRoy Marples.Pp 170*93f7425fSRoy MarplesThe default value of the 171*93f7425fSRoy Marples.Va net.link.bridge.pfil_* 172*93f7425fSRoy Marplesnodes is 173*93f7425fSRoy Marples.Li 1 . 174db37145fSSimon Schubert.Pp 175db37145fSSimon SchubertNote that packets to and from the bridging host will be seen by the 176db37145fSSimon Schubertfilter on the interface with the appropriate address configured as well 177db37145fSSimon Schubertas on the interface on which the packet arrives or departs. 178db37145fSSimon Schubert.Pp 179db37145fSSimon SchubertThe MTU of the first member interface to be added is used as the bridge MTU, 180db37145fSSimon Schubertall additional members are required to have exactly the same value. 1813677aae9SMatthew Dillon.Sh EXTRA FEATURES 1823677aae9SMatthew Dillon.Dx 1833677aae9SMatthew Dillonimplements two additional features to make spanning tree operation more 1843677aae9SMatthew Dillonresilient. 1853677aae9SMatthew Dillon.Pp 1863677aae9SMatthew DillonSpecifying 1873677aae9SMatthew Dillon.Cm link0 1883677aae9SMatthew Dillonon the bridge interface places the bridge in transparent bridging mode. 1893677aae9SMatthew DillonThe bridge will make every attempt to retain the original source MAC in 1903677aae9SMatthew Dillonthe ethernet link header. 1913677aae9SMatthew Dillon.Pp 1923677aae9SMatthew DillonSpecifying 1933677aae9SMatthew Dillon.Cm link1 1943677aae9SMatthew Dillonon the bridge interface forces the bridge to generate a 802.11d CFG 1953677aae9SMatthew Dillonmessage on every hello interval for all interfaces participating 1963677aae9SMatthew Dillonin the STP protocol. 1973677aae9SMatthew DillonNormally CFG messages are only generated by the root bridge interface 1983677aae9SMatthew Dillonor during topology changes. 1993677aae9SMatthew DillonIn addition the bridge code expects to receive 802.11d frames from 2003677aae9SMatthew Dillonall interface participating in the STP protocol. 2013677aae9SMatthew Dillon.Pp 2023677aae9SMatthew DillonAn interface which fails to receive a 802.11d frame within 10 times 2033677aae9SMatthew Dillonthe hello interval (usually 20 seconds) automatically goes into 2043677aae9SMatthew Dillonl1blocking mode, which can be observed in the ifconfig output for 2053677aae9SMatthew Dillonthe bridge. This removes the interface from consideration and the 2063677aae9SMatthew Dillonbridge code automatically routes around it. 2073677aae9SMatthew Dillon.Pp 2083677aae9SMatthew DillonUsing 2093677aae9SMatthew Dillon.Cm link0 2103677aae9SMatthew Dillonand 2113677aae9SMatthew Dillon.Cm link1 2123677aae9SMatthew Dillontogether between two 2133677aae9SMatthew Dillon.Dx 2143677aae9SMatthew Dillonboxes allows you to maintain multiple parallel vpns between those 2153677aae9SMatthew Dillonboxes via different networks (if you happen to be on more than one 2163677aae9SMatthew Dillonwith internet access). 2173677aae9SMatthew DillonUse separate openvpn instances and tap devices for each vpn link 2183677aae9SMatthew Dillonto accomplish this, placing them in the same bridge interface on 2193677aae9SMatthew Dillonthe two endpoints. 2203677aae9SMatthew DillonThe tap devices do not need any IP configuration when bridged and 2213677aae9SMatthew Dilloncan be assigned the same ether MAC (in fact they have to be 2223677aae9SMatthew Dillonif you want the failover to work nicely). 223db37145fSSimon Schubert.Sh SEE ALSO 224375d1659SSascha Wildner.Xr pf 4 , 22545eff2e9SSascha Wildner.Xr ifconfig 8 226db37145fSSimon Schubert.Sh HISTORY 227db37145fSSimon SchubertThe 228db37145fSSimon Schubert.Nm 229db37145fSSimon Schubertdriver first appeared in 230db37145fSSimon Schubert.Ox 2.5 231db37145fSSimon Schubertand found its way into 2329feb902cSSascha Wildner.Dx 1.3 . 233be02a6a0SMatthew DillonTransparent bridging (link0) was added in 234be02a6a0SMatthew Dillon.Dx 2.9 235be02a6a0SMatthew Dillonin 2011. 236db37145fSSimon Schubert.Sh AUTHORS 237db37145fSSimon Schubert.An -nosplit 238db37145fSSimon SchubertThe 2399b5a9965SSascha Wildner.Nm 240db37145fSSimon Schubertdriver was originally written by 241b2a6f486SFranco Fichtner.An Jason L. Wright Aq Mt jason@thought.net 242db37145fSSimon Schubertas part of an undergraduate independent study at the University of 243db37145fSSimon SchubertNorth Carolina at Greensboro. 244db37145fSSimon Schubert.Pp 245db37145fSSimon SchubertThis version of the 246db37145fSSimon Schubert.Nm 247db37145fSSimon Schubertdriver has been heavily modified from the original version by 248b2a6f486SFranco Fichtner.An Jason R. Thorpe Aq Mt thorpej@wasabisystems.com . 249db37145fSSimon Schubert.Sh BUGS 250db37145fSSimon SchubertThe 251db37145fSSimon Schubert.Nm 252db37145fSSimon Schubertdriver currently supports only Ethernet and Ethernet-like (e.g. 802.11) 253db37145fSSimon Schubertnetwork devices, with exactly the same interface MTU size as the bridge device. 254