netplan does not allow a top-level 'nameservers' stanza

Bug #1698023 reported by Steve Langasek
36
This bug affects 7 people
Affects Status Importance Assigned to Milestone
netplan.io (Ubuntu)
Triaged
Wishlist
Unassigned
nplan (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

The netplan draft spec calls for 'nameservers' to be allowed as a top-level stanza. It is currently only implemented as a per-device configuration.

While we've discussed that the nameserver addresses should really just be associated with the interfaces which route to those addresses, 'nameservers' is also how you define the DNS search path as would be included in /etc/resolv.conf. A machine's DNS search path is not a function of which interfaces are currently up, and needs to be globally definable.

If we decide this is client configuration that's out of scope for netplan, we should clarify the spec to not list 'nameservers' at the top level.

If we decide that it is in scope, but that we still don't want to support declaration of global nameservers just the search path, we should fix this to be e.g. 'domain-search' at the top level.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in nplan (Ubuntu):
status: New → Confirmed
Revision history for this message
John F Leach (jfleach) wrote :

Is there a workaround for this issue?

Revision history for this message
John F Leach (jfleach) wrote :

This is a workaround for the issue:

sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo reboot

# Known Issue
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624320

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Please don't do that.

resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf and should remain that way -- this makes sure any changes on the network are reflected "automatically" in the resolver's behavior, since you'd be asking systemd-resolved rather than the libc resolver, and it already knows about the contents of /run/systemd/resolve/resolv.conf.

If you must use global nameservers, you can certainly modify /etc/systemd/resolved.conf's DNS= field to add them, but be aware that "global" nameservers don't make all that much sense. Nameservers are per-interface, because they might not be reachable by all interfaces when there are multiple connected.

Revision history for this message
John F Leach (jfleach) wrote :

@cyphermox: Why should the user have to maintain nameservers in two separate places? netplan should support this and I don't think it belongs in systemd. Thanks for your help.

Revision history for this message
Mark Rodgers (mrodg1998) wrote :

There seem to be a number of workarounds on the Web, and most of them revolve around modifying either the netplan config file or the systemd resolver config. None really worked for me -- usually, the resolver configuration did not survive a reboot.

I found a very unclean (but effective) workaround by restoring the old functionality of /etc/resolv.conf:

1. Remove the symlink /etc/resolv.conf
2. Create a new /etc/resolv.conf and enter your name servers and search domains.
3. Make this file immutable (chattr +i /etc/resolv.conf)
4. Wait until this bug is resolved

And yes, I am aware that this workaround is *very* ugly. This workaround is (hopefully) temporary, but it seems to me that netplan needs to be fixed first.

Revision history for this message
Steve Langasek (vorlon) wrote :

Mark, this bug is solely about the lack of support for top-level declarations of DNS preferences in netplan. At most, the consequence is that you must repeat yourself in the netplan config. That's suboptimal and a bug we should fix, but I don't see any reason one should ever work around it by making resolve.conf immutable.

Revision history for this message
Mark Rodgers (mrodg1998) wrote :

Steve: Maybe my comment does not really belong here, I agree. I admit that I have not fully investigated the problem -- the problem in my case being that a configuration with static IP does not appear to set the DNS correctly, either via netplan (and networkd) or via systemd's resolver. A web search for this problem reveals that I am not the only one.

I also agree (and acknowledge) that my workaround is ugly.

Revision history for this message
Steve Langasek (vorlon) wrote : Re: [Bug 1698023] Re: netplan does not allow a top-level 'nameservers' stanza

On Tue, Sep 04, 2018 at 03:26:12PM -0000, Mark Rodgers wrote:
> Steve: Maybe my comment does not really belong here, I agree. I admit
> that I have not fully investigated the problem -- the problem in my case
> being that a configuration with static IP does not appear to set the DNS
> correctly, either via netplan (and networkd) or via systemd's resolver.
> A web search for this problem reveals that I am not the only one.

Setting DNS with a static IP is a common configuration that's well-exercised
in Ubuntu 18.04, no workarounds required. If you're having difficulty
getting the config correct, askubuntu.com is a good resource for this.

Revision history for this message
Lukas Märdian (slyon) wrote :

Moving it over to the netplan.io project, as nplan is deprecated.
Also, I'm marking it as a "Wishlist" item, which could be considered to be implemented as a new feature.

Changed in netplan.io (Ubuntu):
status: New → Triaged
importance: Undecided → Wishlist
Changed in nplan (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.