Bug 11969 - issues with network-manager handling of resolv.conf when systemd-resolved is not enabled
Summary: issues with network-manager handling of resolv.conf when systemd-resolved is ...
Status: RESOLVED DUPLICATE of bug 11331
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: connectivity (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.7 M2
Assignee: Kai Kang
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-08-23 18:04 UTC by Carlos Alberto Lopez Perez
Modified: 2018-12-25 03:12 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Alberto Lopez Perez 2017-08-23 18:04:01 UTC
network-manager tries to auto-detect if systemd-resolved is enabled. When it detects that it skips updating the resolv.conf file.

Therefore if a false positive is triggered, this means DNS resolution will be broken on the system.

To do this detection it simply checks if the file /etc/resolv.conf points to any of this symlinks.

 - "/run/systemd/resolve/resolv.conf"
 - "/lib/systemd/resolv.conf"
 - "/usr/lib/systemd/resolv.conf"

So far so fine.

But then the issue is that the oe-core recipe is linking /etc/resolv.conf to /run/systemd/resolve/resolv.conf even when systemd-resolved is not enabled.
The reason for this is to allow updating resolv.conf on read-only-rootfs images. See oe-core commit 7f087f161e8942bcd35f88999dfca418f01cd7fa <https://git.io/v5L4d>

So the fix could be to symlink /etc/resolv.conf to a different path in /run when systemd-resolved is not enabled, right?

The issue is that after commit 00f1cc1a85ee736773442cd82f3225ff9f731e8c in meta-openembedded <https://git.io/v5L4S> /etc/resolv.conf always points to /etc/resolv-conf.systemd and at the same time the path /etc/resolv-conf.systemd is also checked by network-manager as one of the targets to detect.
Comment 1 Carlos Alberto Lopez Perez 2017-08-23 18:11:10 UTC
Option I see going forward:

Option A) Make NM follow symlinks (readlink -f) and use a different target path for the resolv.conf file at /run than the one used when resolved is enabled.

Option B) Use a different ALTERNATIVE_TARGET for the resolv-conf alternative link at /etc/resolv.conf (and at the same time try to use a different destination name in /run/resolv.conf just in case NM someday decides to follow symlinks readlink -f)
Comment 2 Jussi Kukkonen 2017-08-24 12:04:28 UTC
(In reply to comment #0)
> So the fix could be to symlink /etc/resolv.conf to a different path in /run
> when systemd-resolved is not enabled, right?
> 
> The issue is that after commit 00f1cc1a85ee736773442cd82f3225ff9f731e8c in
> meta-openembedded <https://git.io/v5L4S> /etc/resolv.conf always points to
> /etc/resolv-conf.systemd and at the same time the path
> /etc/resolv-conf.systemd is also checked by network-manager as one of the
> targets to detect.

I wonder why ${sysconfdir}/resolv-conf.systemd is created when resolved is not enabled?

Maxin, any ideas on this one?
Comment 3 Carlos Alberto Lopez Perez 2017-09-06 11:30:07 UTC
I have workarounded this by creating a NM config-file that changes the default DNS update method from "symlink" to "file".

* With the "symlink" method (the default), nm updates only /run/NetworkManager/resolv.conf and then updates the /etc/resolv.conf link under certain conditions (like resolv.conf not pointing to a systemd-resolved file)

* With update method "file", the content of /etc/resolv.conf is always updated (following any symlink) with the contents of the upstream DHCP DNS entries.


To set update method "file" this config-file can be used:


#/etc/NetworkManager/NetworkManager.conf
[main]
rc-manager=file
Comment 4 Ross Burton 2017-09-11 16:18:12 UTC
Reassigning Jussi's bugs.
Comment 5 Bastian Krause 2018-11-29 15:22:52 UTC
This is still an issue. Using NetworkManager with the default config does not work. Setting..

dns=default
rc-manager=file

..works, but this is not the desired solution.