Configure static IP address on Debian systems
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:
- uninstall
network-manager
:apt-get remove network-manager
- make sure the only configured interface in
/etc/network/interfaces
islo
- create
/etc/systemd/network/10-static.network
(contents below) - enable (do not start!)
systemd-resolved
:systemctl enable systemd-resolved
- enable (do not start!)
systemd-networkd
:systemctl enable systemd-networkd
- 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:
- Use
DNS=192.168.10.10
in the file10-static.network
(point to the same host) - 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.