CentOS 8 add a network bridge (br0) to the nmcli command

How can I configure CentOS 8 and add a network bridge (br0) using the nmcli command? How to create a Linux network bridge on a CentOS Linux 8 server for KVM (Kernel-based Virtual Machine)?

A network bridge is nothing more than a device that connects two LANs. It works on the link layer (layer 2 of the OSI model). Network bridges are often used with virtualization software. Network bridges are often used with virtualization software. Popular programs such as KVM, LXD or Docker can, for example, configure bridges instead of a NAT-based network. The nmcli command line tool allows you to create a permanent bridge configuration without having to modify the files. This page shows how to create the gateway interface using a Network Manager command line tool called nmcli on CentOS 8 Enterprise Linux. Learn more Linux Plesk server management.

 

CentOS 8 Add a network bridge (br0) with nmcli

The procedure for creating and adding a gateway interface in CentOS 8 is as follows if you want to use a network administrator:
Open the terminal application or log in with [nixmcd name=ssh].

  1. Discover the current network connection of CentOS 8:
    sudo nmcli con show
  2. Then add a new bridge named br0:
    sudo nmcli con.
  3. Create a slave interface for br0:
    sudo nmcli con add bridge-slave type as name eno1 master br0.
  4. Turn on the br0 interface to get the IP over DHCP:
    sudo nmcli con up br0.
  5. Static IP address settings are discussed below for the br0 interface.

Let’s take a closer look at all the examples and instructions for creating a network bridge in CentOS 8.

Look out! Look out! These instructions make critical changes to the network of your existing server, and incorrect commands can lead to the loss of the network/ssh connection to the server. It is therefore not recommended to execute these commands on ssh sessions. Next, you may need to adjust your firewall rules to match the settings of your network gateway. For remote servers I recommend using KVM over IP or IPMI based on remote sessions.

How to create a Linux network bridge on CentOS 8

First of all, discover the current interface of CentOS Linux 8 and the IP address we will need later. Therefore, type the following command:
$ nmcli con shows
$ nmcli connection shows -active
outputs :

APPARATUS PARTS UUIDE TYPE
eno1 71a189f2-9cb9-49f0-8464-37a6801740e3 ethernet eno1

So my server has an eno1 ethernet interface. I will configure the bridge interface called br0 and add the interface to eno1 (slave).

Step 1 – Create a network bridge called br0

Syntax:
$ sudo nmcli con add ifname br0 type bridge con-name br0
$ sudo nmcli con add type bridge-slave ifname eno1 master br0
$ nmcli connection show
CentOS 8 add a network bridge (br0) to the nmcli command

Step 2 – Enabling or disabling PTS for network bridge

The main purpose of the Voltage Tree Protocol (STP) is to ensure that you do not create loops if your network has redundant paths. At br0 you can deactivate or activate the PTS as follows:
$ sudo nmcli con change br0 bridge.stp no
## CentOS 8 nmcli command to STP with br0 ##
$ sudo nmcli con change br0 bridge.stp yes
## verification ##
$ nmcli con tone
$ nmcli -f bridge con tone br0
outputs :

bridge.mac address: —
bridge.stp: no
bridge.priority: 32768
bridge.forwarddelay: 15
bridge.hello-time: 2
bridge.max-age: 20 bridge.aging time
: 300 bridge.group
forward mask: 0
bridge.multicast-snooping: yes
bridge.vlan-filtration: no
bridge.vlan-default-pvid: 1 1
bridge.vlans: —

Step 3 – Setting up a Static or DHCPNetwork Bridge .

We have not assigned a static IP address to our br0 interface. For example, if a DHCP server is available, it must provide IP addresses and other parameters. On servers, however, we usually set a static IP address. In this example, I convert the existing parameters of the eno1-IP network to br0 parameters as follows

IPv4 br0Parameters

modify sudo nmcli connection br0 ipv4.addresses ‘192.168.2.19/24’
$ modify sudo nmcli connection br0 ipv4.gateway ‘192.168.2.254’
$ modify sudo nmcli connection br0 ipv4.dns ‘192.168.2.254’
$ modify sudo nmcli connection to br0 ipv4.dns-search ‘sweet.home’
$ modify sudo nmcli connection to br0 ipv4.method manually

IPv6 br0Parameters

change sudo nmcli connection bridge0 ipv6.addresses ‘Your-Static-IPv6-Address’
$ change sudo nmcli connection br0 ipv6.gateway ‘Your-Static-IPv6-Gateway-Address’
$ change sudo nmcli connection br0 ipv6.dns ‘Your-Static-IPv6-DNS’
$ change sudo nmcli connection br0 ipv6.dns-search ‘sweet.home’
$ change sudo nmcli connection br0 ipv6.method manual

Step 4 – Activate the Br0 network bridge interface on CentOS 8.

So far we have configured the required network settings. It is time to activate br0:
$ sudo nmcli con up br0
$ nmcli con show
Wait a moment to activate the parameters.

Step 5 – Check the settings of the network gateway

Use the ip command to display the IP parameters of br0:
$ ip a s
$ ip a s br0
You can remove eno1, since br0 itself has a static IP address, since eno1 will be in redirect state:
$ remove sudo nmcli connection eno1
This is what it looks like when you use the command ip
$ nmcli connection show
$ ip a show br0
$ nmcli device
## interface activates and works with br0 ##
$ ip a show eno1
$ ip r
## Check the internet connection and local network with the command ping ##
$ ping -c 4 www.cyberciti.biz
$ ping -c 4 192.168.2.25
Show the connection status of Ethernet devices and bridges on a computer running CentOS 8 Linux:
$ ip link show master br0
$ bridge link show
$ bridge link show dev eno1
CentOS 8 add a network bridge (br0) to the nmcli command

Conclusion

In this lesson you learned how to add and create a Linux network bridge on a CentoS 8 server. For more information we refer to the nmcli documents here.

RECOMMENDATIONS

Published: Vivek gears

The author is the creator of nixCraft and an experienced system administrator, DevOps engineer and Linux/Unix shell script trainer. Receive the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly by email.centos 8 network bridge,centos bridge configuration file,centos 7 network config bridge,how to configure bridge network in kvm centos 7,how to configure virbr0 in centos 7,centos 7 bridge device,centos 8 no network,centos 7 wireless bridge