How to Configure Software Bridges in CentOS/RHEL 7

This post outlines steps to configure and troubleshoot local software bridges and associated interfaces.

Software Bridges

A network bridge is a link-layer device that forwards traffic 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 configure 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 configuration files

Software bridges are managed by interface configuration files found in the /etc/sysconfig/network-scripts directory. There is an ifcfg-* configuration file for each software bridge. The following is a sample configuration file 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 definition specifies that this is a software bridge. BRIDGING_OPTS defines additional bridge options. Note that this bridge has been assigned a static IP address. The following configuration file 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 definition, 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