Linux Network Configuration: ip, nmcli, Netplan and Troubleshooting
On modern Linux, use the ip command (iproute2) to view and make temporary network changes, and your distribution's network manager for permanent configuration: NetworkManager with nmcli on RHEL, Fedora and many desktops; Netplan YAML files on Ubuntu Server, which hand off to systemd-networkd or NetworkManager. Configure an IP address, gateway and DNS, then verify with ip addr, ip route, resolvectl status and ping.
Topic: Linux Administration in IT Infrastructure · Comparison
Quick answer: On modern Linux, use the ip command (iproute2) to view and make temporary network changes, and your distribution's network manager for permanent configuration: NetworkManager with nmcli on RHEL, Fedora and many desktops; Netplan YAML files on Ubuntu Server, which hand off to systemd-networkd or NetworkManager. Configure an IP address, gateway and DNS, then verify with ip addr, ip route, resolvectl status and ping. Older commands such as ifconfig and route are deprecated.
Key takeaways
ipchanges are lost at reboot unless saved in the network manager's configuration.- Use one network management tool per host to avoid conflicts.
- Check addresses, routes and DNS in that order when troubleshooting.
- Keep console access when changing networking on remote servers.
- Document static addressing and VLANs in your inventory.
Table of Contents
- Which Tool Does Your Distribution Use?
- How Do You View the Current Configuration?
- How Do You Set a Static IP with nmcli?
- How Do You Set a Static IP with Netplan?
- How Do You Configure VLANs and Bonding?
- What Is a Good Troubleshooting Sequence?
- References
Which Tool Does Your Distribution Use?
| Distribution | Default | Command or files |
|---|---|---|
| RHEL, Rocky, AlmaLinux, Fedora | NetworkManager | nmcli, nmtui |
| Ubuntu Server | Netplan with systemd-networkd | /etc/netplan/*.yaml |
| Ubuntu Desktop | Netplan with NetworkManager | nmcli or GUI |
| Debian (classic) | ifupdown | /etc/network/interfaces |
See Red Hat's networking guide and the Netplan documentation.
How Do You View the Current Configuration?
ip -br addr # brief list of interfaces and addresses
ip route # routing table, including default gateway
resolvectl status # DNS servers (systemd-resolved)
nmcli device status # NetworkManager view
hostnamectl # hostname
The ip manual covers every subcommand.
How Do You Set a Static IP with nmcli?
sudo nmcli con mod "System eth0" ipv4.method manual \
ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 \
ipv4.dns "192.168.10.1 1.1.1.1"
sudo nmcli con up "System eth0"
nmcli con show "System eth0" | grep ipv4
See the nmcli manual.
How Do You Set a Static IP with Netplan?
# /etc/netplan/01-static.yaml
network:
version: 2
ethernets:
eth0:
addresses: [192.168.10.20/24]
routes:
- to: default
via: 192.168.10.1
nameservers:
addresses: [192.168.10.1, 1.1.1.1]
# test with automatic rollback, then apply
sudo netplan try
sudo netplan apply
netplan try reverts automatically if you lose connectivity and do not confirm.
How Do You Configure VLANs and Bonding?
# VLAN 30 on eth0 (NetworkManager)
sudo nmcli con add type vlan con-name vlan30 dev eth0 id 30 ipv4.method manual ipv4.addresses 10.30.0.5/24
# Bond two NICs for redundancy (active-backup)
sudo nmcli con add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup"
sudo nmcli con add type ethernet slave-type bond con-name bond0-p1 ifname eth1 master bond0
sudo nmcli con add type ethernet slave-type bond con-name bond0-p2 ifname eth2 master bond0
# Temporary test only (lost on reboot)
sudo ip addr add 192.168.10.99/24 dev eth0
What Is a Good Troubleshooting Sequence?
- Link:
ip linkshows the interface UP; check cables or Wi-Fi. - Address:
ip addrshows a correct IP and prefix. - Gateway:
ip routehas a default route;pingthe gateway. - Internet:
ping 1.1.1.1. - DNS:
resolvectl query example.comordig example.com. - Firewall: check nftables or firewalld rules.
- Logs:
journalctl -u NetworkManagerorjournalctl -u systemd-networkd.
Related: fixing DNS problems and Linux firewalls. WebAsha offers RHCSA training.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0