CentOS

How to create a Network Bridge in CentOS8

A network bridge is a link layer device that enables the communication between two different networks and facilitates their working as a single network. The Network bridge creates a MAC address database by listening to network traffic and concluding which hosts are linked to each network. This table of MAC addresses is then used to forward traffic between networks.

CentOS 8 establishes network connections between devices by realizing an imitation of the hardware bridge in a software-controlled network bridge. This network bridge is a virtual entity, and any device, physical or virtual, can be connected to this link.

Each network to which the bridge should connect requires a network device. Upon configuration, the bridge is referred to as a controller, and the devices it connects are referred to as ports. You can create network bridges with a variety of devices, including:

  • VLAN devices
  • Physical and virtual Ethernet devices
  • Network teams
  • Network bonds

However, a bridge cannot be configured via Wi-Fi networks in Ad-Hoc or Infrastructure modes. Now we will explain the way to create a network bridge in CentOS 8.

How to Create a Network Bridge in CentOS 8

We can create a network bridge in CentOS 8 following two methods:

  • Using nmcli command
  • Using nm-connection-editor

Using nmcli command

Before you begin, make certain that:

  • There are two to four network devices on a server.
  • On the server, physical or virtual Ethernet devices are installed to serve as bridge ports.
  • To use VLAN devices as bridge ports, they must be created ahead of time or when the bridge is being built.

STEP 1

Create a bridge interface through this command:

# nmcli connection add type bridge con-name bridge0 ifname bridge0

STEP 2

Note the names of all the interfaces to be added to the bridge from the list of all network interfaces displayed by the following command

# nmcli device status

To use the devices with existing connection profiles as ports, modify their profiles in the next step. If the device to be used as a port is not configured, add connection profiles.

STEP 3

Set the bridge’s master parameter to bridge0 if you wish to apply an existing connection profile to the bridge.

# nmcli connection modify bond0 master bridge0

Create new profiles for the un-configured ports and add them to bridge 0 connection

# nmcli connection add type ethernet slave-type bridge con-name bridge0-port1 ifname enp7s0 master bridge0

STEP 4

Set the bridge’s IP address. If you wish to utilize this bridge to connect other devices, skip this step. Configure the IPv4 settings as follows:

# nmcli connection modify bridge0 ipv4.addresses '192.0.2.1/24'

# nmcli connection modify bridge0 ipv4.gateway '192.0.2.254'

# nmcli connection modify bridge0 ipv4.dns '192.0.2.253'

# nmcli connection modify bridge0 ipv4.dns-search 'example.com'

# nmcli connection modify bridge0 ipv4.method manual

Configure the IPv6 settings as follows:

# nmcli connection modify bridge0 ipv6.addresses '2001:db8:1::1/64'

# nmcli connection modify bridge0 ipv6.gateway '2001:db8:1::fffe'

# nmcli connection modify bridge0 ipv6.dns '2001:db8:1::fffd'

# nmcli connection modify bridge0 ipv6.dns-search 'example.com'

# nmcli connection modify bridge0 ipv6.method manual

Further properties like the STP of the bridge can also be configured. However, because the primary aim of Spanning Tree Protocol (STP) is to prevent forming loops in your network when you have redundant paths, doing so is optional. As shown below, we can disable or enable STP:

# nmcli connection modify bridge0 bridge.priority '16384’

STEP 5

Activate the connection

# nmcli connection up bridge0

STEP 6

Check the status of the ports using the following command:

# nmcli device

How to Create device Type State Connection

Only new ports can be added to a bridge using nm-connection-editor. Before starting, make sure that:

  • Two or more network devices exist on the server.
  • On the server, physical or virtual Ethernet devices are installed to serve as bridge ports.
  • Be sure they aren’t already set up to use team, bond, or VLAN devices as bridge ports.

STEP 1

Open a terminal, and enter nm-connection-editor:

$ nm-connection-editor

STEP 2

Click the plus (+) button to create a new connection.

STEP 3

Create a Bridge connection by selecting the appropriate type.

STEP 4

In the Bridge tab:

  1. The interface name should be entered in the Interface name field.
  2. You need to add a new profile as a port to the bridge by clicking the Add button for the new connection profile.
  • Choose an appropriate type of connection.
  • The device’s connection name is set here.
  • Select the connection type in the tab. To add a network port, select the network interface.
  • Once you have saved, click OK.

STEP 5

Repeat the above steps until each interface is added to the bridge.

STEP 6

Save the bridge connection.

STEP 7

Close nm-connection-editor.

Conclusion

So, it was brief on the method to create a network bridge on CentOS 8. To help you better understand, we have divided the method into steps. Please get in touch with us if you would like more information on different technologies.

About the author

Ankit Sharma