On Ubuntu server 18.04 I've disabled netplan and using /etc/network/interfaces.
sudo apt-get -y install ifupdown
cat <<EOM | sudo bash -c 'cat > /etc/network/interfaces'
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.5.5
netmask 255.255.255.0
gateway 192.168.5.254
dns-nameservers 192.168.5.53 192.168.5.5
EOM
sudo ifdown --force eth0 lo && sudo ifup -a
sudo systemctl stop networkd-dispatcher
sudo systemctl disable networkd-dispatcher
sudo systemctl mask networkd-dispatcher
sudo apt-get -y purge nplan netplan.io
But apparently the systemd-resolve doesn't take into account the dns-nameservers
field.
In the /etc/resolv.conf
it puts only this:
nameserver 127.0.0.53
Output of ls -la /etc/resolv.conf
is:
lrwxrwxrwx 1 root root 39 Oct 2 15:28 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
Output of the sudo systemd-resolve --status | grep -A3 Server
is empty.
I can define DNS servers in /etc/systemd/resolved.conf
like this:
[Resolve]
DNS=192.168.5.53 192.168.5.5
Then the output of sudo systemd-resolve --status | grep -A3 Server
is:
DNS Servers: 192.168.5.53
192.168.5.5
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
And they are used correctly and appear in /etc/resolv.conf
.
How to make the dns-nameservers
config line work?
sudo systemd-resolve --status | grep -A3 Servers