NetworkManager/src/core/dns
Íñigo Huguet 1cba0a3cca dns: make [global-dns] to overwrite configs from connections
According to the documentation, settings from [global-dns] (searches and
options) are always merged with those from connections. However this was
not happening if no [global-dns-domain-*] exists, in which case
connections were ignored. This happened because in the past both global
sections must de defined or undefined. When this was changed to allow
defining only [global-dns], allowing it in the function that generates
the resolv.conf file was forgotten. Fix that now.

Anyway, merging these configs doesn't make much sense. The searches and
options defined in connections probably make sense only for the nameservers
defined in that same connection.

Because of this, make the following change: if global nameservers are
defined, use searches and options from [global-dns] only, because those
defined in connections may not make sense for the global nameservers. If
[global-dns] is missing, assume an empty [global-dns] section.

Also, if no global nameservers are defined, but [global-dns] is, make
that it overwrites the searches and options defined in connections. This
is not ideal, but none of the alternatives is better and at least this
is easy to remember.

So, the resulting rules from above are:
- If [global-dns] is defined, it always overwrite searches and options
  from connections.
- If [global-dns-domain-*] is defined, it always overwrite nameservers
  from connections. It overwrites searches and options too.

Fixes: 1f0d1d78d2 ('dns-manager: always apply options from [global-dns]')
Fixes: f57a848da5 ('man: update documentation about global DNS configuration')
2025-09-11 10:25:36 +00:00
..
nm-dns-dnsconfd.c dns: return error from nm_dns_uri_parse() 2025-08-14 09:40:26 +02:00
nm-dns-dnsconfd.h dns: Add dnsconfd DNS plugin 2025-01-29 14:41:47 +01:00
nm-dns-dnsmasq.c core, libnm: support per-connection DNS URIs 2025-01-07 15:41:44 +01:00
nm-dns-dnsmasq.h all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal uses 2022-12-16 10:55:03 +01:00
nm-dns-manager.c dns: make [global-dns] to overwrite configs from connections 2025-09-11 10:25:36 +00:00
nm-dns-manager.h emit DNS CONFIG_CHANGED signal even dns=none 2023-09-26 15:00:32 +08:00
nm-dns-plugin.c dns: add "update-pending" state to NMDnsPlugin 2022-04-15 09:04:29 +02:00
nm-dns-plugin.h all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal uses 2022-12-16 10:55:03 +01:00
nm-dns-systemd-resolved.c dns: return error from nm_dns_uri_parse() 2025-08-14 09:40:26 +02:00
nm-dns-systemd-resolved.h all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal uses 2022-12-16 10:55:03 +01:00