To add a network bridge (br0) on Ubuntu 20.04 using the nmcli
command, you can use the following steps:
bridge-utils
package, which provides the brctl
utility for configuring bridge interfaces:sudo apt-get install bridge-utilsSource:www.lautturi.com
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.
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.
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.
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.