How to make Ubuntu server 18.04 use dns-nameservers from /etc/network/interfaces?
Solution 1
You need the package resolvconf
, too.
So, to get rid of netplan completely:
- Configure
/etc/network/interfaces
- Install ifupdown and friends:
$ sudo apt install ifupdown resolvconf
- Remove netplan:
$ sudo apt remove nplan netplan.io
Solution 2
How to make the dns-nameservers config line work?
As you can see by the status command, the line is working perfectly:
DNS Servers: 192.168.5.53
192.168.5.5
The symbolic link /etc/resolv.conf shows:
nameserver 127.0.0.53
That indicates that dnsmasq is running here: https://help.ubuntu.com/community/Dnsmasq
In short, this means that domain name lookups will first query a local cache to see if the site has been visited before. 127.0.0.xx is 'local' in this context. If so, the local cache will provide the IP address. If the site has not been visited before and no reference is available in the local cache, only then will the listed DNS nameservers; 192.168.5.53 and 192.168.5.5, in your case, be used.
The readings you’ve gven above are entirely normal and expected.
Related videos on Youtube
Velkan
Updated on September 18, 2022Comments
-
Velkan over 1 year
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?-
chili555 over 5 yearsPlease edit your question to show the result of the terminal command:
sudo systemd-resolve --status | grep -A3 Servers
-
-
Velkan over 5 yearsI don't care about netplan. And the server has no NetworkManager.
-
Velkan over 5 yearsOn google it's possible to find how to configure netplan. If you think that my question is about configuring netplan then flag it as a duplicate.
-
Velkan over 5 yearsIt's working perfectly only if you hardcode IPs into
/etc/systemd/resolved.conf
, otherwise the status command output is empty. So thedns-nameservers
doesn't work at all. Sorry for the confusing description. -
chili555 over 5 yearsMay we see:
ls -al /etc/resolv.conf
-
Velkan over 5 yearsAdded the
/etc/resolv.conf
.