From e05550c34c612136839942010c8c341d14154f32 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 29 Sep 2020 11:48:03 +0200 Subject: [PATCH 1/4] dns: slightly refactor rebuild_domain_lists() Centralize wildcard domain assignment in a single place. --- src/dns/nm-dns-manager.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index 87187d694..f11e10481 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -1326,8 +1326,8 @@ static void rebuild_domain_lists(NMDnsManager *self) { NMDnsIPConfigData *ip_data; - gs_unref_hashtable GHashTable *ht = NULL; - gboolean default_route_found = FALSE; + gs_unref_hashtable GHashTable *ht = NULL; + gs_unref_hashtable GHashTable *wildcard_entries = NULL; CList * head; head = _ip_config_lst_head(self); @@ -1337,8 +1337,9 @@ rebuild_domain_lists(NMDnsManager *self) if (!nm_ip_config_get_num_nameservers(ip_config)) continue; if (nm_ip_config_best_default_route_get(ip_config)) { - default_route_found = TRUE; - break; + if (!wildcard_entries) + wildcard_entries = g_hash_table_new(nm_direct_hash, NULL); + g_hash_table_add(wildcard_entries, ip_data); } } @@ -1373,13 +1374,13 @@ rebuild_domain_lists(NMDnsManager *self) /* Add wildcard lookup domain to connections with the default route. * If there is no default route, add the wildcard domain to all non-VPN * connections */ - if (default_route_found) { + if (wildcard_entries) { /* FIXME: this heuristic of which device has a default route does * not work with policy routing (as used by default with WireGuard). * We should have a more stable mechanism where an NMIPConfig indicates * whether it is suitable for certain operations (like having an automatically * added "~" domain). */ - if (nm_ip_config_best_default_route_get(ip_config)) + if (g_hash_table_contains(wildcard_entries, ip_data)) domains[num_dom1++] = "~"; } else { if (ip_data->ip_config_type != NM_DNS_IP_CONFIG_TYPE_VPN) From 9eba457426813c2d0ef77c396c79214bc7a67961 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 29 Sep 2020 12:06:11 +0200 Subject: [PATCH 2/4] core: add never-default field to NMIP{4,6}Config --- src/nm-ip4-config.c | 32 ++++++++++++++++++++++++++++++++ src/nm-ip4-config.h | 18 ++++++++++++++++++ src/nm-ip6-config.c | 21 +++++++++++++++++++++ src/nm-ip6-config.h | 3 +++ 4 files changed, 74 insertions(+) diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index ea08450d2..9d2b459d3 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -283,6 +283,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMIP4Config, typedef struct { bool metered : 1; + bool never_default : 1; guint32 mtu; int ifindex; NMIPConfigSource mtu_source; @@ -895,6 +896,8 @@ nm_ip4_config_merge_setting(NMIP4Config * self, nm_ip4_config_mdns_set(self, mdns); nm_ip4_config_llmnr_set(self, llmnr); + nm_ip4_config_set_never_default(self, nm_setting_ip_config_get_never_default(setting)); + g_object_thaw_notify(G_OBJECT(self)); } @@ -1122,6 +1125,11 @@ nm_ip4_config_merge(NMIP4Config * dst, nm_ip4_config_set_metered(dst, nm_ip4_config_get_metered(dst) || nm_ip4_config_get_metered(src)); + /* never default */ + nm_ip4_config_set_never_default(dst, + nm_ip4_config_get_never_default(dst) + || nm_ip4_config_get_never_default(src)); + /* DNS priority */ if (nm_ip4_config_get_dns_priority(src)) nm_ip4_config_set_dns_priority(dst, nm_ip4_config_get_dns_priority(src)); @@ -1856,6 +1864,12 @@ nm_ip4_config_replace(NMIP4Config *dst, const NMIP4Config *src, gboolean *releva has_minor_changes = TRUE; } + /* never default */ + if (src_priv->never_default != dst_priv->never_default) { + dst_priv->never_default = src_priv->never_default; + has_minor_changes = TRUE; + } + #if NM_MORE_ASSERTS /* config_equal does not compare *all* the fields, therefore, we might have has_minor_changes * regardless of config_equal. But config_equal must correspond to has_relevant_changes. */ @@ -2729,6 +2743,24 @@ nm_ip4_config_get_metered(const NMIP4Config *self) /*****************************************************************************/ +void +nm_ip4_config_set_never_default(NMIP4Config *self, gboolean never_default) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); + + priv->never_default = never_default; +} + +gboolean +nm_ip4_config_get_never_default(const NMIP4Config *self) +{ + const NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE(self); + + return priv->never_default; +} + +/*****************************************************************************/ + const NMPObject * nm_ip4_config_nmpobj_lookup(const NMIP4Config *self, const NMPObject *needle) { diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h index fcbdd7144..ccfca74c1 100644 --- a/src/nm-ip4-config.h +++ b/src/nm-ip4-config.h @@ -244,6 +244,9 @@ NMIPConfigSource nm_ip4_config_get_mtu_source(const NMIP4Config *self); void nm_ip4_config_set_metered(NMIP4Config *self, gboolean metered); gboolean nm_ip4_config_get_metered(const NMIP4Config *self); +void nm_ip4_config_set_never_default(NMIP4Config *self, gboolean never_default); +gboolean nm_ip4_config_get_never_default(const NMIP4Config *self); + const NMPObject *nm_ip4_config_nmpobj_lookup(const NMIP4Config *self, const NMPObject *needle); gboolean nm_ip4_config_nmpobj_remove(NMIP4Config *self, const NMPObject *needle); @@ -519,6 +522,21 @@ nm_ip_config_set_config_flags(NMIPConfig *self, NMIPConfigFlags flags, NMIPConfi mask); } +static inline gboolean +nm_ip_config_get_never_default(const NMIPConfig *self) +{ + _NM_IP_CONFIG_DISPATCH(self, nm_ip4_config_get_never_default, nm_ip6_config_get_never_default); +} + +static inline void +nm_ip_config_set_never_default(NMIPConfig *self, gboolean never_default) +{ + _NM_IP_CONFIG_DISPATCH_VOID(self, + nm_ip4_config_set_never_default, + nm_ip6_config_set_never_default, + never_default); +} + #define _NM_IP_CONFIG_DISPATCH_SET_OP(_return, dst, src, v4_func, v6_func, ...) \ G_STMT_START \ { \ diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index bd2508756..407aa1d60 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -64,6 +64,7 @@ typedef struct { NMDedupMultiIdxType idx_ip6_routes; }; NMIPConfigFlags config_flags; + bool never_default : 1; } NMIP6ConfigPrivate; struct _NMIP6Config { @@ -128,6 +129,24 @@ nm_ip6_config_set_privacy(NMIP6Config *self, NMSettingIP6ConfigPrivacy privacy) /*****************************************************************************/ +void +nm_ip6_config_set_never_default(NMIP6Config *self, gboolean never_default) +{ + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); + + priv->never_default = never_default; +} + +gboolean +nm_ip6_config_get_never_default(const NMIP6Config *self) +{ + const NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE(self); + + return priv->never_default; +} + +/*****************************************************************************/ + const NMDedupMultiHeadEntry * nm_ip6_config_lookup_addresses(const NMIP6Config *self) { @@ -635,6 +654,8 @@ nm_ip6_config_merge_setting(NMIP6Config * self, if (priority) nm_ip6_config_set_dns_priority(self, priority); + nm_ip6_config_set_never_default(self, nm_setting_ip_config_get_never_default(setting)); + g_object_thaw_notify(G_OBJECT(self)); } diff --git a/src/nm-ip6-config.h b/src/nm-ip6-config.h index 49046dc81..a5a28a1af 100644 --- a/src/nm-ip6-config.h +++ b/src/nm-ip6-config.h @@ -175,6 +175,9 @@ const char *nm_ip6_config_get_dns_option(const NMIP6Config *self, guint i); void nm_ip6_config_set_dns_priority(NMIP6Config *self, int priority); int nm_ip6_config_get_dns_priority(const NMIP6Config *self); +void nm_ip6_config_set_never_default(NMIP6Config *self, gboolean never_default); +gboolean nm_ip6_config_get_never_default(const NMIP6Config *self); + const NMPObject *nm_ip6_config_nmpobj_lookup(const NMIP6Config *self, const NMPObject *needle); gboolean nm_ip6_config_nmpobj_remove(NMIP6Config *self, const NMPObject *needle); From cefd5ee3229d33de8b474852deb5a2044e378b04 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 29 Sep 2020 13:42:02 +0200 Subject: [PATCH 3/4] dns: add wildcard domain to VPNs with never-default=no and no domains If a VPN has never-default=no but doesn't get a default route (this can happen for example when the server pushes routes with openconnect), and there are no search domains, then the name servers pushed by the server would be unused. It is preferable in this case to use the VPN DNS server for all queries. https://bugzilla.redhat.com/show_bug.cgi?id=1863041 --- src/dns/nm-dns-manager.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index f11e10481..635e94f69 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -1332,11 +1332,28 @@ rebuild_domain_lists(NMDnsManager *self) head = _ip_config_lst_head(self); c_list_for_each_entry (ip_data, head, ip_config_lst) { - NMIPConfig *ip_config = ip_data->ip_config; + NMIPConfig *ip_config = ip_data->ip_config; + gboolean add_wildcard = FALSE; if (!nm_ip_config_get_num_nameservers(ip_config)) continue; - if (nm_ip_config_best_default_route_get(ip_config)) { + if (nm_ip_config_best_default_route_get(ip_config)) + add_wildcard = TRUE; + else { + /* If a VPN has never-default=no but doesn't get a default + * route (this can happen for example when the server + * pushes routes with openconnect), and there are no + * search or routing domains, then the name servers pushed + * by the server would be unused. It is preferable in this + * case to use the VPN DNS server for all queries. */ + if (ip_data->ip_config_type == NM_DNS_IP_CONFIG_TYPE_VPN + && !nm_ip_config_get_never_default(ip_data->ip_config) + && nm_ip_config_get_num_searches(ip_data->ip_config) == 0 + && nm_ip_config_get_num_domains(ip_data->ip_config) == 0) + add_wildcard = TRUE; + } + + if (add_wildcard) { if (!wildcard_entries) wildcard_entries = g_hash_table_new(nm_direct_hash, NULL); g_hash_table_add(wildcard_entries, ip_data); From af13081bec8bf5cbe961df4c4577a7e4c7b14e97 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 1 Oct 2020 09:54:30 +0200 Subject: [PATCH 4/4] dns: change default DNS priority of VPNs to -50 Change the default DNS priority of VPNs to -50, to avoid leaking queries out of full-tunnel VPNs. This is a change in behavior. In particular: - when using dns=default (i.e. no split-dns) before this patch both VPN and the local name server were added (in this order) to resolv.conf; the result was that depending on resolv.conf options and resolver implementation, the name servers were tried in a certain manner which does not prevent DNS leaks. With this change, only the VPN name server is added to resolv.conf. - When using a split-dns plugin (systemd-resolved or dnsmasq), before this patch the full-tunnel VPN would get all queries except those ending in a local domain, that would instead be directed to the local server. After this patch, the VPN gets all queries. To revert to the old behavior, set the DNS priority to 50 in the connection profile. --- NEWS | 5 +++++ clients/common/settings-docs.h.in | 4 ++-- libnm-core/nm-setting-ip-config.c | 2 +- src/dns/nm-dns-manager.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4229a6010..eb698d8b7 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,11 @@ Overview of changes since NetworkManager-1.26 * Fix building NetworkManager with LTO (Link Time Optimization). * Reformat code using spaces instead of tabs. Also, the entire C source code is now formatted with "clang-format" (version 11.0). +* Change the default DNS priority for VPNs from 50 to -50. This is a + change in behavior and means that when connecting to a VPN with the + default route, DNS queries will never leak to local resolvers. To + restore the old behavior, set the DNS priority of the connection to + 50. ============================================= NetworkManager-1.26 diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in index 58fc92e13..5b9362724 100644 --- a/clients/common/settings-docs.h.in +++ b/clients/common/settings-docs.h.in @@ -234,7 +234,7 @@ #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER N_("The Vendor Class Identifier DHCP option (60). Special characters in the data string may be escaped using C-style escapes, nevertheless this property cannot contain nul bytes. If the per-profile value is unspecified (the default), a global connection default gets consulted. If still unspecified, the DHCP option is not sent to the server. Since 1.28") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS N_("Array of IP addresses of DNS servers.") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_OPTIONS N_("Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties. The currently supported options are \"attempts\", \"debug\", \"edns0\", \"inet6\", \"ip6-bytestring\", \"ip6-dotint\", \"ndots\", \"no-check-names\", \"no-ip6-dotint\", \"no-reload\", \"no-tld-query\", \"rotate\", \"single-request\", \"single-request-reopen\", \"timeout\", \"trust-ad\", \"use-vc\". The \"trust-ad\" setting is only honored if the profile contributes name servers to resolv.conf, and if all contributing profiles have \"trust-ad\" enabled.") -#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_PRIORITY N_("DNS servers priority. The relative priority for DNS servers specified by this setting. A lower numerical value is better (higher priority). Negative values have the special effect of excluding other configurations with a greater numerical priority value; so in presence of at least one negative priority, only DNS servers from connections with the lowest priority value will be used. To avoid all DNS leaks, set the priority of the profile that should be used to the most negative value of all active connections profiles. Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs (including WireGuard) and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When multiple devices have configurations with the same priority, VPNs will be considered first, then devices with the best (lowest metric) default route and then all other devices. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. Note that commonly the resolver tries name servers in /etc/resolv.conf in the order listed, proceeding with the next server in the list on failure. See for example the \"rotate\" option of the dns-options setting. If there are any negative DNS priorities, then only name servers from the devices with that lowest priority will be considered. When using a DNS resolver that supports Conditional Forwarding or Split DNS (with dns=dnsmasq or dns=systemd-resolved settings), each connection is used to query domains in its search list. The search domains determine which name servers to ask, and the DNS priority is used to prioritize name servers based on the domain. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the best priority (lowest numerical value) wins. If a sub domain is configured on another interface it will be accepted regardless the priority, unless parent domain on the other interface has a negative priority, which causes the sub domain to be shadowed. With Split DNS one can avoid undesired DNS leaks by properly configuring DNS priorities and the search domains, so that only name servers of the desired interface are configured.") +#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_PRIORITY N_("DNS servers priority. The relative priority for DNS servers specified by this setting. A lower numerical value is better (higher priority). Negative values have the special effect of excluding other configurations with a greater numerical priority value; so in presence of at least one negative priority, only DNS servers from connections with the lowest priority value will be used. To avoid all DNS leaks, set the priority of the profile that should be used to the most negative value of all active connections profiles. Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to -50 for VPNs (including WireGuard) and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When multiple devices have configurations with the same priority, VPNs will be considered first, then devices with the best (lowest metric) default route and then all other devices. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. Note that commonly the resolver tries name servers in /etc/resolv.conf in the order listed, proceeding with the next server in the list on failure. See for example the \"rotate\" option of the dns-options setting. If there are any negative DNS priorities, then only name servers from the devices with that lowest priority will be considered. When using a DNS resolver that supports Conditional Forwarding or Split DNS (with dns=dnsmasq or dns=systemd-resolved settings), each connection is used to query domains in its search list. The search domains determine which name servers to ask, and the DNS priority is used to prioritize name servers based on the domain. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the best priority (lowest numerical value) wins. If a sub domain is configured on another interface it will be accepted regardless the priority, unless parent domain on the other interface has a negative priority, which causes the sub domain to be shadowed. With Split DNS one can avoid undesired DNS leaks by properly configuring DNS priorities and the search domains, so that only name servers of the desired interface are configured.") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_SEARCH N_("Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names. When using a DNS plugin that supports Conditional Forwarding or Split DNS, then the search domains specify which name servers to query. This makes the behavior different from running with plain /etc/resolv.conf. For more information see also the dns-priority setting.") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_GATEWAY N_("The gateway associated with this configuration. This is only meaningful if \"addresses\" is also set. The gateway's main purpose is to control the next hop of the standard default route on the device. Hence, the gateway property conflicts with \"never-default\" and will be automatically dropped if the IP configuration is set to never-default. As an alternative to set the gateway, configure a static default route with /0 as prefix length.") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured name servers and search domains are ignored and only name servers and search domains specified in the \"dns\" and \"dns-search\" properties, if any, are used.") @@ -257,7 +257,7 @@ #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_TIMEOUT N_("A timeout for a DHCP transaction in seconds. If zero (the default), a globally configured default is used. If still unspecified, a device specific timeout is used (usually 45 seconds). Set to 2147483647 (MAXINT32) for infinity.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS N_("Array of IP addresses of DNS servers.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_OPTIONS N_("Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties. The currently supported options are \"attempts\", \"debug\", \"edns0\", \"inet6\", \"ip6-bytestring\", \"ip6-dotint\", \"ndots\", \"no-check-names\", \"no-ip6-dotint\", \"no-reload\", \"no-tld-query\", \"rotate\", \"single-request\", \"single-request-reopen\", \"timeout\", \"trust-ad\", \"use-vc\". The \"trust-ad\" setting is only honored if the profile contributes name servers to resolv.conf, and if all contributing profiles have \"trust-ad\" enabled.") -#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_PRIORITY N_("DNS servers priority. The relative priority for DNS servers specified by this setting. A lower numerical value is better (higher priority). Negative values have the special effect of excluding other configurations with a greater numerical priority value; so in presence of at least one negative priority, only DNS servers from connections with the lowest priority value will be used. To avoid all DNS leaks, set the priority of the profile that should be used to the most negative value of all active connections profiles. Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs (including WireGuard) and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When multiple devices have configurations with the same priority, VPNs will be considered first, then devices with the best (lowest metric) default route and then all other devices. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. Note that commonly the resolver tries name servers in /etc/resolv.conf in the order listed, proceeding with the next server in the list on failure. See for example the \"rotate\" option of the dns-options setting. If there are any negative DNS priorities, then only name servers from the devices with that lowest priority will be considered. When using a DNS resolver that supports Conditional Forwarding or Split DNS (with dns=dnsmasq or dns=systemd-resolved settings), each connection is used to query domains in its search list. The search domains determine which name servers to ask, and the DNS priority is used to prioritize name servers based on the domain. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the best priority (lowest numerical value) wins. If a sub domain is configured on another interface it will be accepted regardless the priority, unless parent domain on the other interface has a negative priority, which causes the sub domain to be shadowed. With Split DNS one can avoid undesired DNS leaks by properly configuring DNS priorities and the search domains, so that only name servers of the desired interface are configured.") +#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_PRIORITY N_("DNS servers priority. The relative priority for DNS servers specified by this setting. A lower numerical value is better (higher priority). Negative values have the special effect of excluding other configurations with a greater numerical priority value; so in presence of at least one negative priority, only DNS servers from connections with the lowest priority value will be used. To avoid all DNS leaks, set the priority of the profile that should be used to the most negative value of all active connections profiles. Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to -50 for VPNs (including WireGuard) and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When multiple devices have configurations with the same priority, VPNs will be considered first, then devices with the best (lowest metric) default route and then all other devices. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. Note that commonly the resolver tries name servers in /etc/resolv.conf in the order listed, proceeding with the next server in the list on failure. See for example the \"rotate\" option of the dns-options setting. If there are any negative DNS priorities, then only name servers from the devices with that lowest priority will be considered. When using a DNS resolver that supports Conditional Forwarding or Split DNS (with dns=dnsmasq or dns=systemd-resolved settings), each connection is used to query domains in its search list. The search domains determine which name servers to ask, and the DNS priority is used to prioritize name servers based on the domain. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the best priority (lowest numerical value) wins. If a sub domain is configured on another interface it will be accepted regardless the priority, unless parent domain on the other interface has a negative priority, which causes the sub domain to be shadowed. With Split DNS one can avoid undesired DNS leaks by properly configuring DNS priorities and the search domains, so that only name servers of the desired interface are configured.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS_SEARCH N_("Array of DNS search domains. Domains starting with a tilde ('~') are considered 'routing' domains and are used only to decide the interface over which a query must be forwarded; they are not used to complete unqualified host names. When using a DNS plugin that supports Conditional Forwarding or Split DNS, then the search domains specify which name servers to query. This makes the behavior different from running with plain /etc/resolv.conf. For more information see also the dns-priority setting.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_GATEWAY N_("The gateway associated with this configuration. This is only meaningful if \"addresses\" is also set. The gateway's main purpose is to control the next hop of the standard default route on the device. Hence, the gateway property conflicts with \"never-default\" and will be automatically dropped if the IP configuration is set to never-default. As an alternative to set the gateway, configure a static default route with /0 as prefix length.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS N_("When \"method\" is set to \"auto\" and this property to TRUE, automatically configured name servers and search domains are ignored and only name servers and search domains specified in the \"dns\" and \"dns-search\" properties, if any, are used.") diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index 7b6624d82..e884066f8 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -5913,7 +5913,7 @@ nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) * to the most negative value of all active connections profiles. * * Zero selects a globally configured default value. If the latter is missing - * or zero too, it defaults to 50 for VPNs (including WireGuard) and 100 for + * or zero too, it defaults to -50 for VPNs (including WireGuard) and 100 for * other connections. * * Note that the priority is to order DNS settings for multiple active diff --git a/src/dns/nm-dns-manager.h b/src/dns/nm-dns-manager.h index 3f90dc877..f91d1556b 100644 --- a/src/dns/nm-dns-manager.h +++ b/src/dns/nm-dns-manager.h @@ -22,7 +22,7 @@ typedef enum { enum { NM_DNS_PRIORITY_DEFAULT_NORMAL = 100, - NM_DNS_PRIORITY_DEFAULT_VPN = 50, + NM_DNS_PRIORITY_DEFAULT_VPN = -50, }; struct _NMDnsConfigData;