Comparison of BRCTL and BRIDGE commands

Comparison of BRCTL and BRIDGE commands


Linux is a very powerful operating system. Besides using it as an OS on your home computer, Linux can also be used as an OS on routers, perform network address translation (NAT) or it can be used for network bridging. When Linux is used for network bridging couple of tools can be used to configure bridge, such as brctl or bridge. Both tools are used for bridge administration. Brctl is a part of bridge-utils while bridge tool is part of iproute2. Iproute2 package is currently maintained by Stephen Hemminger who has also contributed to bridge-utils package. So, whats the difference and which command to use? In this post, options of these tools will be compared. At the end of the post, comparison table of bridge and brctl tool capabilities is given.

BRCTL

Brctl replaces older brcfg tool which has only modest capabilities to configure bridge. As said, it is part of bridge-utils package and its capabilities encompass creation, deletion and configuration of multiple bridges on one computer.

One of primary brctl operations certainly is creation and deletion of bridge. When bridge is created there are no interfaces (ports) assigned to it, so basically it does nothing. Adding ports to bridge can be also done with brctl, it can create and delete interfaces on bridge.

Every switch has its FDB (Forwarding Database) which is used to forward traffic to a known device. Switch either knows to which port it needs to forward traffic based on destination MAC address or it doesnt. When switch doesnt know where to forward traffic it simply sends traffic to all ports and listens for reply. Based on reply it can update FDB with new entry. Configuration of FDB entries ageing time and garbage collector interval as well as listing of all MACs in FDB can be done with brctl.

When connecting multiple bridges in ethernet network, there can be loop in topology which will cause broadcast radiation. When using STP, those loops are removed. Switching STP on or off and configuration of some STP parameters is provided by brctl.

BRIDGE

Bridge command is part of iproute2 package. More on current development of iproute2 (and bridge command) can be found on official mailing list.

Basically, bridge command can do three types of configuration/management tasks:
  • port configuration,
  • FDB managment,
  • virtual LAN (VLAN) configuration.
Bridge command provides more options on configuring port parameters and their STP states. Some of which can also be set with brctl command. Management of forwarding database can be done with bridge command and it provides operations like adding, appending, deleting and showing FDB. Also VLANs can be created and deleted with bridge command.

Conclusion

While both commands provide bridge manipulation and management, they are pretty complementary. Brctl can create and delete bridges while providing configuration of some STP parameters and FDB control. Bridge command on the other hand operates on port level and all options regarding STP configuration is focused only on ports. VLAN manipulation can only be done with bridge command and it also provides better FDB maintenance. Both commands should be used for fine grain management of network bridge. It is worth noting there is ip command which can also create bridges. Source codes for bridge-utils and iproute2 packages are available online.

BRIDGE MANAGEMENT
ACTION
BRCTL
BRIDGE
creating bridgebrctl addbr <bridge>
deleting bridgebrctl delbr <bridge>
add interface (port) to bridgebrctl addif <bridge> <ifname>
delete interface (port) on bridgebrctl delbr <bridge>

FDB MANAGEMENT
ACTION
BRCTL
BRIDGE
Shows a list of MACs in FDBbrctl showmacs <bridge>bridge fdb show
Sets FDB entries ageing time brctl setageingtime  <bridge> <time>
Sets FDB garbage collector intervalbrctl setgcint <brname> <time>
Adds FDB entry
bridge fdb add dev <interface> [dst, vni, port, via]
Appends FDB entry
bridge fdb append 
(parameters same as for fdb add)
Deletes FDB entry
bridge fdb delete
(parameters same as for fdb add)

STP MANAGEMENT
ACTION
BRCTL
BRIDGE
Turning STP on/offbrctl stp <bridge> <state>
Setting bridge prioritybrctl setbridgeprio <bridge> <priority>
Setting bridge forward delaybrctl setfd <bridge> <time>
Setting bridge hello timebrctl sethello <bridge> <time>
Setting bridge maximum message agebrctl setmaxage <bridge> <time>
Setting cost of the port on bridgebrctl setpathcost <bridge> <port> <cost>bridge link set dev <port> cost <cost>
Setting bridge port prioritybrctl setportprio <bridge> <port> <priority>bridge link set dev <port> priority <priority>
Should port proccess STP BDPUs
bridge link set dev <port > guard [on, off]
Should bridge might send traffic on the port it was received
bridge link set dev <port> hairpin [on,off]
Enabling/disabling fastleave options on port
bridge link set dev <port> fastleave [on,off]
Setting STP port state
bridge link set dev <port> state <state>            

VLAN MANAGEMENT
ACTION
BRCTL
BRIDGE
Creating new VLAN filter entry
bridge vlan add dev <dev> [vid, pvid, untagged, self, master]
Delete VLAN filter entry
bridge vlan delete dev <dev>
(parameters same as for vlan add)
List VLAN configuration
bridge vlan show     



download file now