core: support automatically adding DNS routes

When the "ipvX.routed-dns" property is set to true, add a route for
each DNS server via the current interface. The feature works in the
following way.

A new routing rule is created ("priority $PRIO not fwmark $MARK lookup
$TABLE") where $PRIO, $MARK and $TABLE are fixed values and are the
same for all interfaces. This rule is evaluated before standard rules
and tries to look up routes in table $TABLE, where NM adds the routes
to DNS servers.

To determine the next-hop to the name server, NM issues a RTM_GETROUTE
netlink request to kernel, specifying to return the route via the
current interface. In order to avoid results from $TABLE, NM also sets
the fwmark as $MARK in the request.
This commit is contained in:
Beniamino Galvani
2024-10-03 15:22:51 +02:00
parent 5122ba48ef
commit 5449b18a94
5 changed files with 187 additions and 3 deletions

View File

@@ -937,6 +937,9 @@ ipv6.ip6-privacy=0
<term><varname>ip-tunnel.mtu</varname></term>
<listitem><para>If configured explicitly to 0, the MTU is not reconfigured during device activation unless it is required due to IPv6 constraints. If left unspecified, a DHCP/IPv6 SLAAC provided value is used or a default of 1500.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ipv4.routed-dns</varname></term>
</varlistentry>
<varlistentry>
<term><varname>ipv4.dad-timeout</varname></term>
</varlistentry>
@@ -993,6 +996,9 @@ ipv6.ip6-privacy=0
removes extraneous routes from the tables.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ipv6.routed-dns</varname></term>
</varlistentry>
<varlistentry>
<term><varname>ipv6.addr-gen-mode</varname></term>
<listitem><para>If the per-profile setting is either "default" or "default-or-eui64", the