What is the effect of the nameservers/addresses field in the yaml configuration file?
Any application I've tried uses the /etc/resolv.conf nameservers. This happens even with resolvconf stopped.
This is using systemd as resolver. No errors on generate or apply.
RESOLUTION
Thanks to all who responded. The netplan config yaml configures the nameservers after I do this:
- Purge resolvconf;
- Put my LAN DNS as forwarder in /etc/bind/named.conf.options;
Replace the /etc/resolv.conf link with a static file as
search nameserver 127.0.0.53
And that works. I find I have to include the search in the resolv.conf even though I have a search field in my netplan config yaml. Puzzle for another day.
The behavior witnessed in your environment is the
systemd-resolved
equivalent of whatdnsmasq
on pre-18.04 was doing. Thenetplan
updates affect the nameservers thatsystemd-resolved
use for its lookups. This is detailed in the last section of the answer.But first, for the curious, some history about this behavior, and how it differs from the 'older' Ubuntu versions which use Network Manager and
dnsmasq
. (Feel free to skip past the next section of this answer if you only want the 18.04-related stuff)Before 18.04:
dnsmasq
as a local caching resolverPrior to 18.04, whenever you used the GUI Ubuntu, it would install
dnsmasq
alongside Network Manager. The Network Manager integration withdnsmasq
would update thednsmasq
list of 'next hop' servers (upstream DNS servers) for where to send a query.Therefore, a DNS query for
google.com
would pass from whatever application is requesting the resolution, intodnsmasq
, and ifdnsmasq
doesn't know the IP address or has had a cached entry expire, would then pass the DNS request to whatever upstream DNS server (for this example,8.8.8.8
or8.8.4.4
). You would then have to check Network Manager or thednsmasq
config to see where the 'upstream' DNS servers were.This is typical behavior in a graphical Ubuntu installed from the Desktop ISOs.
The default install from the Server ISOs, conversely, followed the traditional "update
/etc/resolv.conf
" method via theresolvconf
package and utilized/etc/resolv.conf
directly instead of communicating viadnsmasq
.18.04:
netplan
, andsystemd-resolved
With 18.04, the default DNS system is
systemd-resolved
. This operates like thednsmasq
of old does, except it does this for both Desktop and Server ISO installations currently. It also can integrate with Network Manager (used in the GUI environments for managing wifi and such), and with Netplan (which better handles ethernets)systemd-resolved
is handed fromnetplan
(servers or custom desktops) or Network Manager (default Desktop images) the list of DNS servers to send queries to (whether statically configured or configured via DHCP). Therefore, using the same example from above, a DNS query togoogle.com
would pass throughsystemd-resolved
's stub resolver which would either return the cached lookup value or pass it on to upstream DNS servers.This emulates the default behavior of
dnsmasq
, but also adds some additional lookup handling for how 'localhost', and other local-related addresses can be queried.With NetPlan, or Network Manager, you can get the list of upstream DNS servers through
systemd-resolved
with the following command:which will give you a bunch of output. The relevant section would look like this (taken from
chili555
's answer for expediency):Disclaimer: This is a well-educated guess and not a canonical, documented answer.
On my 18.04 system, the un-commented, that is, actually operational, section of /etc/resolv.conf says:
That is, I believe, a symptom of the use of dnsmasq, the system that caches DNS information. That means, I believe, look in the local cache first, before asking external nameservers.
But the local cache won’t contain any nameserver information about a website that has never been visited before. In that case, the system uses declared external DNS nameservers. These may be declared in /etc/network/interfaces in older systems; in /etc/netplan/*.yaml in newer systems or, in almost all desktop installations, in Network Manager.
In fact, /etc/resolv.conf tells us how the external nameservers can be found.
On my system, the report says, in part:
In short, I believe that DNS nameservers are declared in netplan to tell the system where to look if the DNS information is not found in the local cache.