3 Ways to Create a Network Bridge in RHEL/CentOS 8

A network bridge is a data-link layer device that interconnects two or more network segments, offering communication between them. It creates a single network interface to set up a single aggregate network from multiple networks or network segments. It forwards traffic based on the MAC addresses of hosts (stored in a MAC address table).

Linux operating systems such as RHEL (Red Hat Enterprise Linux) and CentOS 8 support the implementation of a software-based network bridge to emulate a hardware bridge. The bridge serves a similar function as a network switch; it acts more or less like a virtual network switch.

There are several use cases of network bridging, one practical application is in a virtualization environment to create a virtual network switch used to connect virtual machines (VMs) to the same network as the host.

This guide shows multiple ways to set up a network bridge in RHEL/CentOS 8 and use it to set up virtual networking in a bridged mode under Oracle VirtualBox and KVM, to connect Virtual Machines to the same network as the host.

Setting Up a Network Bridge Using nmcli Tool

nmcli is a widely-used, scriptable and powerful command-line tool to control NetworkManager and report network status. It communicates directly to NetworkManager and controls only system-wide connections. Importantly, it allows users to use abbreviations, as long as they are a unique prefix in the set of possible options.

First, use the IP command to identify the network interfaces (both physical and virtual) currently attached to your machine and the networks they are connected to.

# ip add

From the output of the above command, the Ethernet interface is called enp2s0, we will add this interface to the bridge as a slave.

Check Network Interfaces
Check Network Interfaces

Next, to list the active network connections on the test system, use the following nmcli command.

# nmcli conn show --active
List Active Network Connections
List Active Network Connections

Important: If the libvirtd daemon (libvirtd) is installed and started, the default network interface that represents the network bridge (virtual network switch) is virbr0 as seen in the above screenshots. It is configured to run in NAT mode.

Next, create a network bridge interface using the following nmcli command, where conn or con stands for connection, and the connection name is br0 and the interface name is also br0.

# nmcli conn add type bridge con-name br0 ifname br0
Create Network Bridge Interface
Create Network Bridge Interface

Note: In a bridged mode, the virtual machines are easily accessible to the physical network, they appear within the same subnet as the host machine and they can access services such as DHCP.

To set a static IP address, run the following commands to set IPv4 address, network mask, default gateway, and DNS server of the br0 connection (set the values according to your environment).

# nmcli conn modify br0 ipv4.addresses '192.168.1.1/24'
# nmcli conn modify br0 ipv4.gateway '192.168.1.1'
# nmcli conn modify br0 ipv4.dns '192.168.1.1'
# nmcli conn modify br0 ipv4.method manual

Now add the Ethernet interface (enp2s0) as a portable device to the bridge (br0) connection as shown.

# nmcli conn add type ethernet slave-type bridge con-name bridge-br0 ifname enp2s0 master br0
Add Ethernet Interface as a Slave to Bridge
Add Ethernet Interface as a Slave to Bridge

Next, bring up or activate the bridge connection, you can use the connection name or UUID as shown.

# nmcli conn up br0
OR
# nmcli conn up 2f03943b-6fb5-44b1-b714-a755660bf6eb
Active Network Bridge Connection
Active Network Bridge Connection

Then deactivate or bring down the Ethernet or Wired connection.

# nmcli conn down Wired\ connection\ 1
OR
# nmcli conn down e1ffb0e0-8ebc-49d0-a690-2117ca5e2f42
De-active Network Wired Connection
De-active Network Wired Connection

Now when you try to list the active network connections on the system, the bridge connection should display on the list.

# nmcli conn show  --active
List Active Network Connection
List Active Network Connection

Next, use the following bridge command to display the current bridge port configuration and flags.

# bridge link show
Show Bridge Ports
Show Bridge Ports

To deactivate the bridge connection and delete it, run the following commands. Note that you first of all have to activate the wired connection.

# nmcli conn up Wired\ connection\ 1
# nmcli conn down br0
# nmcli conn del br0
# nmcli conn del bridge-br0
Delete Bridge Network Connection
Delete Bridge Network Connection

For more information, see the nmcli manual page.

# man nmcli

Creating a Network Bridge via Cockpit Web Console

The cockpit is a lightweight, interactive and easy-to-use web-based server administration interface. To interact with the system’s network configuration, the cockpit uses NetworkManager and the DBus APIs it provides.

To add a bridge, go to Networking, then click Add Bridge as highlighted in the following image.

Choose Networking in Cockpit Web Console
Choose Networking in Cockpit Web Console

A pop window with options to add a new bridge will appear. Set the bridge name and select the ports as shown in the following screenshot. You can optionally enable STP (Spanning Tree Protocol) and then click Apply.

Add Network Bridge Settings
Add Network Bridge Settings

Under the list of Interfaces, the new bridge should now appear and the Ethernet interface should be de-activated.

New Network Bridge Interface
New Network Bridge Interface

To view the bridge in detail, double click on it. There are options to take it down or delete, add a new port device to it and more.

View Network Bridge Details
View Network Bridge Details

Creating a Network Bridge Using nm-connection-editor Application

nm-connection-editor is a graphical network connection editor for NetworkManager, used to add, remove, and modify network connections stored by NetworkManager. Any modifications can only work if NetworkManager is running.

To launch it, run the nm-connection-editor command as root in the command line or open it from the system menu.

# nm-connection-editor

Once it opens up, click the plus sign to add a new connection as highlighted in the following screenshot.

Add a New Network Connection
Add a New Network Connection

From the pop window, choose the connection type from the drop-down, Bridge in this case and click Create.

Choose Network Connection Type
Choose Network Connection Type

Next, set a bridge connection and interface name, then click Add to add a bridge port. Choose Ethernet as the connection type. Then click Create.

Create a Bridge Connection
Create a Bridge Connection
Choose Ethernet as Connection Type
Choose Ethernet as Connection Type

Next, edit the port device connection details and click Save.

Edit Network Bridge Port
Edit Network Bridge Port

Now the bridged port should be added to the list of bridged connections. Then click Save.

Network Bridge Port Added
Network Bridge Port Added

From the connection editor’s main interface, you should be able to see the new bridged connection and bridge interface as shown in the following screenshot.

Network Bridge Created Successfully
Network Bridge Created Successfully

Now go ahead to activate the bridge connection and deactivate the wired connection from the command line using the nmcli tool as shown before.

# nmcli conn up br0
# nmcli conn down Wired\ connection\ 1

How to Use the Network Bridge in a Virtualization Software

In this section, we will show how to use a bridge to connect virtual machines to the host network, under Oracle VirtualBox and KVM as explained below.

Using a Network Bridge in Oracle VirtualBox

To configure a virtual machine to use a bridged adapter, select it from the list of VMs, then go to its settings, click Network option and select the adapter (e.g Adapter 1), then make sure the Enable Network Adapter option is checked, set the attached to as Bridged Adapter, then select the name of the bridged interface (br0) and click Ok.

Configure VM to Use Bridge Network in VirtualBox
Configure VM to Use Bridge Network in VirtualBox

Using a Network Bridge in KVM

To use the network bridge created above under KVM, use the --network=bridge=br0 option while virtual machines using the command-line interface, using the virt-install command.

# virt-install --virt-type=kvm --name Ubuntu18.04 --ram 1536 --vcpus=4 --os-variant=ubuntu18.04 --cdrom=/path/to/install.iso --network=bridge=br0,model=virtio --graphics vnc --disk path=/var/lib/libvirt/images/ubuntu18.04.qcow2,size=20,bus=virtio,format=qcow2

You can as well create additional networks and configure them using the virsh command-line tool, and a VM’s XML configuration file can be edited to use one of these new bridged networks.

In this guide, we have shown how to set up a network bridge in RHEL/CentOS 8 and use it within to connect VMs to the same network of the host, under Oracle VirtualBox and KVM.

As usual, reach us via the feedback form below for any questions or comments. You can find more details in understanding virtual networking and configuring a network bridge in RHEL 8 documentation.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

2 thoughts on “3 Ways to Create a Network Bridge in RHEL/CentOS 8”

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.