## Intro

When a Linux host stops communicating, the issue often hides in the interaction between systemd, NetworkManager, systemd-resolved, and the kernel's routing tables. The good news: most problems can be diagnosed methodically with simple tools and corrected without guesswork. This guide walks through a repeatable troubleshooting path, from the physical link up through DNS resolution, using commands, expected output, and safe rollback steps. Each section builds on the last, ending with a checklist you can keep for on-call situations.

We will cover:

- Gathering version and environment information

- Making scoped configuration changes

- Verifying connectivity and name resolution

- Recognizing common failure modes and recovering from them

- A practical operations checklist

The approach relies on systemd's introspection capabilities and standard networking commands. Whether you manage a single virtual machine or a fleet of servers, these techniques will help you isolate issues faster and with confidence.

## Version and Environment Inventory

Before touching any configuration, collect the current state. This establishes a baseline for comparison if things go wrong and helps you identify version-specific quirks. Run the following commands on the affected system, ideally as a user with sudo privileges.

### Check the OS and systemd Version

cat /etc/os-release
systemctl --version | head -1 
 Example output (from a typical Ubuntu 24.04 system):

PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION_CODENAME=noble
ID=ubuntu
...
systemd 255 (255.4-1ubuntu8.2) 
 Why it matters: systemd's network components evolve. For example, systemd-resolved gained DNS-over-TLS options in version 239, and networkctl syntax changed in version 244. Knowing your version avoids using outdated commands.

### Identify Network Management Stack

Does the system use NetworkManager or systemd-networkd? Both can coexist, but one usually manages interfaces. Check with:

systemctl status NetworkManager systemd-networkd --no-pager 
 If NetworkManager is active, you will see something like:

● NetworkManager.service - Network Manager
 Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
 Active: active (running) since Mon 2025-02-10 08:17:42 UTC; 2h 3min ago 
 For systemd-networkd, look for active status and any interface it manages via networkctl :

networkctl list 
 This shows interfaces, their operational state, and which setup (e.g., dhcp , configured ) applies.

### Record Current Network Configuration

Capture a snapshot of IP addresses, routes, and DNS settings. These will be your reference if you need to revert.

ip addr show > /tmp/ip_addr_before.txt
ip route show table all > /tmp/ip_route_before.txt
cat /etc/resolv.conf > /tmp/resolv_before.txt 
 Use ip from the iproute2 package; it is the modern replacement for ifconfig . The output should include your primary interface (e.g., eth0 or ens3 ) with an IP address and a default route via a gateway.

Also check hostname and NSS configuration:

hostnamectl
cat /etc/nsswitch.conf | grep hosts 
 The hosts: line typically reads files dns or files resolve [!UNAVAIL=return] dns . If you are troubleshooting systemd-resolved, you may see resolve in that line.

### Determine Physical and Link Layer Status

Use ip link to see whether the interface is up or down, and check for carrier signal:

ip link show eth0 
 Example with link up:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff 
 Note UP and LOWER_UP : the first means administratively enabled, and the second indicates a carrier signal (cable connected or virtual link active). If missing, start at the physical/virtual layer.

### Prerequisites Summary

You will need:

- A Linux system running systemd (most modern distributions)

- Access to a terminal with sudo rights

- Basic familiarity with ip , ping , ss , dig or nslookup

- No production changes yet; we are just reading state

Having this baseline documented makes troubleshooting systematic and safe.

## Safe Configuration Path

Now that you understand the current state, you can make targeted changes. The key principle: always make the smallest possible change, test it, and be ready to revert. Avoid editing multiple files at once or restarting networking services blindly. Instead, use systemd's native tools for secure and reversible modifications.

### How systemd Manages Network Configuration

Depending on your setup, networking is controlled by:

- systemd-networkd : uses .network files in /etc/systemd/network/ , applied per interface

- NetworkManager : stores connection profiles in /etc/NetworkManager/system-connections/ , managed via nmcli or GUI

- ifupdown (legacy) : uses /etc/network/interfaces

We will focus on systemd-resolved and the interplay with these services.

### systemd-resolved Role

systemd-resolved provides DNS resolution and manages /etc/resolv.conf via a stub listener at 127.0.0.53 . Check its status:

systemctl status systemd-resolved
resolvectl status 
 The resolvectl status output shows global and per-link DNS settings.

### Example: Adjusting systemd-resolved DNS Servers

Imagine a host using systemd-resolved but unable to resolve internal hostnames. You have a local DNS server at 10.0.0.2 . Instead of editing /etc/resolv.conf directly (which may be overwritten), set the DNS server for the active connection using resolvectl .

First, identify the interface name via ip link or resolvectl status . Assume it is eth0 . Set the DNS server for that link:

sudo resolvectl dns eth0 10.0.0.2 
 Expected output (no output means success). Verify:

resolvectl status eth0 
 You should see the new DNS server under Link 2 (eth0) :

Link 2 (eth0)
 Current Scopes: DNS
 Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 10.0.0.2
 DNS Servers: 10.0.0.2 
 This change is immediate but not persistent across reboots. To make it persistent, you must configure the underlying network manager. For systemd-networkd, create or edit /etc/systemd/network/eth0.network (or a drop-in) to include:

[Network]
DNS=10.0.0.2 
 For NetworkManager, use:

sudo nmcli connection modify "Wired connection 1" ipv4.dns "10.0.0.2"
sudo nmcli connection up "Wired connection 1" 
 Always test the immediate change with resolvectl before making it persistent. If something breaks, simply reboot or restore the original configuration.

### Example: Using Drop-in Files to Override Service Settings

For systemd services, avoid editing unit files directly under /lib/systemd/system/ . Instead, use drop-in files under /etc/systemd/system/ . This keeps your changes separate and easy to undo.

Suppose you need to add a custom DNS option to systemd-resolved. You can create a drop-in for the service:

sudo mkdir -p /etc/systemd/system/systemd-resolved.service.d/
cat <<EOF | sudo tee /etc/systemd/system/systemd-resolved.service.d/dns.conf
[Service]
Environment=SYSTEMD_RESOLVED_OPTIONS=--debug
EOF
sudo systemctl daemon-reload
sudo systemctl restart systemd-resolved 
 However, enabling debug logging should be temporary. To remove, delete the drop-in file and restart.

### Best Practices for Safe Configuration

- Always use sudo for changes and keep a terminal open with root shell in case you lock yourself out.

- Before restarting a service, run systemctl status to know its current state.

- For network changes, if you are connected remotely, ensure you have a way to revert (e.g., a scheduled reboot or out-of-band console) because a mistake can cut off access.

- Do not disable systemd-resolved unless you fully understand the implications; many services expect it to be running.

- Use networkctl reload for systemd-networkd instead of restarting the whole service when applying .network file changes.

- Document every change with date and reason.

## Verification and Diagnostics

After making a change, verify that the system behaves correctly. This section provides a sequence of commands that check connectivity at each layer, from the local socket to external DNS resolution. Each command includes typical output and interpretation.

### 1. Verify Interface and IP Configuration

Use ip to confirm the interface has an IP address and is up:

ip addr show eth0 
 Expected:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
 inet 192.168.122.50/24 metric 100 brd 192.168.122.255 scope global dynamic eth0
 valid_lft 3599sec preferred_lft 3599sec 
 If no inet line appears, the interface did not get an IP. For DHCP, check networkctl status eth0 or journalctl -u systemd-networkd for errors.

### 2. Check Routing Table

Confirm a default route exists:

ip route show default 
 Expected:

default via 192.168.122.1 dev eth0 proto dhcp src 192.168.122.50 metric 100 
 If missing, the system cannot reach external networks.

### 3. Test Local TCP/IP Stack

Ping the loopback address:

ping -c 4 127.0.0.1 
 Should show 4 packets transmitted, 4 received, 0% loss. If this fails, the kernel networking stack is broken, which is rare.

### 4. Ping Gateway

Ensure you can reach the default gateway:

ping -c 3 192.168.122.1 
 If unreachable, check the link layer and switch/VLAN configuration.

### 5. Test External IP Connectivity

Ping a public IP (e.g., 8.8.8.8 ) to see if routing beyond the gateway works:

ping -c 3 8.8.8.8 
 If this works but DNS fails, the problem is name resolution, not routing.

### 6. Verify DNS Resolution via systemd-resolved

Use resolvectl query or dig against the stub resolver to test DNS:

resolvectl query example.com 
 Expected output includes the IP address and the DNS server used:

example.com: 93.184.216.34
 93.184.216.34

-- Information acquired via protocol DNS in 12.3ms.
-- Data is authenticated: no; Data was acquired via local or encrypted transport: no 
 Alternatively, use dig (may need install dnsutils ):

dig @127.0.0.53 example.com 
 If this returns SERVFAIL or NXDOMAIN , the DNS server may be misconfigured or unreachable.

### 7. Check Listening Ports and Services

Use ss to verify that services are listening on expected ports:

ss -tulpn 
 For example, a web server listening on port 80 and 443:

State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=1234,fd=6))
LISTEN 0 128 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=1234,fd=7)) 
 If a service is missing or bound to the wrong address, check its unit status and logs.

### 8. Firewall and Port Reachability

If a service is listening but unreachable from another host, test with curl or nc on the target port, and check firewall rules.

From a remote machine, try:

nc -zv 192.168.122.50 80 
 If it fails, local firewall may be blocking. On the target, list rules with nft list ruleset or iptables -L -n :

sudo nft list ruleset | less 
 Common issues include missing ACCEPT for port 80 or a default DROP policy. Remember that ufw or firewalld may be managing these rules.

### 9. systemd-resolved and DNS Over TLS

If you are using DNS-over-TLS (DoT), verify that the connection is encrypted. resolvectl status shows the protocol. For example, with DoT enabled, you may see DNSOverTLS=opportunistic or yes . You can test with a command like:

resolvectl query example.com 
 If output shows Data was acquired via local or encrypted transport: no , then DoT may not be active or the server does not support it. Check the resolved configuration and logs.

### 10. Using journalctl for Network-Related Logs

Systemd logs are invaluable. To see messages from systemd-networkd or systemd-resolved in the last hour:

journalctl -u systemd-networkd -u systemd-resolved --since "1 hour ago" 
 Look for lines indicating DHCP failures, DNS timeouts, or interface state changes. Use -f to follow logs live while reproducing the issue.

## Failure Modes and Recovery

Despite careful changes, networking may break. This section describes common failure modes and how to recover safely.

### Common Failure Modes

- Incorrect DNS server : systemd-resolved points to an unreachable or wrong DNS server, causing resolution timeouts.

- Duplicate IP address : two hosts share the same IP, leading to intermittent connectivity.

- Missing default route : after DHCP or static configuration changes, the default route is absent, so external traffic fails.

- Firewall misconfiguration : new rules accidentally block required ports.

- systemd-resolved not running : if the service crashed or was disabled, local applications cannot resolve names via the stub.

- Interface down or unplugged : physical or virtual link is down.

### Recovery Steps

### Recovering from a Bad DNS Setting

If a resolvectl dns change breaks resolution, revert by resetting to DHCP or original values. For example, to revert a static DNS server and let DHCP provide DNS again:

sudo resolvectl dns eth0 "" 
 Then, if using systemd-networkd, remove the DNS= line from the .network file and reload. For NetworkManager, modify the connection to remove DNS entries and reactivate.

To verify recovery, run resolvectl query example.com and check the output shows a proper IP.

### Recovering from a Missing Default Route

If you accidentally deleted the default route, add it back manually:

sudo ip route add default via 192.168.122.1 dev eth0 
 Then update the persistent configuration to ensure it survives reboot.

### Recovering from a Broken Firewall Rule

If you added a rule that blocks SSH or another critical service, you can temporarily disable the firewall:

- For ufw : sudo ufw disable

- For firewalld : sudo systemctl stop firewalld

- For raw nftables / iptables , flush rules: sudo nft flush ruleset or sudo iptables -F

Then re-establish connectivity and carefully re-enable with corrected rules.

### Systemd-resolved Crash Recovery

If systemd-resolved is not running, start it and enable it:

sudo systemctl start systemd-resolved
sudo systemctl enable systemd-resolved 
 Then check /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf or contains nameserver 127.0.0.53 . If not, you can recreate the symlink:

sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf 

### Recovering from Interface Down

 If an interface is administratively down, bring it up:

sudo ip link set eth0 up 
 For persistent configurations, ensure the .network file or NetworkManager connection has Link section with RequiredForOnline=yes or similar, and the profile is set to autoconnect.

### Rollback Strategy for Systemd Service Changes

If you modified a service unit file or drop-in and the service fails, the quickest rollback is to:

- Stop the service: sudo systemctl stop <service>

- Remove or rename the drop-in file: sudo mv /etc/systemd/system/<service>.d/override.conf /tmp/

- Run sudo systemctl daemon-reload

- Start the service: sudo systemctl start <service>

If the service still fails, inspect journalctl -u <service> for errors and additional missing dependencies.

### Testing Recovery

Always test recovery steps in a non-production environment first, if possible. If you are working on a live system, schedule a maintenance window and have a rollback plan.

## Operations Checklist

Use this checklist for routine network troubleshooting, especially during incidents.

### Pre-checks (Before Changes)

- [ ] Confirm physical/virtual link: ip link show shows LOWER_UP .

- [ ] Record current IP configuration: ip addr show > /tmp/ip_before.txt .

- [ ] Record routing table: ip route show > /tmp/route_before.txt .

- [ ] Check DNS settings: resolvectl status or cat /etc/resolv.conf .

- [ ] Note active network manager: systemctl status NetworkManager systemd-networkd .

### During Troubleshooting

- [ ] Make one change at a time; test after each.

- [ ] Use drop-ins for service overrides.

- Commands to diagnose connectivity:

- ping -c 3 8.8.8.8 (external IP)

- ping -c 3 example.com (DNS and routing)

- resolvectl query example.com (DNS resolution)

- ss -tulpn (listening ports)

- journalctl -u systemd-networkd -u systemd-resolved --since "10 min ago"

- [ ] Capture firewall rules: sudo nft list ruleset .

- [ ] If using NetworkManager, inspect connection: nmcli connection show .

### Post-change Verification

- [ ] Confirm interface has IP: ip addr show eth0 .

- [ ] Confirm default route: ip route show default .

- [ ] Confirm DNS resolution: resolvectl query example.com returns an IP.

- [ ] Confirm service connectivity: curl -I http://localhost or nc -zv localhost 80 .

- [ ] Check logs for new errors: journalctl -u systemd-networkd -u systemd-resolved --since "5 min ago" .

### Cleanup and Documentation

- [ ] Remove temporary files ( /tmp/ip_* ).

- [ ] Document the permanent fix in your team's knowledge base.

- [ ] If the issue was caused by a configuration change, update the configuration management (e.g., Ansible, Puppet) to prevent recurrence.

- [ ] Review monitoring alerts to ensure they cover the failure mode.

## Conclusion

Troubleshooting systemd networking issues does not have to be painful. By following a systematic approach - inventory, safe configuration, verification, and recovery - you can resolve most problems quickly and with minimal risk. The key takeaways are:

- Always start with a baseline: know your systemd version, active network manager, and current network state.

- Make scoped changes using systemd's tools like resolvectl and drop-in files, not broad hacks.

- Verify each change with simple commands and expected outputs.

- Be ready to roll back: keep backups, use reversible commands, and know how to restore services.

- Use the operations checklist to stay consistent and prevent missed steps.

By practicing these techniques, you will build confidence and reduce downtime. For your next incident, pull out this guide and work through the layers: link, IP, route, DNS, service, and firewall. Happy troubleshooting!