How to Configure Software Bridges in CentOS/RHEL 7
This post outlines steps to conﬁgure and troubleshoot local software bridges and associated interfaces.
A network bridge is a link-layer device that forwards trafﬁc between networks based on MAC addresses. It learns what hosts are connected to each network, builds a table of MAC addresses, then makes packet forwarding decisions based on that table. A software bridge can be used in a Linux environment to emulate a hardware bridge. The most common application for software bridges is in virtualization applications for sharing a hardware NIC among one or more virtual NICs.
Configure Software Bridges
The nmcli can be used to conﬁgure software bridges persistently. First, the software bridge is created, then existing interfaces are connected to it. For example, the following commands will create a bridge called br0 and attach both the eth1 and eth2 interfaces to it.
# nmcli con add type bridge con-name br0 ifname br0 # nmcli con add type bridge-slave con-name br0-port1 ifname eth1 master br0 # nmcli con add type bridge-slave con-name br0-port2 ifname eth2 master br0
Software bridge conﬁguration ﬁles
Software bridges are managed by interface conﬁguration ﬁles found in the /etc/sysconfig/network-scripts directory. There is an ifcfg-* conﬁguration ﬁle for each software bridge. The following is a sample conﬁguration ﬁle for a software bridge:
# /etc/sysconfig/network-scripts/ifcfg-br1 DEVICE=br1 NAME=br1 TYPE=Bridge BOOTPROTO=none IPADDR0=172.25.5.100 PREFIX0=24 STP=yes BRIDGING_OPTS=priority=32768
The TYPE=Bridge deﬁnition speciﬁes that this is a software bridge. BRIDGING_OPTS deﬁnes additional bridge options. Note that this bridge has been assigned a static IP address. The following conﬁguration ﬁle attaches an Ethernet interface to a software bridge:
# /etc/sysconfig/network-scripts/ifcfg-br1-port0 TYPE=Ethernet NAME=br1-port0 DEVICE=eth1 ONBOOT=yes BRIDGE=br1
The single variable deﬁnition, BRIDGE=br1, is what ties this interface to the software bridge, br1.
The brctl show command will display software bridges and the list of interfaces attached to them.
# brctl show bridge name bridge id STP enabled interfaces br1 8000.52540001050b yes eth1