GNOME Bugzilla – Bug 779269
DNS info not pushed to systemd-resolved if /etc/resolv.conf is a relative symlink
Last modified: 2017-05-13 15:03:02 UTC
I found that NM wasn't talking to systemd-resolved because I have: $ readlink /etc/resolv.conf ../run/systemd/resolve/resolv.conf Once I changed the symlink target to use an absolute path, NM correctly started pushing DNS server info to systemd-resolved. The following Python code will resolve the symlink with glib. If you think it is sane, I can send a patch to make the _resolvconf_resolved_managed function do the same. >>> from io.repository import Gio >>> f = Gio.File.new_for_path('/etc/resolv.conf') >>> i = query_info(Gio.FILE_ATTRIBUTE_STANDARD_IS_SYMLINK + ',' + Gio.FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, None) >>> f.get_parent().resolve_relative_path(i.get_symlink_target()).get_path() '/run/systemd/resolve/resolv.conf' Alternatively, the wording in the documentation could make it clear that systemd-resolved only becomes the default dns backend if /etc/resolv.conf is a symlink that points to networkd's resolv.conf file as an absolute path.
(In reply to Sam Morris from comment #0) > I found that NM wasn't talking to systemd-resolved because I have: > > $ readlink /etc/resolv.conf > ../run/systemd/resolve/resolv.conf > > Once I changed the symlink target to use an absolute path, NM correctly > started pushing DNS server info to systemd-resolved. > > The following Python code will resolve the symlink with glib. If you think > it is sane, I can send a patch to make the _resolvconf_resolved_managed > function do the same. Yes please, I think we should consider the absolute path when comparing the link.
While working on this I realised that it's easier to simply stat /etc/resolv.conf, and compare its st_dev and st_ino to those of each of the resolved_paths until we get a match. This way the kernel takes care of resolving the symlinks for us. I've submitted a pull request on Github: https://github.com/NetworkManager/NetworkManager/pull/16 The same comparison can be performed using gio, but it's a lot more complex: https://github.com/NetworkManager/NetworkManager/compare/master...yrro:networkd-resconf-fileid
I think, this bug affects me as well on Kubuntu 17.04, NetworkManager 1.4.4. I have an OpenVPN connection with a static DNS IP and search domain specified in the connection settings. Sometimes (in ~50% cases) these settings are not forwarded to systemd-resolved when the connection is established. /etc/resolv.conf is a symlink to ../run/resolvconf/resolv.conf.
The detection of systemd-networkd was improved: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=fae84b16f850c8a9d6a5f5c4bee1c162debb8dec Note, that as workaround, you can always explicitly configure the dns-plugin via [main] dns=systemd-resolved (but of course, detection based on the symlink is better).
Setting "dns=systemd-resolved" does not help. I still sometimes get DNS params not pushed to systemd-resolved after the VPN connection is established.
(In reply to andysem from comment #5) > Setting "dns=systemd-resolved" does not help. I still sometimes get DNS > params not pushed to systemd-resolved after the VPN connection is > established. then your issue is not the same as this bug.