Basic Network Interface Confguration with NetworkManager via nmcli
![[attachment-qFVVzQ]](/files/2024/03/06/nmtui.png)
Preface
Having discovered nmtui only some time after familiarizing myself with nmcli - under the incorrect assumption that it would be necessary - I am adding this some time since publishing the body of the following article so that you might not make the same error:
I realize that for 99% of readers I am about to kill an article, but better for you to get the goods off the bat than to waste anyone's time. Before we dig into nmcli it would be remiss for me to not inform you of its menu-based ncurses relative that is so much easier that it does not even warrant its own article: nmtui. It is quick and feature-full enough to render knowing nmcli syntax relevant more-or-less exclusively to those looking to implement interfacing with Network Manager within shell scripts.
For those of you remaining so-inclined, I present the following...
Introduction
I have always favoured directly editing network configuration plaintext files (e.g: /etc/sysconfig/network-scripts/ifcfg-ifname on RedHat flavours). However it has for some time been more ideologically correct to manage the network configuration on many distributions via the NetworkManager daemon. More importantly, it is intrusive, obnoxious and annoying to disable NM such that it does not interfere with manual configurations (lookin' at you, Ubuntu). So this is my attempt to find religion.
Unless there is a crazy good reason, I don't do GUIs on servers. nmcli is provided to interface with NetworkManager from the command line. It can be used in CLI (direct) or shell (interactive) mode, as root/via sudo:
CLI
To effect the changes you must raise or reload the interface, using nmcli:
or on RedHat flavours simply:
Note the following:
- The interface's address is specified in CIDR notation (i.e. including the netmask)
- Arrays of multiple addresses are defined as comma-delimited lists (e.g: IP1,IP2,IP3). Take care to not include spaces.
The IPv4.method property can be set to any one of:
IPv6 is configured in the same way; see https://developer.gnome.org/NetworkManager/stable/settings-ipv6.html for IPv6 configuration options and modify your syntax accordingly.
Shell
As root/via
Again the connection must either be reloaded or raised to take effect:
Comments
There are no comments for this item.