Ubuntu 20.04 add network bridge (br0) with nmcli command

Ubuntu 20.04 add network bridge (br0) with nmcli command

To add a network bridge (br0) on Ubuntu 20.04 using the nmcli command, you can use the following steps:

  1. Install the bridge-utils package, which provides the brctl utility for configuring bridge interfaces:
sudo apt-get install bridge-utils
Source‮‬:www.lautturi.com
  1. Create the bridge interface using the nmcli command. For example, to create a bridge named br0 with the IP address 192.168.1.1/24, you can use the following command:
nmcli connection add type bridge con-name br0 ifname br0 ip4 192.168.1.1/24

This will create a new connection named br0 of type bridge with the specified IP address.

  1. Add the interface you want to bridge to the bridge using the nmcli command. For example, to add the interface eth0 to the br0 bridge, you can use the following command:
nmcli connection add type bridge-slave con-name br0-slave ifname eth0 master br0

This will create a new connection named br0-slave of type bridge-slave and add it to the br0 bridge as a slave interface.

  1. Activate the bridge and the slave interface using the nmcli command. For example, to activate the br0 bridge and the eth0 slave interface, you can use the following commands:
nmcli connection up br0
nmcli connection up br0-slave

This will bring up the br0 bridge and the eth0 slave interface.

  1. (Optional) If you want to set the bridge as the default route for all traffic, you can use the ip command to change the default route. For example, to set the br0 bridge as the default route, you can use the following command:
ip route add default via 192.168.1.1 dev br0

Replace 192.168.1.1 with the IP address of the bridge.

That's it! You have now added a network bridge (br0) on Ubuntu 20.04 using the nmcli command.

Created Time:2017-10-30 14:27:24  Author:lautturi