[systemd-devel] systemd-resolved service ignores UseDNS=false

David Herrmann dh.herrmann at gmail.com
Tue Apr 7 03:42:35 PDT 2015


Hi

On Wed, Mar 25, 2015 at 4:20 AM, Mikhail Morfikov <mmorfikov at gmail.com> wrote:
> In the systemd-resolved manual we can read something like this:
>
>   The DNS servers contacted are determined from the global settings in
>   resolved.conf(5), the per-link static settings in .network files, and
>   the per-link dynamic settings received over DHCP.
>
> 1. Let's say that I have set all the three settings, which one will be
> applied?
>
> 2. If I set the global settings via the /etc/systemd/resolved.conf file,
> for instance:
>
> [Resolve]
> DNS=127.0.2.1
> FallbackDNS=208.67.222.222 208.67.220.220
>
> will this local resolver be used all the time, even when dhcp
> server sends an ip address of other resolver in the network to
> the client?
>
> I don't know how that is supposed to work, but it looks like it doesn't
> work in the way I thought it would. So I added some entries to this
> /etc/systemd/network/50-bond0-dhcp.network file:
>
> [Match]
> Name=bond0
>
> [Network]
> Description=Bonded network
> DHCP=ipv4
> LinkLocalAddressing=no
> DNS=127.0.2.1
> IPForward=true
>
> [DHCP]
> UseDNS=false
> UseMTU=false
> SendHostname=true
> UseHostname=false
> UseDomains=true
> UseRoutes=true
> CriticalConnection=true
> RequestBroadcast=true
>
> And according to the systemd-networkd manual:
>
>   DNS -- a DNS server address, which must be in the format described
>   in inet_pton(3). This option may be specified more than once.
>
>   UseDNS -- when true (the default), the DNS servers received from the
>   DHCP server will be used and take precedence over any statically
>   configured ones.
>
> (btw, the link to inet_pton is dead)
>
> So UseDNS is set to false, and I thought the system will be using
> the local resolver, but it sometimes uses the local settings and
> sometimes not -- it depends on restarting the systemd-resolved
> service, for example:
>
> # ls -al /etc/resolv.conf
> lrwxrwxrwx 1 root root 32 2015-02-27 23:52:39 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
>
> # cat /etc/resolv.conf
> nameserver 127.0.2.1
> nameserver 192.168.1.1
> search mhouse.lh
>
> # systemctl restart systemd-resolved.service
> # cat /etc/resolv.conf
> nameserver 192.168.1.1
> nameserver 127.0.2.1
> search mhouse.lh
>
> (I've cut the comments for readability)
>
> As you can see, the two resolvers just switched, and it seems that my
> system tries to use the 192.168.1.1 , but I disabled it for testing on
> my router. After I ping a domain, I have 10s lag, and then ping go there
> and back, so it falls back to the local resolver.
>
> 3. Shouldn't there be just one resolver in the /etc/resolv.conf file?

I'm not 100% sure, but reading networkd-code I'd say there's something
going wrong. It should never store the DHCP DNS servers if UseDNS is
false. Therefore, resolved should never see them.

Cat you look into /run/systemd/netif/links/* and paste the content?

Thanks
David


More information about the systemd-devel mailing list