Configure static IP address on Debian systems
Posted on October 29, 2021 (Last modified on July 11, 2024) • 1 min read • 188 wordsI 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:
network-manager
: apt-get remove network-manager
/etc/network/interfaces
is lo
/etc/systemd/network/10-static.network
(contents below)systemd-resolved
: systemctl enable systemd-resolved
systemd-networkd
: systemctl enable systemd-networkd
/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:
DNS=192.168.10.10
in the file 10-static.network
(point to the same host)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.