Lab 5-2: Linux Bridging and the Spanning Tree

The Linux bridge administration is done via the brctl tool. Consult the man page for details and look at the Linux Bridge-STP-HOWTO (http/www.tldp.org/HOWTO/BRIDGE-STP-HOWTO/index.html) and http://bridge.sourceforge.net.

The following setup (Example 5-19) bridges between the two interfaces eth0 and eth1 of the callisto Linux gateway (setup and removal). Example 5-20 provides interface status information of the bridge setup, and Example 5-21 shows a more detailed experience with the brctl tool. Finally, Example 5-22 presents a short sniffer session to capture STP packets.

Example 5-19. Linux Bridge Configuration

[root@callisto:~#] brctl addbr mybridge

[root@callisto:~#] brctl addif mybridge eth0

[root@callisto:~#] brctl addif mybridge eth1

[root@callisto:~#] ifconfig mybridge up



[root@callisto:~#] ifconfig mybridge down

[root@callisto:~#] brctl delbr mybridge


Example 5-20. Linux Bridge Configuration Interface Status

[root@callisto:~#] ifconfig

eth0      Link encap:Ethernet  HWaddr 00:10:5A:D7:93:60

          inet addr:192.168.14.1  Bcast:192.168.14.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:100

          RX bytes:0 (0.0 b)  TX bytes:360 (360.0 b)

          Interrupt:5 Base address:0xd800



eth1      Link encap:Ethernet  HWaddr 52:54:05:E3:51:87

          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:58 errors:0 dropped:0 overruns:0 frame:0

          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:100

          RX bytes:4325 (4.2 Kb)  TX bytes:3625 (3.5 Kb)

          Interrupt:9 Base address:0xd400



mybridge  Link encap:Ethernet  HWaddr 00:10:5A:D7:93:60

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


Example 5-21. Linux brctl Tool

[root@callisto:~#] brctl

commands:

        addbr           <bridge>                add bridge

        addif           <bridge> <device>       add interface to bridge

        delbr           <bridge>                delete bridge

        delif           <bridge> <device>       delete interface from bridge

        show                                    show a list of bridges

        showmacs        <bridge>                show a list of mac addrs

        showstp         <bridge>                show bridge stp info

        setageing       <bridge> <time>         set ageing time

        setbridgeprio   <bridge> <prio>         set bridge priority

        setfd           <bridge> <time>         set bridge forward delay

        setgcint        <bridge> <time>         set garbage collection interval

        sethello        <bridge> <time>         set hello time

        setmaxage       <bridge> <time>         set max message age

        setpathcost     <bridge> <port> <cost>  set path cost

        setportprio     <bridge> <port> <prio>  set port priority

        stp             <bridge> <state>        turn stp on/off



[root@callisto:~#] brctl show

bridge name     bridge id               STP enabled     interfaces

mybridge                8000.00105ad79360       yes     eth0

                                                        eth1

[root@callisto:~#] brctl showmacs mybridge

port no mac addr                is local?       ageing timer

  1     00:06:52:58:5d:44       no                 0.93

  1     00:10:5a:d7:93:60       yes                0.00

  2     48:54:e8:8c:0a:3f       no                 9.62

  2     52:54:05:e3:51:87       yes                0.00

  1     52:54:05:e3:e4:88       no                 9.62



[root@callisto:~#] brctl showstp mybridge

mybridge

 bridge id              8000.00105ad79360

 designated root        8000.000652585d40

 root port                 1                    path cost                   100

 max age                  20.00                 bridge max age            20.00

 hello time                2.00                 bridge hello time          2.00

 forward delay            15.00                 bridge forward delay      15.00

 ageing time             300.00                 gc interval                4.00

 hello timer               0.00                 tcn timer                  0.00

 topology change timer     0.00                 gc timer                   3.24

 flags                  TOPOLOGY_CHANGE



eth0 (1)

 port id                8001                    state                   forwarding

 designated root        8000.000652585d40       path cost                   100

 designated bridge      8000.000652585d40       message age timer          1.20

 designated port        800a                    forward delay timer        0.00

 designated cost           0                    hold timer                 0.00

 flags



eth1 (2)

 port id                8002                    state                   forwarding

 designated root        8000.000652585d40       path cost                   100

 designated bridge      8000.00105ad79360       message age timer          0.00

 designated port        8002                    forward delay timer        0.00

 designated cost         100                    hold timer                 0.00

 flags


Example 5-22. STP Operation on a Linux Bridge

[root@callisto:~#] tethereal -i eth1

Capturing on eth1

  8.001048     callisto -> 01:80:c2:00:00:00 STP Conf. Root =

32768/00:06:52:58:5d:40  Cost = 100  Port = 0x8002