Skip to content

Linux Foundations / Follow traffic and find the fault ยท Step 27 of 46

Lesson: Network ManagerSwitch
โ† Linux Foundations

Network operations

Network Manager

Manage wired and wireless connections with NetworkManager and its nmcli tool.

Configuring each interface by hand does not survive reboots and is awkward on laptops that move between networks. NetworkManager is a service that handles this for you. It is common on desktop distributions and on Fedora and RHEL. Some servers use systemd-networkd instead.

Devices and connections

NetworkManager separates two ideas:

  • A device is an interface, such as enp3s0.
  • A connection is a saved set of settings that can be activated on a device.

One device can have several connections, such as one for home and one for the office.

Looking around

nmcli is the command-line client:

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION
enp3s0  ethernet  connected  Wired connection 1
lo      loopback  connected (externally)  lo

Versions older than 1.42 usually show lo as unmanaged.

$ nmcli connection show

The second lists saved connections. Columns and states vary a little between versions.

Creating a static connection

$ sudo nmcli connection add type ethernet con-name lab ifname enp3s0 \
    ipv4.method manual ipv4.addresses 192.168.1.60/24 \
    ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1
$ sudo nmcli connection up lab

ipv4.method manual means you supply the address. With auto, the usual setting for a new profile, the address comes from DHCP. To change a saved setting, use modify, then activate the connection again so it takes effect:

$ sudo nmcli connection modify lab ipv4.dns 192.168.1.2
$ sudo nmcli connection up lab

Switching connections can drop a remote session, so practise on a console.

Other interfaces

  • nmtui gives a text menu in the terminal, if installed.
  • Desktop environments offer a graphical applet.
  • nmcli device wifi list shows nearby wireless networks.

Saved profiles are commonly stored in /etc/NetworkManager/system-connections/. Some older Red Hat systems use files in /etc/sysconfig/network-scripts/. Prefer nmcli to editing by hand.

Check that the service is running with systemctl status NetworkManager.

Try it

  1. Run nmcli device status.
  2. Run nmcli connection show and match connections to devices.
  3. Show one connection's full settings with nmcli connection show followed by its name.

Check your understanding

Network Manager

All 4 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.