OSETC TECH

Linux: Add Network Bridge with Nmcli Tool

This post will guide you how to add a new network bridge with nmcli network Manager tool under the Linux operating system. How do I create a network bridge using the nmcli tool in Ubuntu/Debian Linux system.

You can use the network bridge to balance the traffic between the networks by using mac address and create a mac address table and to decide from which network package should be transmitted so that to balance the network traffic.

Linux Add Network Bridge with Nmcli Tool


If you want to create or add a network bridge under Ubuntu/debian Linux system, you can use the nmcli tool to achieve the result. Just do the following steps:

#1 run the following command to get information about the current network connectin. Type:

#nmcli con show

Outputs:

root@ubuntu-dev:/home/devops# nmcli con show

NAME                UUID                                  TYPE            DEVICE

Wired connection 1  dd6b5c99-0569-3310-b04a-2584d49a1a88  802-3-ethernet  enp0s3

root@ubuntu-dev:/home/devops#

#2 create a new bridge with nmcli command, type:

#nmcli con add type bridge ifname br0

Outputs:

root@ubuntu-dev:/home/devops# nmcli con add type bridge ifname br0

Connection 'bridge-br0' (8730c653-aa6d-4716-b83b-f1bb9036c992) successfully added.

#3 create a slave interface to your newly created bridge-br0. Type:

#nmcli con add type bridge-slave ifname enp0s3 master br0

#4 you need to turn on the newly created bridge br0, type:

#nmcli con up br0

#5 check all the connections

Type the following command:

#nmcli con show

Outputs:

root@ubuntu-dev:/home/devops# nmcli con show

NAME                UUID                                  TYPE            DEVICE

Wired connection 1  dd6b5c99-0569-3310-b04a-2584d49a1a88  802-3-ethernet  enp0s3

bridge-br0          8730c653-aa6d-4716-b83b-f1bb9036c992  bridge          br0

From the above outputs, you will see that the network bridge br0 has been created.

Delete a Network Connection using nmcli Command


You can use the nmcli tool to delete a network connection, for example, to delete bridge-br0, just type the following command:

#nmcli con delete bridge-br0

Outputs:

root@ubuntu-dev:/home/devops# nmcli con delete bridge-br0

Connection 'bridge-br0' (8730c653-aa6d-4716-b83b-f1bb9036c992) successfully deleted.

root@ubuntu-dev:/home/devops# nmcli con show

NAME                UUID                                  TYPE            DEVICE

Wired connection 1  dd6b5c99-0569-3310-b04a-2584d49a1a88  802-3-ethernet  enp0s3

root@ubuntu-dev:/home/devops#

See Also: https://linux.die.net/man/1/nmcli