Exercise: Managing Network Interfaces
Using nmcli and networkctl
nmcli and systemd-networkd’s networkctl command-line tools.
1 Purpose
This exercise introduces you to the command-line tools for the two major networking services on modern Linux systems: NetworkManager and systemd-networkd. Your Fedora Workstation uses NetworkManager by default, so you will use its tool, nmcli. However, it’s important to also know the commands for systemd-networkd, as it is very common in server environments. This guide provides steps for nmcli and includes callouts with the equivalent commands for systemd-networkd.
2 What You’ll Accomplish
By the end of this exercise, you will be able to:
- Use
nmclito check the overall network status. - Differentiate between network “devices” and “connections” in NetworkManager.
- Use
nmclito view devices and connection profiles. - Identify the equivalent
networkctlcommands for viewing system network state. - Understand why different tools are preferred for workstations versus servers.
This exercise maps to the following program and course learning outcomes:
- Course Learning Outcomes (CLOs):
- 3. Troubleshoot hardware and basic network components: Using
nmcliornetworkctlto check status is a key skill for troubleshooting network issues on any modern Linux system.
- 3. Troubleshoot hardware and basic network components: Using
This exercise develops the following skills, which align with the O*NET SOC Code 15-1232.00 for Computer User Support Specialists.
| Learning Objective | O*NET KSAs | Technologies Used |
|---|---|---|
| Manage network state using command-line tools. | Knowledge: Telecommunications, Computers & Electronics Skills: Systems Analysis, Operations Analysis |
nmcli, networkctl |
3 Prerequisites
This exercise requires a running Fedora 42 virtual machine with internet access and a user account with sudo privileges.
4 Step-by-Step Guide
Open a terminal window in your Fedora VM to begin.
- NetworkManager (
nmcli) is standard on workstations like Fedora. It is designed for dynamic environments where network connections change frequently (e.g., switching Wi-Fi, connecting VPNs). It’s powerful and user-friendly for desktop use. - systemd-networkd (
networkctl) is common on servers. It uses simple text files for configuration, which is ideal for the static, predictable network setups found in data centers. It’s leaner and preferred for automation.
4.1 Step 1: Check General Status
First, get a high-level status of your networking.
Run the
nmclicommand:nmcli general statusThis will tell you if networking is enabled overall and if your machine has a connection.
The equivalent command for systemd-networkd is networkctl status. This command lists the status of all network links that systemd-networkd is managing.
networkctl status4.2 Step 2: View Devices (Links)
Next, view all the network “devices” (or “links”) that the service can see.
Run the
nmclicommand:nmcli device statusYou will see your wired Ethernet adapter (e.g.,
enp1s0), the loopback interface (lo), and potentially others.
The networkctl command to list links is simply networkctl list, or just networkctl by itself.
networkctl listThis shows each network interface’s index number, name, type, and operational state.
4.3 Step 3: View Connections (Configuration)
Now, view the list of configured connections.
Run the
nmclicommand:nmcli connection showAnalyze the output. You will likely see a connection profile that corresponds to your primary Ethernet device. This highlights a key concept in NetworkManager:
- A device (seen in Step 2) is the network interface, which can be physical hardware (like
enp1s0) or a virtual interface (like a bridge, veth, or vxlan device). - A connection is a saved profile of settings (e.g., IP address configuration, DNS servers, Wi-Fi password) that is applied to a device.
You can have multiple connection profiles for a single device, such as one for a static IP at the office and one for DHCP at home, and switch between them as needed.
- A device (seen in Step 2) is the network interface, which can be physical hardware (like
systemd-networkd does not have a “connection” concept. Instead, it uses simple configuration files ending in .network located in /etc/systemd/network/. You would list the configurations like this:
ls /etc/systemd/network/This declarative, file-based approach is a key reason it’s preferred for managing servers.
4.4 Step 4: Simulate Radio Control
You can globally enable or disable different types of wireless radios.
Run the following
nmclicommands to simulate turning the Wi-Fi radio off and on.# To disable all Wi-Fi radios nmcli radio wifi off # Check the status of the radios nmcli radio # To re-enable them nmcli radio wifi on # Check the status again nmcli radio
rfkill
systemd-networkd does not manage radios. This task is handled by a lower-level utility called rfkill.
rfkill list: Shows all radios, their type, and whether they are soft or hard blocked.sudo rfkill block wifi: Disables all Wi-Fi radios.sudo rfkill unblock wifi: Re-enables all Wi-Fi radios.
This separation of concerns is typical in server-oriented tools.
5 Reflect and Review
Now that you have completed this exercise, reflect on your experience in your Microsoft Teams Student Notebook:
- 3 different
nmcliornetworkctlcommands you learned. - 2 differences between how NetworkManager and
systemd-networkdoperate. - 1 question you still have about Linux networking services.
Answer these questions in your notebook to solidify your understanding:
- What command would you use to see a list of saved network profiles in NetworkManager?
- Why might a server administrator prefer using
systemd-networkd’s text files for configuration instead ofnmcli’s connection profiles? - You need to disable the Wi-Fi radio on a server that does not have NetworkManager installed. What command would you use?
- What
networkctlcommand is the equivalent ofnmcli device status?