Fly, Penguin!

I blog so I don't forget.

Configure static IP address on Debian systems

1 minute read #linux #linux: debian #solved #network

I have now two home servers in two locations, and they should be “identical”. Both have a static IP address, which is surprisingly hard to configure, since there are actually four different ways in doing it:

  • netplan (Ubuntu only it seems)
  • ifup/down
  • NetworkManager
  • systemd-networkd

I am using the last one, systemd-networkd. This is how it’s done:

  1. uninstall network-manager: apt-get remove network-manager
  2. make sure the only configured interface in /etc/network/interfaces is lo
  3. create /etc/systemd/network/10-static.network (contents below)
  4. enable (do not start!) systemd-resolved: systemctl enable systemd-resolved
  5. enable (do not start!) systemd-networkd: systemctl enable systemd-networkd
  6. convert /etc/resolv.conf to a symlink: ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
# FILE: /etc/systemd/network/10-static.network

[Match]
Name=enp*                   # match the name of your hardware eth interface

[Network]
Address=192.168.10.10/24    # your IP including netmask
Gateway=192.168.10.1        # your default gateway
DNS=8.8.8.8                 # your dns server
Domains=mi.casa             # your domain search paths

If you plan to run a DNS server on the same host, do this:

  1. Use DNS=192.168.10.10 in the file 10-static.network (point to the same host)
  2. Add DNSStubListener=no to the file /etc/systemd/resolved.conf

… otherwise you’ll run into port troubles, cause both systemd-resolved and your DNS server want to own port 53.

Now REBOOT.