Cook Book

 

Configure your linux box as a switch:

Step zero: You need to plug more than one NIC cards. You can configure your linux box as switch with only one NIC card. But it doesn't make sense for your switch with one port.

Step one: You need to download and install bridge software:  bridge-utils-0.9.3.tar.gz

Step two: You need to recompile your kernel to include this network option: 802.1d Ethernet Bridging

Step three: Setup your bridge.

               After you install bridge-utils, you will have "brctl" application.

brctl Command Synopsis

# 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        
    showbr          <bridge>                show bridge info               
    showmacs        <bridge>                show a list of mac addrs       

    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>        {dis,en}able stp               

 

  1. Create the bridge interface.
    root@mbb-1:~ # brctl addbr mybridge
              

     

  2. Add interfaces to the bridge.
    root@mbb-1:~ # brctl addif mybridge eth0
    root@mbb-1:~ # brctl addif mybridge eth1
              

     

  3. Zero IP the interfaces.
    root@mbb-1:~ # ifconfig eth0 0.0.0.0
    root@mbb-1:~ # ifconfig eth1 0.0.0.0
              

     

  4. Put up the bridge.
    root@mbb-1:~ # ifconfig mybridge up
              
  1. Optionally you can configure the virtual interface mybridge 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:
    root@mbb-1:~ # ifconfig mybridge 192.168.100.5 netmask 255.255.255.0 up