<HTML ><HEAD ><TITLE >Set Up The Bridge</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.63 "><LINK REL="HOME" TITLE="Linux BRIDGE-STP-HOWTO" HREF="index.html"><LINK REL="PREVIOUS" TITLE="Preparing The Bridge" HREF="preparing-the-bridge.html"><LINK REL="NEXT" TITLE="Advanced Bridge Features" HREF="advanced-bridge.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Linux BRIDGE-STP-HOWTO: About The Linux Modular Bridge And STP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="preparing-the-bridge.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="advanced-bridge.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="SET-UP-THE-BRIDGE" >6. Set Up The Bridge</A ></H1 ><P >Make sure all your network cards are working nicely and are accessible. If so, <B CLASS="COMMAND" >ifconfig</B > will show you the hardware layout of the network-interface. If you have problems making your cards work please read the Ethernet-HOWTO at <A HREF="http://www.linuxdoc.org/HOWTO/Ethernet-HOWTO.html" TARGET="_top" >http://www.linuxdoc.org/HOWTO/Ethernet-HOWTO.html</A >. Don't mess around with IP-addresses or net-masks. You will not need it, until you bridge fully operational an up. </P ><P >After you did the steps mentioned above a <B CLASS="COMMAND" >modprobe -v bridge</B > should show no errors. You can check the success by issuing a <B CLASS="COMMAND" >cat /proc/modules</B >. Also for each of the network cards you want to use in the bridge the <B CLASS="COMMAND" >ifconfig <TT CLASS="USERINPUT" ><B >whateverNameYourInterfaceHas</B ></TT ></B > should give you some information about the interface. </P ><P >If your <SPAN CLASS="APPLICATION" >bridge-utilities</SPAN > have been correctly built and your kernel and bridge-module are OK, then issuing a <B CLASS="COMMAND" >brctl</B > should show a small command synopsis. </P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="BRCTL-SYNOPSIS" >6.1. <B CLASS="COMMAND" >brctl</B > Command Synopsis</A ></H2 ><P > <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl commands: addbr <bridge> add bridge <A NAME="BRCTL-ADDBR" ><IMG SRC="../images/callouts/1.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(1)"></A > addif <bridge> <device> add interface to bridge <A NAME="BRCTL-ADDIF" ><IMG SRC="../images/callouts/2.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(2)"></A > delbr <bridge> delete bridge <A NAME="BRCTL-DELBR" ><IMG SRC="../images/callouts/3.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(3)"></A > delif <bridge> <device> delete interface from bridge <A NAME="BRCTL-DELIF" ><IMG SRC="../images/callouts/4.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(4)"></A > show show a list of bridges <A NAME="BRCTL-SHOW" ><IMG SRC="../images/callouts/5.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(5)"></A > showbr <bridge> show bridge info <A NAME="BRCTL-SHOWBR" ><IMG SRC="../images/callouts/6.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(6)"></A > showmacs <bridge> show a list of mac addrs <A NAME="BRCTL-SHOWMACS" ><IMG SRC="../images/callouts/7.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(7)"></A > setageing <bridge> <time> set ageing time <A NAME="BRCTL-SETAGEING" ><IMG SRC="../images/callouts/8.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(8)"></A > setbridgeprio <bridge> <prio> set bridge priority <A NAME="BRCTL-SETBRIDGEPRIO" ><IMG SRC="../images/callouts/9.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(9)"></A > setfd <bridge> <time> set bridge forward delay <A NAME="BRCTL-SETFD" ><IMG SRC="../images/callouts/10.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(10)"></A > setgcint <bridge> <time> set garbage collection interval <A NAME="BRCTL-SETGCINT" ><B >(11)</B ></A > sethello <bridge> <time> set hello time <A NAME="BRCTL-SETHELLO" ><B >(12)</B ></A > setmaxage <bridge> <time> set max message age <A NAME="BRCTL-SETMAXAGE" ><B >(13)</B ></A > setpathcost <bridge> <port> <cost> set path cost <A NAME="BRCTL-SETPATHCOST" ><B >(14)</B ></A > setportprio <bridge> <port> <prio> set port priority <A NAME="BRCTL-SETPORTPRIO" ><B >(15)</B ></A > stp <bridge> <state> {dis,en}able stp <A NAME="BRCTL-STP" ><B >(16)</B ></A > </PRE ></TD ></TR ></TABLE > </P ><DIV CLASS="CALLOUTLIST" ><DL COMPACT="COMPACT" ><DT ><A HREF="set-up-the-bridge.html#BRCTL-ADDBR" ><IMG SRC="../images/callouts/1.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(1)"></A ><A HREF="set-up-the-bridge.html#BRCTL-DELBR" ><IMG SRC="../images/callouts/3.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(3)"></A ></DT ><DD >The <B CLASS="COMMAND" >brctl addbr <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B > command creates a logical bridge instance with the name <TT CLASS="USERINPUT" ><B >bridgename</B ></TT >. You will need at least one logical instance to do any bridging at all. You can interpret the logical bridge being a container for the interfaces taking part in the bridging. Each bridging instance is represented by a new network interface. </DD ><DIV CLASS="EXAMPLE" ><A NAME="CREATE-A-INSTANCE" ></A ><P ><B >Example 6. Creating A Instance</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl addbr mybridge1 </PRE ></TD ></TR ></TABLE ></DIV ><DD ><P >The corresponding <SPAN CLASS="QUOTE" >"shutdown"</SPAN > command is <B CLASS="COMMAND" >brctl delbr <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B >. <DIV CLASS="CAUTION" ><P ></P ><TABLE CLASS="CAUTION" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Caution</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P ><B CLASS="COMMAND" >brctl delbr <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B > will only work, if there are no more interfaces added to the instance you want to delete. </P ></TD ></TR ></TABLE ></DIV > </P ></DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-ADDIF" ><IMG SRC="../images/callouts/2.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(2)"></A ><A HREF="set-up-the-bridge.html#BRCTL-DELIF" ><IMG SRC="../images/callouts/4.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(4)"></A ></DT ><DD >The <B CLASS="COMMAND" >brctl addif <TT CLASS="USERINPUT" ><B >bridgename</B ></TT > <TT CLASS="USERINPUT" ><B >device</B ></TT ></B > command enslaves the network device <TT CLASS="USERINPUT" ><B >device</B ></TT > to take part in the bridging of <TT CLASS="USERINPUT" ><B >bridgename</B ></TT >. As a simple explanation, each interface enslaved into a instance is bridged to the other interfaces of the instance. </DD ><DD ><P >The corresponding command to tale a interface out of the bridge would be <B CLASS="COMMAND" >brctl delif <TT CLASS="USERINPUT" ><B >bridgename</B ></TT > <TT CLASS="USERINPUT" ><B >device</B ></TT ></B > </P ></DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SHOW" ><IMG SRC="../images/callouts/5.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(5)"></A ></DT ><DD >The <B CLASS="COMMAND" >brctl show</B > command gives you a summary about the overall bridge status, and the instances running as shown in <A HREF="set-up-the-bridge.html#BRCTL-SHOW-OUTPUT" >Example 7</A >. If you are interested in detailed information about a instance and it's interfaces you will have to check <A HREF="set-up-the-bridge.html#BRCTL-SHOWBR" ><A HREF="set-up-the-bridge.html#BRCTL-SHOWBR" ><IMG SRC="../images/callouts/6.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(6)"></A ></A >. </DD ><DIV CLASS="EXAMPLE" ><A NAME="BRCTL-SHOW-OUTPUT" ></A ><P ><B >Example 7. Output Of <B CLASS="COMMAND" >brctl show</B ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl show bridge name bridge id stp enabled mybridge1 0000.0800062815f6 yes </PRE ></TD ></TR ></TABLE ></DIV ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SHOWBR" ><IMG SRC="../images/callouts/6.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(6)"></A ></DT ><DD >The <B CLASS="COMMAND" >brctl showbr <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B > command gives you a summary about a bridge instance and it's enslaved interfaces. </DD ><DIV CLASS="EXAMPLE" ><A NAME="BRCTL-SHOWBR-OUTPUT" ></A ><P ><B >Example 8. Output Of <B CLASS="COMMAND" >brctl showbr <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl showbr mybridge1 mybridge1 bridge id 0000.0800062815f6 designated root 0000.0800062815f6 root port 0 path cost 0 max age 4.00 bridge max age 4.00 hello time 1.00 bridge hello time 1.00 forward delay 4.00 bridge forward delay 4.00 ageing time 300.00 gc interval 4.00 hello timer 0.84 tcn timer 0.00 topology change timer 0.00 gc timer 1.84 flags eth0 (1) port id 8001 state forwarding designated root 0000.0800062815f6 path cost 100 designated bridge 0000.0800062815f6 message age timer 0.00 designated port 8001 forward delay timer 0.00 designated cost 0 hold timer 0.84 flags eth1 (2) port id 8002 state forwarding designated root 0000.0800062815f6 path cost 100 designated bridge 0000.0800062815f6 message age timer 0.00 designated port 8002 forward delay timer 0.00 designated cost 0 hold timer 0.84 flags </PRE ></TD ></TR ></TABLE ></DIV ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SHOWMACS" ><IMG SRC="../images/callouts/7.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(7)"></A ></DT ><DD >The <B CLASS="COMMAND" >brctl showmacs <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B > command gives you a list of <SPAN CLASS="ACRONYM" >MAC</SPAN >-addresses of the interfaces which are enslaved in <TT CLASS="USERINPUT" ><B >bridgename</B ></TT >. </DD ><DIV CLASS="EXAMPLE" ><A NAME="BRCTL-SHOWMACS-OUTPUT" ></A ><P ><B >Example 9. Output Of <B CLASS="COMMAND" >brctl showmacs <TT CLASS="USERINPUT" ><B >bridgename</B ></TT ></B ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl showmacs mybridge1 port no mac addr is local? ageing timer 1 00:10:4b:b6:c6:e4 no 119.25 1 00:50:04:43:82:85 no 0.00 1 00:50:da:45:45:b1 no 76.75 1 00:a0:24:d0:4c:d6 yes 0.00 1 00:a0:24:f0:22:71 no 5.81 1 08:00:09:b5:dc:41 no 22.22 1 08:00:09:fb:39:a1 no 27.24 1 08:00:09:fc:92:2c no 53.13 4 08:00:09:fc:d2:11 yes 0.00 1 08:00:09:fd:23:88 no 230.42 1 08:00:09:fe:0d:6f no 144.55 </PRE ></TD ></TR ></TABLE ></DIV ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETAGEING" ><IMG SRC="../images/callouts/8.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(8)"></A ></DT ><DD >Sets the aging time. The aging time is the number of seconds a <SPAN CLASS="ACRONYM" >MAC</SPAN >-address will be kept in the forwarding database after having received a packet from this <SPAN CLASS="ACRONYM" >MAC</SPAN > address. The entries in the forwarding database are periodically timed out to ensure they won't stay around forever. Normally there should be no need to modify this parameter. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETBRIDGEPRIO" ><IMG SRC="../images/callouts/9.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(9)"></A ></DT ><DD >Sets the bridge's relative priority. The bridge with the lowest priority will be elected as the root bridge. The root bridge is the <SPAN CLASS="QUOTE" >"central"</SPAN > bridge in the spanning tree. More information about <SPAN CLASS="ACRONYM" >STP</SPAN > you find at <A HREF="advanced-bridge.html#STP" >Section 7.1</A >. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETFD" ><IMG SRC="../images/callouts/10.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(10)"></A ></DT ><DD >Sets the forwarding delay time. The forwarding delay time is the time spent in each of the Listening and Learning states before the Forwarding state is entered. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETGCINT" ><B >(11)</B ></A ></DT ><DD >Sets the garbage collection interval. Every (this number) seconds, the entire forwarding database is checked for timed-out entries. The timed-out entries are removed. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETHELLO" ><B >(12)</B ></A ></DT ><DD >Sets the hello time. Every (this number) seconds, a hello packet is sent out by the Root Bridge and the Designated Bridges. Hello packets are used to communicate information about the topology throughout the entire Bridged Local Area Network. More information about <SPAN CLASS="ACRONYM" >STP</SPAN > you find at <A HREF="advanced-bridge.html#STP" >Section 7.1</A >. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETMAXAGE" ><B >(13)</B ></A ></DT ><DD >Sets the maximum message age. If the last seen (received) hello packet is more than this number of seconds old, the bridge in question will start the takeover procedure in attempt to become the Root Bridge itself. More information about <SPAN CLASS="ACRONYM" >STP</SPAN > you find at <A HREF="advanced-bridge.html#STP" >Section 7.1</A >. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETPATHCOST" ><B >(14)</B ></A ></DT ><DD >Sets the cost of receiving (or sending, I'm not sure) a packet on this interface. Faster interfaces should have lower path costs. These values are used in the computation of the minimal spanning tree. More information about <SPAN CLASS="ACRONYM" >STP</SPAN > you find at <A HREF="advanced-bridge.html#STP" >Section 7.1</A >. Paths with lower costs are likelier to be used in the spanning tree than high-cost paths (As an example, think of a gigabit line with a 100Mbit or 10Mbit line as a backup line. You don't want the 10/100Mbit line to become the primary line there.) </DD ><DD ><P > The Linux implementation currently sets the path cost of all eth* interfaces to 100, the nominal cost for a 10Mbit connection. There is unfortunately no easy way to discern 10Mbit from 100Mbit from 1Gbit Ethernet cards, so the bridge cannot use the real interface speed. </P ></DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-STP" ><B >(16)</B ></A ></DT ><DD >With this parameter you can enable or disable the Spanning Tree Protocol. </DD ><DT ><A HREF="set-up-the-bridge.html#BRCTL-SETBRIDGEPRIO" ><IMG SRC="../images/callouts/9.gif" HSPACE="0" VSPACE="0" BORDER="0" ALT="(9)"></A ><A HREF="set-up-the-bridge.html#BRCTL-SETHELLO" ><B >(12)</B ></A ><A HREF="set-up-the-bridge.html#BRCTL-SETPATHCOST" ><B >(14)</B ></A ><A HREF="set-up-the-bridge.html#BRCTL-STP" ><B >(16)</B ></A ></DT ><DD >This parameters are only of interest, if you have more than one bridge in your LAN and stp enabled. Before modifying them you should read <A HREF="advanced-bridge.html#STP" >Section 7.1</A >. </DD ></DL ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="BASIC-SETUP" >6.2. Basic Setup</A ></H2 ><P >The standard configuration should consist of: </P ><P ></P ><OL COMPACT="COMPACT" TYPE="1" ><LI ><P >Create the bridge interface. <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl addbr mybridge </PRE ></TD ></TR ></TABLE > </P ></LI ><LI ><P >Add interfaces to the bridge. <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # brctl addif mybridge eth0 root@mbb-1:~ # brctl addif mybridge eth1 </PRE ></TD ></TR ></TABLE > </P ></LI ><LI ><P >Zero IP the interfaces. <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # ifconfig eth0 0.0.0.0 root@mbb-1:~ # ifconfig eth1 0.0.0.0 </PRE ></TD ></TR ></TABLE > </P ></LI ><LI ><P >Put up the bridge. <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # ifconfig mybridge up </PRE ></TD ></TR ></TABLE > </P ></LI ><LI ><P >Optionally you can configure the virtual interface <TT CLASS="USERINPUT" ><B >mybridge</B ></TT > to take part in your network. It behaves like one interface (like a normal network card). Exactly that way you configure it, replacing the previous command with something like: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="90%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # ifconfig mybridge 192.168.100.5 netmask 255.255.255.0 up </PRE ></TD ></TR ></TABLE > </P ></LI ></OL ><P >A more sophisticated setup script you will find at <A HREF="practical-example.html#BRIDGE-INIT-SCRIPT" >Example 16</A >. </P ><DIV CLASS="IMPORTANT" ><BLOCKQUOTE CLASS="IMPORTANT" ><P ><B >Important: </B >If you get the terrible experience of a frozen system or some nasty behavior of your nicely shaped linux box at <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # ifconfig eth<TT CLASS="USERINPUT" ><B >n</B ></TT > 0 0.0.0.0 </PRE ></TD ></TR ></TABLE > please try (after the reboot of the system if necessary) before starting any bridge stuff at all a <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" >root@mbb-1:~ # ifconfig eth<TT CLASS="USERINPUT" ><B >n</B ></TT > promisc up </PRE ></TD ></TR ></TABLE > If again your system is frozen it's you NIC's driver you have to blame, not the bridging code. </P ></BLOCKQUOTE ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="preparing-the-bridge.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="advanced-bridge.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Preparing The Bridge</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" > </TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Advanced Bridge Features</TD ></TR ></TABLE ></DIV ></BODY ></HTML >