Jan 5, 2017

Part 2. Linux bridge (Virtual bridge)

Leave a Comment

Before

ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:7a:94:3d 
          inet addr:192.168.0.36  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7a:943d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:288 errors:0 dropped:0 overruns:0 frame:0
          TX packets:273 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:61152 (61.1 KB)  TX bytes:35117 (35.1 KB)
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 B)  TX bytes:240 (240.0 B)
 
vdkmai@Ubuntu32bit:~$ brctl
The program 'brctl' is currently not installed. You can install it by typing:
sudo apt-get install bridge-utils

Setup

sudo apt-get install bridge-utils

Usage

Usage: brctl [commands]
commands:
        addbr                           add bridge
        delbr                           delete bridge
        addif                   add interface to bridge
        delif                   delete interface from bridge
        hairpin           {on|off}        turn hairpin on/off
        setageing        
Usage: brctl [commands]
commands:
        addbr           <bridge>                add bridge
        delbr           <bridge>                delete bridge
        addif           <bridge> <device>       add interface to bridge
        delif           <bridge> <device>       delete interface from bridge
        hairpin         <bridge> <port> {on|off}        turn hairpin on/off
        setageing       <bridge> <time>         set ageing time
        setbridgeprio   <bridge> <prio>         set bridge priority
        setfd           <bridge> <time>         set bridge forward delay
        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
        show            [ <bridge> ]            show a list of bridges
        showmacs        <bridge>                show a list of mac addrs
        showstp         <bridge>                show bridge stp info
        stp             <bridge> {on|off}       turn stp on/off
vdkmai@Ubuntu32bit:~$ sudo brctl addbr vCisco
vdkmai@Ubuntu32bit:~$ brctl show
bridge name bridge id STP enabled interfaces
vCisco 8000.000000000000 no
vdkmai@Ubuntu32bit:~$ sudo ip link add type veth
vdkmai@Ubuntu32bit:~$
vdkmai@Ubuntu32bit:~$
vdkmai@Ubuntu32bit:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:7a:94:3d 
          inet addr:192.168.0.36  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7a:943d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:525 errors:0 dropped:0 overruns:0 frame:0
          TX packets:388 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:82986 (82.9 KB)  TX bytes:48549 (48.5 KB)
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 B)  TX bytes:240 (240.0 B)
vdkmai@Ubuntu32bit:~$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:7a:94:3d 
          inet addr:192.168.0.36  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7a:943d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:535 errors:0 dropped:0 overruns:0 frame:0
          TX packets:393 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:83816 (83.8 KB)  TX bytes:49991 (49.9 KB)
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:240 (240.0 B)  TX bytes:240 (240.0 B)
vCisco    Link encap:Ethernet  HWaddr 8e:fb:13:53:d2:7a 
          BROADCAST 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)
veth0     Link encap:Ethernet  HWaddr 16:74:bc:b4:c4:16 
          BROADCAST 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:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
veth1     Link encap:Ethernet  HWaddr 9a:49:33:f6:6e:79 
          BROADCAST 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:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
sudo ifconfig veth0 10.0.0.10 netmask 255.255.255.0 up
sudo ifconfig veth2 10.0.0.12 netmask 255.255.255.0 up
sudo brctl addif vCisco veth1
sudo brctl addif vCisco veth3
vdkmai@Ubuntu32bit:~$ brctl show vCisco
bridge name     bridge id               STP enabled     interfaces
vCisco          8000.0ee3838584ff       no              veth1
                                                        veth3
Example to create veth interfaces with custom names: lnsgmii0 & nsgmii0. You can use any name which you want.
sudo ip link add lnsgmii0 type veth peer name nsgmii0
ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:7a:94:3d 
          inet addr:192.168.0.36  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe7a:943d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1330 errors:0 dropped:0 overruns:0 frame:0
          TX packets:612 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:116571 (116.5 KB)  TX bytes:79276 (79.2 KB)
lnsgmii0  Link encap:Ethernet  HWaddr 96:8f:8c:ca:bb:49 
          BROADCAST 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:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
nsgmii0   Link encap:Ethernet  HWaddr 9e:ed:69:fa:93:b1 
          BROADCAST 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:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment