4

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?

1
  • 1
    Please edit your question to show the result of the terminal command: sudo systemd-resolve --status | grep -A3 Servers
    – chili555
    Oct 2, 2018 at 13:14

4 Answers 4

3

You need the package resolvconf, too.

So, to get rid of netplan completely:

  1. Configure /etc/network/interfaces
  2. Install ifupdown and friends: $ sudo apt install ifupdown resolvconf
  3. Remove netplan: $ sudo apt remove nplan netplan.io
1

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.

3
  • 1
    It's working perfectly only if you hardcode IPs into /etc/systemd/resolved.conf, otherwise the status command output is empty. So the dns-nameservers doesn't work at all. Sorry for the confusing description.
    – Velkan
    Oct 3, 2018 at 6:27
  • May we see: ls -al /etc/resolv.conf
    – chili555
    Oct 3, 2018 at 13:31
  • Added the /etc/resolv.conf.
    – Velkan
    Oct 4, 2018 at 7:50
0

See the answer here.

You need to edit /etc/systemd/resolved.conf file to change DNS on Ubuntu 18.04.

-1

network interfaces files have been changed a lot on ubuntu 18. I suggest you to check this website or another one to correctly configure your network adapter

how to configure network ubuntu 18

Anyways you can also (and that's the easiest way) configure your ip and nameservers from the network manager on settings.

2
  • I don't care about netplan. And the server has no NetworkManager.
    – Velkan
    Oct 2, 2018 at 9:59
  • On 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
    Oct 2, 2018 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .