LLI Wiki — My Digital Knowledge Base

Linux network configuration overview

Interface naming, network managers (systemd-networkd, NetworkManager, netplan, netctl), statistics and DHCP checks on Linux.

This article gives an overview of network interface names and of the main network managers on Linux, with the commands to check the state of a network card, its link statistics and DHCP traffic.

Interface names

Recent systemd versions use predictable interface names built from the hardware location. For example, enp0s10 is read as:

Part Meaning
en Ethernet (wl would mean wireless)
p0 PCI bus number (0)
s10 Slot number (10)

To list the interfaces and the Ethernet controllers:

ls /sys/class/net
lspci | grep Ethernet

To check the link state, speed and duplex of an interface:

sudo ethtool <interface>

Network managers

Identify the manager in use before changing a configuration. Several managers on the same machine can fight over the same interface.

Manager Service Configuration Tools
systemd-networkd (common on servers) systemd-networkd.service /etc/systemd/network/ networkctl status
NetworkManager (common on desktops) NetworkManager.service /etc/NetworkManager/system-connections/ nmcli, nmtui
netplan (Ubuntu) netplan generates the configuration for the back end /etc/netplan/*.yaml sudo netplan apply, sudo netplan --debug apply
netctl (Arch Linux) netctl.service /etc/netctl/ netctl

Notes on each manager:

Firewall

On AlmaLinux and other Red Hat-based systems, firewalld manages the firewall. See How to allow a port through the firewall on AlmaLinux.

Interface and traffic statistics

Command Shows
ip -s link Packet and error counters for each interface
ss -s Summary of socket usage
netstat -i Interface counters (net-tools package)
netstat -s Protocol statistics (net-tools package)
nstat Kernel network counters, with changes since the last call
sar -n DEV 1 3 Network throughput per interface, every second, three samples (sysstat package)

More commands are listed in Linux networking commands on TecMint.

DHCP server and client

On an ISC DHCP server, the leases file is /var/lib/dhcpd/dhcpd.leases:

tail -f /var/lib/dhcpd/dhcpd.leases

To capture DHCP traffic (ports 67 and 68) on an interface:

sudo tcpdump -i <interface> port 67 or port 68 -e -n -vv

Notes

Mastodon LLIMastodon SocialFosstodon