How to add network bridge with nmcli (NetworkManager) on Linux

To add a network bridge using the nmcli command-line tool with the NetworkManager service in Linux, follow these steps:

  1. Install the NetworkManager command line tool:
sudo yum install NetworkManager-cli

or

sudo apt-get install NetworkManager-cli
  1. Create a bridge interface:
sudo nmcli connection add type bridge ifname <bridge_interface_name> con-name <connection_name>

Replace <bridge_interface_name> with a unique name for the bridge interface and <connection_name> with a name for the connection.

  1. Connect the bridge interface to physical interfaces:
sudo nmcli connection add type bridge-slave ifname <physical_interface_name> master <bridge_interface_name>

Replace <physical_interface_name> with the name of the physical interface you want to add to the bridge and <bridge_interface_name> with the name of the bridge interface created in step 2. Repeat this command for each physical interface you want to add.

  1. Activate the bridge interface:
sudo nmcli connection up <connection_name>

Replace <connection_name> with the name of the connection you specified in step 2.

  1. Verify the network bridge configuration:
sudo nmcli connection show

This will display information about all network connections, including the bridge interface and its connected physical interfaces.

Leave a Comment