A bridge is a device that separates two or more network segments within one logical network. A bridge is one step above the Hub (by default, a Linux bridge acts as a Switch) – it reviews the destination of the packet before sending. If the destination address is not on the other side of the bridge, the packet is dropped. Whereas a hub is the simplest of the network devices – any data packet coming from one port is sent to all other ports. It is then up to the receiving computer to decide, whether to accept the packet or not. Usually, hubs are used on small networks where the amount of data going across the network is not very high. For my experiment on Xen hypervisor, I wanted to make the Linux bridge act as a Hub instead of Switch. Here’s how I achieved the same:
How to find the list of Linux bridges created on the Host
Firstly, we need to find the list of Linux bridges created on the host and make the corresponding one as Hub. Execute the below command to find the list of Linux bridges on the host:
[root@centos-1 ~]# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.000000000000 yes xenbr0 8000.feffffffffff no vif33.0 vif31.0 vif19.0 vif0.0 peth0
How to make a bridge act as a hub?
Execute the below commands to make the bridge act as a hub. Here, seting setageing to 0, you are making bridge to forget every MAC addresses that it sees and react like a hub.
brctl stp <bridge name> off brctl setageing <bridge name> 0 brctl setfd <bridge name> 0
Example: From the above list of bridges, I would like to make xenbr0 bridge as hub.
[root@centos-1 ~]# brctl stp xenbr0 off [root@centos-1 ~]# brctl setageing xenbr0 0 [root@centos-1 ~]# brctl setfd xenbr0 0
How to verify the bridge act as Hub?
Scenario: Consider 3 VM’s running on the Linux Host. Now start pinging from VM1 to VM2. On VM3, run the tcpdump to see the ICMP packets flowing from VM1 to VM2.
How to reverse the above hub to a Linux bridge
Now to reverse the above setting on the physical host, just run the below command:
brctl setageing <bridge name> 300
[root@centos-1 ~]# brctl setageing xenbr0 300
Now to verify it again, Consider the same 3 VM’s running on the Linux Host. Now start pinging from VM1 to VM2. On VM3, run the tcpdump and you wouldn’t be able see the ICMP packets flowing from VM1 to VM2.
is a Web Designer and content creator. A freelance writer on latest trends in technology, gadget reviews, How to’s and many more.