diff options
-rw-r--r-- | man/NetworkManager.conf.xml | 12 | ||||
-rw-r--r-- | src/dns/nm-dns-manager.c | 35 |
2 files changed, 42 insertions, 5 deletions
diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml index 87cf001621..728947b3cb 100644 --- a/man/NetworkManager.conf.xml +++ b/man/NetworkManager.conf.xml @@ -331,15 +331,23 @@ no-auto-default=* after some time. This behavior can be modified passing the 'all-servers' or 'strict-order' options to dnsmasq (see the manual page for more details).</para> + <para><literal>systemd-resolved</literal>: NetworkManager will + push the DNS configuration to systemd-resolved</para> <para><literal>unbound</literal>: NetworkManager will talk to unbound and dnssec-triggerd, providing a "split DNS" configuration with DNSSEC support. <filename>/etc/resolv.conf</filename> will be managed by dnssec-trigger daemon.</para> - <para><literal>systemd-resolved</literal>: NetworkManager will - push the DNS configuration to systemd-resolved</para> <para><literal>none</literal>: NetworkManager will not modify resolv.conf. This implies <literal>rc-manager</literal> <literal>unmanaged</literal></para> + + <para>Note that the plugins <literal>dnsmasq</literal>, <literal>systemd-resolved</literal> + and <literal>unbound</literal> are caching local nameservers. + Hence, when NetworkManager writes <filename>&nmrundir;/resolv.conf</filename> + and <filename>/etc/resolv.conf</filename> (according to <literal>rc-manager</literal> + setting below), the name server there will be localhost only. + NetworkManager also writes a file <filename>&nmrundir;/no-stub-resolv.conf</filename> + that contains the original name servers, which are pushed to the DNS plugin.</para> </listitem> </varlistentry> diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 33a414831f..2755b26241 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -744,9 +744,36 @@ _read_link_cached (const char *path, gboolean *is_cached, char **cached) return (*cached = g_file_read_link (path, NULL)); } -#define MY_RESOLV_CONF NMRUNDIR "/resolv.conf" -#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp" -#define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager" +#define MY_RESOLV_CONF NMRUNDIR"/resolv.conf" +#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF".tmp" +#define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager" + +#define NO_STUB_RESOLV_CONF NMRUNDIR "/no-stub-resolv.conf" + +static void +update_resolv_conf_no_stub (NMDnsManager *self, + char **searches, + char **nameservers, + char **options) +{ + gs_free char *content = NULL; + GError *local = NULL; + + content = create_resolv_conf (searches, nameservers, options); + + if (!g_file_set_contents (NO_STUB_RESOLV_CONF, + content, + -1, + &local)) { + _LOGD ("update-resolv-no-stub: failure to write file: %s", + local->message); + g_error_free (local); + return; + } + + _LOGT ("update-resolv-no-stub: '%s' successfully written", + NO_STUB_RESOLV_CONF); +} static SpawnResult update_resolv_conf (NMDnsManager *self, @@ -1421,6 +1448,8 @@ update_dns (NMDnsManager *self, ; } + update_resolv_conf_no_stub (self, searches, nameservers, options); + /* If caching was successful, we only send 127.0.0.1 to /etc/resolv.conf * to ensure that the glibc resolver doesn't try to round-robin nameservers, * but only uses the local caching nameserver. |