Nmcli – Command-line Convenience

To configure the network on a Linux machine is an important skill.
You have already seen how to do it with systemd-networkd.

NetworkManager gives you another way to do it: nmcli.

In the previous example you created a network bridge interface.
Then you added a physical card to the bridge.

The chore is the same. The tool is different.

Create The Bridge Interface

In newer versions of NetworkManager, the terminology has changed.
In Debian 13 these are the commands to create the bridge,
then to attach a physical device to it.

sudo nmcli device status
sudo nmcli connection add type bridge con-name bridge0 ifname bridge0
sudo nmcli connection add type ethernet slave-type bridge con-name 'Bridge connection 1' ifname enp2s0 master bridge0
sudo nmcli connection modify bridge0 connection.autoconnect-slaves 1
sudo nmcli connection up bridge0
sudo nmcli device status

Add A Static IP Address

To add a static IP address to the newly created bridge device, run
the following commands.

Adjust the IP configuration to match your network.

sudo nmcli connection modify bridge0 ipv4.addresses 192.168.1.3/24
sudo nmcli connection modify bridge0 ipv4.gateway 192.168.1.1
sudo nmcli connection modify bridge0 ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli connection modify bridge0 ipv4.method manual
sudo nmcli connection up bridge0

Final Thoughts

For a sysadmin it is a very important skill to set up the networking.
There are different ways to do it.

  • systemd-networkd
  • ifupdown
  • NetworkManager and nmcli

The chore is the same, but you use different tools to achieve the expected outcome.


Discover more from Tom's IT Cafe

Subscribe to get the latest posts sent to your email.

Leave a signal