7

I'm trying to override the nameserver settings in the netplan yaml configuration, but it doesn't seem to be working. Here's the /etc/netplan/01-netcfg.yaml file:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes
      dhcp4-overrides:
        use-dns: no
      nameservers:
        addresses: [192.168.1.7]

I'm running Ubuntu 18.04.3 LTS (I changed the nameserver IP address, but everything else is the same). Also, when I run netplan --debug generate, it produces this:

** (generate:1951): DEBUG: 20:05:57.212: Processing input file /etc/netplan/01-netcfg.yaml..
** (generate:1951): DEBUG: 20:05:57.212: starting new processing pass
** (generate:1951): DEBUG: 20:05:57.212: eth0: setting default backend to 1
** (generate:1951): DEBUG: 20:05:57.212: Configuration is valid
** (generate:1951): DEBUG: 20:05:57.212: Generating output files..
** (generate:1951): DEBUG: 20:05:57.212: NetworkManager: definition eth0 is not for us (backend 1)

And the really confusing thing is that there isn't any /run/netplan directory...

I should also mention that this is a virtual private server, so I don't have access to the bare metal... Not sure if that's important... Also, the reason that I'm using eth0 is because that's the only one that shows up when I run ifconfig, other than the loopback address. The original /etc/netplan/01-netcfg.yaml file from when I got the server from the hosting company was:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes

I wanted to reconfigure it so that I could use another virtual private server as the DNS server...

EDIT Just wanted to mention the output of systemd-resolve --status shows that the DNS Servers are the original ones configured by DHCP, and not the one overridden by the netplan configuration above. It doesn't seem to be accepting the netplan settings.

EDIT 2 In answer to some of the questions posted in the comments, I believe the hosting company has installed Ubuntu Server rather than a desktop installation. As far as I know, I can only access the VPS through a terminal, and I don't believe I have access to a GUI desktop. As for the other questions, I've reverted back to the original /etc/netplan/01-netcfg.yaml file and rebooted the server. Now, it should be back to its original configuration:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes

Also, it doesn't look like dhclient is running when I do ps aux | grep -i dhc... How can the /etc/netplan/01-netcfg.yaml file have dhcp4: yes configured if dhclient isn't running on the machine?

When I run ip a, I get

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     ...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
     ...

But there's no mention of enp0s3... Similarly for the ifconfig command, it just mentions eth0 and not enp0s3...

Here's the /etc/resolv.conf file:

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver <Some loopback IP>
options edns0
search home

I changed the value of the nameserver above as well as the value of the seach option.

systemd-resolve --status includes the following at the bottom of its output:

Link 2 (eth0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: <IP1>
                      <IP2>
                      <IP3>
          DNS Domain: <domain1>

where IP1, IP2, and IP3 are three IPv4 addresses that I would prefer not to use for DNS, and domain1 is a domain name that I also have no use for. Please let me know in the comments if there's any other useful information that could be find. Should I configure a static IP in /etc/netplan/01-netcfg.yaml, since dhclient isn't running? Another question, wouldn't it make more sense to use eth0 for the network device instead of enp0s3, since the latter isn't present when ip a is run?

EDIT 3 It might be useful to know that the servers in question are being provided by Linode. I deactivated their Linode Network Helper in order to set up my own DNS servers. Just thought it be useful information to know... It should just be a regular Ubuntu 18.04 server.

Response to Update 1 - See Heynnema's response

So, after rebooting with /etc/netplan/01-netcnf.yaml as

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: yes
      dhcp4-overrides:
        use-dns: no
      nameservers:
        addresses: [ 192.168.1.7 ]

and /etc/systemd/resolved.conf as

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
#DNS=
DNS=192.168.1.7
#FallbackDNS=
#Domains=
Domains=mydomain.com
#LLMNR=no
LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

I have the following:

/run/resolvconf/resolv.conf isn't present on the system.

cat /run/systemd/resolve/resolv.conf produces:

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 192.168.1.7
nameserver IP1
nameserver IP2
# Too many DNS servers configured, the following entries may be ignored.
nameserver IP3
search mydomain.com <domain1>

where IP1, IP2, and IP3 match those in the original output of systemd-resolve --status.

cat /run/systemd/resolve/stub-resolv.conf produces:

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
search mydomain.com <domain1>

Also, dpkg -l *dnsmasq* | grep ii produces:

ii  dnsmasq-base     2.79-1       amd64        Small caching DNS proxy and DHCP/TFTP server

and dpkg -l *dhcp* | grep ii produces:

ii  isc-dhcp-client      4.3.5-3ubuntu7.1 amd64        DHCP client for automatically obtaining an IP address
ii  isc-dhcp-common      4.3.5-3ubuntu7.1 amd64        common manpages relevant to all of the isc-dhcp packages

However, when I run ps aux | grep dns and ps aux | grep dh, no results are returned other than grep itself.

Edit 4

In case anyone's interested, the contents of /etc/systemd/network/05-eth0.network, minus the comments, were:

[Match]
Name=eth0

[Network]
DHCP=no
DNS=IP1 IP2 IP3
Domains=<domain1>
IPv6PrivacyExtensions=false

Gateway=the_gateway_ip
Address=my_public_ip
Address=my_private_ip

where IP1, IP2, and IP3 were the nameserver IPs that I needed to override, and domain1 was a domain name created by the hosting provider. The Gateway and two Address settings were the correct ones that I needed. I just wanted to override the DNS settings, so renaming the file to avoid its being used did the trick.

Many thanks in advance!

Andrew
  • 211
  • 1
    Since you specified "renderer: networkd", when you "sudo netplan generate" NetworkManager just gives an informational message that "eth0 is not for us". What I don't see in your post is that you've done a "sudo netplan apply" which is what makes a newly generated config active. You've otherwise got the right idea. – heynnema Jan 25 '20 at 02:05
  • @heynnema Thanks for the suggestion. I just tried sudo netplan apply, and it executes without any errors. However, the output of systemd-resolve --status is still showing the original dhcp servers:( I should have mentioned that when I ran sudo netplan try, it asked me if I wanted to keep the new settings, which I indicated by pressing enter. – Andrew Jan 25 '20 at 02:46
  • Is this a desktop or server configuration? Reboot, and then edit your question and show me ls -al /etc/resolv.conf and cat /etc/resolv.conf and cat /etc/systemd/resolved.conf and systemd-resolve --status. – heynnema Jan 25 '20 at 03:49
  • And I just noticed that you're using the wrong eth0... it should be enp0s3... you'd better show me sudo lshw -C network. – heynnema Jan 25 '20 at 03:55
  • And show me grep -i net.ifnames /etc/default/grub. – heynnema Jan 25 '20 at 04:00
  • @heynnema I added EDIT 2 to provide some more information. Also, when I grep the /etc/default/grub file, it produces the line GRUB_CMDLINE_LINUX="console=ttyS0,19200n8 net.ifnames=0". Is that significant? It sure looks strange... – Andrew Jan 25 '20 at 14:44
  • @heynnema It might be useful to know at this point that the server is being provided by Linode, in case anyone has any experience with their configurations. I'll add a third edit to the question... – Andrew Jan 25 '20 at 15:15
  • Lets see if I can remember all of the items I need to cover. 1) you didn't show me all of the info that I requested, and please don't redact info unless it's internal or company private, like the cat /etc/resolv.conf I needed to actually see the nameserver if it's not 127.0.0.53. Please review my previous comment and supply the full info 2) the net.ifnames=0 is what messed things up, in so far as the network devices have been reverted to the non-portable names... so your .yaml file that uses eth0 is correct, enp0s3 is not. 3) yes, you have a server, so there's no GUI. – heynnema Jan 25 '20 at 15:39
  • /etc/resolv.conf should be a symlink, and shouldn't be manually edited.
  • – heynnema Jan 25 '20 at 15:45
  • @heynnema You are correct, the nameserver from /etc/resolv.conf is set to 127.0.0.53. You're also correct that the file is symlinked to /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf. I redacted it because it appeared to be a nonstandard loopback IP address, although I guess this was not true. I've never seen a loopback that ends in 53. You learn something new everyday, I suppose... – Andrew Jan 25 '20 at 16:19
  • Thanks for the update. However, I still need to see cat /etc/systemd/resolved.conf and the full systemd-resolve --status. – heynnema Jan 25 '20 at 16:21