Configure static IP address on Debian systems

1 minute read

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/ (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/

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

Address=    # your IP including netmask
Gateway=        # your default gateway
DNS=                 # your dns server             # your domain search paths

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

  1. Use DNS= in the file (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.