1998-12-21 22:37:53 +00:00
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1998-12-21 22:37:53 +00:00
|
|
|
.\"
|
2003-09-21 23:16:02 +00:00
|
|
|
.Dd September 20, 2003
|
1998-12-21 22:37:53 +00:00
|
|
|
.Dt BRIDGE 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm bridge
|
2001-04-18 15:54:10 +00:00
|
|
|
.Nd bridging support
|
2001-08-07 13:18:09 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Cd "options BRIDGE"
|
1998-12-21 22:37:53 +00:00
|
|
|
.Sh DESCRIPTION
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx
|
2002-02-18 01:57:56 +00:00
|
|
|
supports bridging on Ethernet-type interfaces, including VLANs.
|
|
|
|
Bridging support can be either compiled into the kernel, or loaded
|
|
|
|
at runtime as a kernel module.
|
|
|
|
.Pp
|
|
|
|
A single
|
|
|
|
.Fx
|
|
|
|
host can do bridging on independent sets of interfaces,
|
|
|
|
which are called
|
2002-03-18 13:52:30 +00:00
|
|
|
.Dq clusters .
|
2002-02-18 01:57:56 +00:00
|
|
|
Each cluster connects a set of interfaces, and is
|
2002-03-18 13:52:30 +00:00
|
|
|
identified by a
|
|
|
|
.Dq cluster-ID
|
|
|
|
which is a number in the range 1..65535.
|
2002-02-18 01:57:56 +00:00
|
|
|
A cluster in fact is very similar to what commercial switches call
|
2002-03-18 13:52:30 +00:00
|
|
|
a
|
|
|
|
.Dq VLAN .
|
|
|
|
Note however that there is no relation whatsoever
|
|
|
|
between the cluster-ID and the IEEE 802.1q VLAN-ID which appears
|
2002-02-18 01:57:56 +00:00
|
|
|
in the header of packets transmitted on the wire.
|
|
|
|
In fact, in most cases there is no relation between the
|
2002-03-18 13:52:30 +00:00
|
|
|
so-called
|
|
|
|
.Dq "VLAN identifier"
|
|
|
|
used in most commercial switches, and
|
|
|
|
the IEEE 802.1q VLAN-ID.
|
|
|
|
.Pp
|
|
|
|
By putting both physical and logical
|
|
|
|
.Pq Xr vlan 4
|
|
|
|
interfaces in the same cluster, a
|
|
|
|
.Fx
|
|
|
|
box can also implement what in commercial terms is called a
|
|
|
|
.Dq trunk
|
|
|
|
interface.
|
2002-03-18 14:41:47 +00:00
|
|
|
This means that packets
|
|
|
|
coming from one of the interfaces in a cluster
|
|
|
|
will appear on the wire of the
|
2002-03-18 13:52:30 +00:00
|
|
|
.Dq parent
|
2002-03-18 14:41:47 +00:00
|
|
|
interface of any VLAN interface in a cluster,
|
|
|
|
with the proper VLAN tag.
|
|
|
|
Similarly, packets
|
|
|
|
coming from a parent interface of any VLAN interface in a cluster
|
|
|
|
will have the VLAN tag stripped,
|
|
|
|
and will be forwarded to other interfaces in a cluster.
|
2002-02-18 01:57:56 +00:00
|
|
|
See the
|
|
|
|
.Sx EXAMPLES
|
|
|
|
section for more details.
|
2000-11-14 11:20:58 +00:00
|
|
|
.Pp
|
2001-08-07 13:18:09 +00:00
|
|
|
Runtime operation of the
|
|
|
|
.Nm
|
|
|
|
is controlled by several
|
2001-07-26 21:19:25 +00:00
|
|
|
.Xr sysctl 8
|
2002-02-18 01:57:56 +00:00
|
|
|
variables, as follows.
|
|
|
|
.Bl -tag -width indent
|
2003-09-21 23:16:02 +00:00
|
|
|
.It Va net.link.ether.bridge.enable
|
|
|
|
Set to
|
2001-07-26 21:19:25 +00:00
|
|
|
.Li 1
|
2002-02-18 01:57:56 +00:00
|
|
|
to enable bridging, set to
|
2001-07-26 21:19:25 +00:00
|
|
|
.Li 0
|
|
|
|
to disable it.
|
2003-09-21 23:16:02 +00:00
|
|
|
.It Va net.link.ether.bridge.ipfw
|
|
|
|
Set to
|
2001-07-26 21:19:25 +00:00
|
|
|
.Li 1
|
|
|
|
to enable
|
|
|
|
.Xr ipfw 8
|
2003-09-21 23:16:02 +00:00
|
|
|
processing of bridged packets.
|
2000-03-01 14:50:24 +00:00
|
|
|
Note that
|
2001-07-26 21:19:25 +00:00
|
|
|
.Xr ipfw 8
|
1998-12-21 22:37:53 +00:00
|
|
|
rules only apply
|
2000-03-01 14:50:24 +00:00
|
|
|
to IP packets.
|
2002-02-18 01:57:56 +00:00
|
|
|
Non-IP packets are accepted by default.
|
|
|
|
See the
|
|
|
|
.Sx BUGS
|
|
|
|
section and the
|
2001-07-26 21:19:25 +00:00
|
|
|
.Xr ipfw 8
|
2002-02-18 01:57:56 +00:00
|
|
|
manpage for more details on the interaction of bridging
|
|
|
|
and the firewall.
|
2003-09-21 23:16:02 +00:00
|
|
|
.It Va net.link.ether.bridge.ipf
|
|
|
|
Set to
|
|
|
|
.Li 1
|
|
|
|
to enable
|
|
|
|
.Xr ipf 8
|
|
|
|
processing of bridged packets.
|
|
|
|
Note that
|
|
|
|
.Xr ipf 8
|
|
|
|
rules only apply
|
|
|
|
to IP packets.
|
|
|
|
Non-IP packets are accepted by default.
|
|
|
|
.It Va net.link.ether.bridge.config
|
|
|
|
Set to the list of interfaces to bridge.
|
2002-03-18 13:52:30 +00:00
|
|
|
Interfaces are separated by spaces, commas or tabs.
|
|
|
|
Each interface
|
2002-02-18 01:57:56 +00:00
|
|
|
can be optionally followed by a colon and an integer indicating the
|
2002-03-18 13:52:30 +00:00
|
|
|
cluster it belongs to (defaults to 1 if the cluster-ID is missing), e.g.\&
|
|
|
|
.Dq Li "dc0:1,dc1,vlan0:3 dc2:3"
|
|
|
|
will put
|
|
|
|
.Li dc0
|
|
|
|
and
|
|
|
|
.Li dc1
|
|
|
|
in cluster number 1, and
|
|
|
|
.Li vlan0
|
|
|
|
and
|
|
|
|
.Li dc2
|
|
|
|
in cluster
|
2002-02-18 01:57:56 +00:00
|
|
|
number 3.
|
|
|
|
See the
|
|
|
|
.Sx EXAMPLES
|
|
|
|
section for more examples.
|
|
|
|
.Pp
|
|
|
|
The list of interfaces is rescanned every time the list is
|
|
|
|
modified, bridging is enabled, or new interfaces are created or
|
2002-03-18 13:52:30 +00:00
|
|
|
destroyed.
|
2003-09-21 23:16:02 +00:00
|
|
|
An explicit request to refresh the bridge configuration can also
|
|
|
|
be done by writing any value to
|
|
|
|
.Va net.link.ether.bridge.refresh .
|
2002-03-18 13:52:30 +00:00
|
|
|
Interfaces that are in the list but cannot be used
|
2002-02-18 01:57:56 +00:00
|
|
|
for bridging (because they are non-existing, or not Ethernet or VLAN)
|
|
|
|
are not used and a warning message is generated.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Bridging requires interfaces to be put in promiscuous mode,
|
2003-09-21 23:16:02 +00:00
|
|
|
and transmit packets with Ethernet source addresses different
|
|
|
|
than their own.
|
2002-03-18 13:52:30 +00:00
|
|
|
Some interfaces (e.g.\&
|
2002-02-18 01:57:56 +00:00
|
|
|
.Xr wi 4 )
|
|
|
|
do not support this functionality.
|
|
|
|
Also, bridging is not compatible with interfaces which
|
|
|
|
use hardware loopback, because there is no way to tell locally
|
|
|
|
generated packets from externally generated ones.
|
2001-07-26 21:19:25 +00:00
|
|
|
.Sh EXAMPLES
|
2002-02-18 01:57:56 +00:00
|
|
|
A simple bridge configuration with three interfaces in the same
|
2002-03-18 13:52:30 +00:00
|
|
|
cluster can be set as follows.
|
|
|
|
No cluster-ID is specified here, which
|
2002-02-18 01:57:56 +00:00
|
|
|
will cause the interfaces to appear as part of cluster #1.
|
|
|
|
.Pp
|
2003-09-21 23:16:02 +00:00
|
|
|
.Dl "sysctl net.link.ether.bridge.config=dc0,dc1,fxp1"
|
2002-02-18 01:57:56 +00:00
|
|
|
.Pp
|
|
|
|
If you do not know what actual interfaces will be present on
|
|
|
|
your system, you can just put all existing interfaces in the
|
|
|
|
configuration, as follows:
|
|
|
|
.Pp
|
2003-09-21 23:16:02 +00:00
|
|
|
.Dl sysctl net.link.ether.bridge.config="`ifconfig -l`"
|
2002-02-18 01:57:56 +00:00
|
|
|
.Pp
|
|
|
|
This will result in a space-separated list of interfaces.
|
2002-03-18 13:52:30 +00:00
|
|
|
Out of the list, only Ethernet and VLAN interfaces will be
|
2002-02-18 01:57:56 +00:00
|
|
|
used for bridging, whereas for others the kernel will produce
|
|
|
|
a warning message.
|
|
|
|
.Pp
|
|
|
|
More complex configurations can be used to create multiple
|
2002-03-18 13:52:30 +00:00
|
|
|
clusters, e.g.\&
|
2002-02-18 01:57:56 +00:00
|
|
|
.Pp
|
2003-09-21 23:16:02 +00:00
|
|
|
.Dl "sysctl net.link.ether.bridge.config=dc0:3,dc1:3,fxp0:4,fxp1:4"
|
2002-02-18 01:57:56 +00:00
|
|
|
.Pp
|
|
|
|
will create two completely independent clusters.
|
|
|
|
.Pp
|
2002-03-18 13:52:30 +00:00
|
|
|
Finally, interesting configurations involve VLANs and parent interfaces.
|
|
|
|
As an example, the following configuration will use interface
|
|
|
|
.Li dc0
|
|
|
|
as a
|
|
|
|
.Dq trunk
|
|
|
|
interface, and pass packets
|
|
|
|
for 802.1q VLANs 10 and 20 to physical interfaces
|
|
|
|
.Li dc1
|
|
|
|
and
|
2002-03-18 14:41:47 +00:00
|
|
|
.Li dc2 ,
|
|
|
|
respectively:
|
2002-03-18 13:52:30 +00:00
|
|
|
.Bd -literal -offset indent
|
2003-09-21 23:16:02 +00:00
|
|
|
sysctl net.link.ether.bridge.config=vlan0:34,dc1:34,vlan1:56,dc2:56
|
2002-03-18 13:52:30 +00:00
|
|
|
ifconfig vlan0 vlan 10 vlandev dc0
|
|
|
|
ifconfig vlan1 vlan 20 vlandev dc0
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Note how there is no relation between the 802.1q VLAN identifiers
|
|
|
|
(10 and 20) and the cluster-ID's (34 and 56) used in
|
|
|
|
the
|
2003-09-21 23:16:02 +00:00
|
|
|
.Va bridge.config
|
2002-03-18 13:52:30 +00:00
|
|
|
variable.
|
2002-02-18 01:57:56 +00:00
|
|
|
.Pp
|
|
|
|
Note also that the trunk interface
|
2002-03-18 13:52:30 +00:00
|
|
|
does not even appear in the
|
2003-09-21 23:16:02 +00:00
|
|
|
.Va bridge.config ,
|
2002-03-18 13:52:30 +00:00
|
|
|
as VLAN tag insertion/removal
|
2002-02-18 01:57:56 +00:00
|
|
|
is performed by the
|
|
|
|
.Xr vlan 4
|
|
|
|
devices.
|
2002-03-18 13:52:30 +00:00
|
|
|
When using VLAN devices, care must be taken by not creating loops
|
2002-02-18 01:57:56 +00:00
|
|
|
between these devices and their parent interfaces.
|
1998-12-21 22:37:53 +00:00
|
|
|
.Sh BUGS
|
2001-08-07 13:18:09 +00:00
|
|
|
Care must be taken not to construct loops in the
|
|
|
|
.Nm
|
|
|
|
topology.
|
1998-12-21 22:37:53 +00:00
|
|
|
The kernel supports only a primitive form of loop detection, by disabling
|
2000-03-01 14:50:24 +00:00
|
|
|
some interfaces when a loop is detected.
|
|
|
|
No support for a daemon running the
|
1998-12-21 22:37:53 +00:00
|
|
|
spanning tree algorithm is currently provided.
|
|
|
|
.Pp
|
|
|
|
With bridging active, interfaces are in promiscuous mode,
|
|
|
|
thus causing some load on the system to receive and filter
|
|
|
|
out undesired traffic.
|
|
|
|
.Pp
|
2002-02-18 01:57:56 +00:00
|
|
|
When passing bridged packets to
|
|
|
|
.Xr ipfw 8 ,
|
|
|
|
remember that only IP packets are passed to the firewall, while
|
|
|
|
other packets are silently accepted.
|
|
|
|
Also remember that bridged packets are accepted after the
|
|
|
|
first pass through the firewall irrespective of the setting
|
|
|
|
of the sysctl variable
|
2002-03-18 13:52:30 +00:00
|
|
|
.Va net.inet.ip.fw.one_pass ,
|
2002-02-18 01:57:56 +00:00
|
|
|
and that some
|
2002-03-18 13:52:30 +00:00
|
|
|
.Xr ipfw 8
|
2002-02-18 01:57:56 +00:00
|
|
|
actions such as
|
2002-03-18 13:52:30 +00:00
|
|
|
.Cm divert
|
2002-02-18 01:57:56 +00:00
|
|
|
do not apply to bridged packets.
|
|
|
|
It might be useful to have a rule of the form
|
|
|
|
.Pp
|
2002-03-18 13:52:30 +00:00
|
|
|
.Dl "skipto 20000 ip from any to any bridged"
|
1998-12-21 22:37:53 +00:00
|
|
|
.Pp
|
2002-02-18 01:57:56 +00:00
|
|
|
near the beginning of your ruleset to implement specific rulesets
|
|
|
|
for bridged packets.
|
2002-03-18 13:52:30 +00:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width ".Pa /boot/kernel/bridge.ko" -compact
|
|
|
|
.It Pa /boot/kernel/bridge.ko
|
|
|
|
.Nm
|
|
|
|
loadable module.
|
|
|
|
.El
|
1998-12-21 22:37:53 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr ip 4 ,
|
2000-09-01 01:37:25 +00:00
|
|
|
.Xr ng_bridge 4 ,
|
2002-02-18 01:57:56 +00:00
|
|
|
.Xr vlan 4 ,
|
2003-09-21 23:16:02 +00:00
|
|
|
.Xr ipf 8 ,
|
1998-12-21 22:37:53 +00:00
|
|
|
.Xr ipfw 8 ,
|
2000-11-15 16:00:07 +00:00
|
|
|
.Xr sysctl 8
|
1998-12-21 22:37:53 +00:00
|
|
|
.Sh HISTORY
|
2002-02-18 01:57:56 +00:00
|
|
|
Bridging was introduced in
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx 2.2.8
|
1999-04-16 02:09:38 +00:00
|
|
|
by
|
|
|
|
.An Luigi Rizzo Aq luigi@iet.unipi.it .
|