Skip to content

Lesson 2 of 9 · 24m

Configuring Interfaces Without Locking Yourself Out

Static addressing, DHCP, MTU, and network management daemons — plus the safe-change habits that keep remote administration from becoming an outage.

The fastest way to lose a remote host is to be technically correct in the wrong order. You add the right address, delete the old one, flush a route, and discover that your SSH session was the test traffic. Interface administration is change management under hostile conditions: every command can cut the branch you are sitting on.

Know who owns the interface

Modern systems usually have exactly one primary manager, but inherited machines often have evidence of several:

networkctl status eth0 2>/dev/null || true
nmcli device status 2>/dev/null || true
ls -l /etc/netplan /etc/systemd/network /etc/NetworkManager/system-connections 2>/dev/null

If systemd-networkd owns the link, edit .network files and reload it. If NetworkManager owns it, use connection profiles. Manual ip address add is valid for testing, but it is not persistent configuration and it may confuse the daemon that believes it owns the interface.

A minimal static configuration

For systemd-networkd:

# /etc/systemd/network/20-uplink.network
[Match]
Name=eth0

[Network]
Address=192.0.2.14/24
Gateway=192.0.2.1
DNS=192.0.2.53

Apply with networkctl reload && networkctl reconfigure eth0. For NetworkManager:

nmcli connection modify uplink ipv4.method manual ipv4.addresses 192.0.2.14/24 ipv4.gateway 192.0.2.1 && nmcli connection up uplink

MTU is a path property, not a vibe

1500 is common, not universal. VPN overlays, PPPoE, VXLAN, and cloud encapsulation reduce effective MTU. Symptoms are ugly: TCP handshakes work, small requests work, large transfers stall. Test with ping -M do -s 1472 192.0.2.1; if the path is smaller, an interface setting such as ip link set dev eth0 mtu 1450 may be appropriate. 1472 payload plus 20 bytes IPv4 and 8 bytes ICMP equals 1500. Lower payload sizes until the probe succeeds, then account for encapsulation. Do not 'fix' MTU by random MSS clamping until you know where the black hole is.

Use a dead man's switch for risky changes

Before modifying the interface carrying your session, schedule rollback:

cp /etc/systemd/network/20-uplink.network /root/20-uplink.network.bak
systemd-run --on-active=2min --unit=rollback-net bash -c 'cp /root/20-uplink.network.bak /etc/systemd/network/20-uplink.network && networkctl reload'

Validate reachability, then cancel the timer with systemctl stop rollback-net.timer or the transient unit mechanism you actually used. This feels paranoid once. The second time, it feels professional.

Field notes

  • Duplicate address detection can leave an IPv4 address tentative or failed; inspect ip addr before blaming routing.
  • DHCP-assigned DNS is not automatically correct for servers. Servers often need explicit resolvers and search domains.
  • Changing the wrong connection profile is common on hosts with old Wired connection 1 profiles. List profiles before editing.
  • MAC address changes can make cloud NIC attach logic, DHCP reservations, and switch port security misbehave.
  • Never batch network changes over SSH without rollback and console access. Assume the command sequence will be interrupted.

Was this lesson helpful?

Sign in to rate