]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp-server: make empty string to DNS= or friends clear previously specified...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 1 Feb 2022 22:20:25 +0000 (07:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Feb 2022 01:02:57 +0000 (10:02 +0900)
man/systemd.network.xml
src/network/networkd-dhcp-server.c

index 71f5219363ee7814927e3e8f6e65649b572436bc..af431e4f2c93da2379eabc1e2c1706787067b64a 100644 (file)
@@ -2561,17 +2561,21 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
         handed out to clients shall contain DNS server information. Defaults to <literal>yes</literal>.
         The DNS servers to pass to clients may be configured with the <varname>DNS=</varname> option,
         which takes a list of IPv4 addresses, or special value <literal>_server_address</literal> which
-        will be converted to the address used by the DHCP server. If the <varname>EmitDNS=</varname>
-        option is enabled but no servers configured, the servers are automatically propagated from an
-        "uplink" interface that has appropriate servers set. The "uplink" interface is determined by
-        the default route of the system with the highest priority. Note that this information is
-        acquired at the time the lease is handed out, and does not take uplink interfaces into account
-        that acquire DNS server information at a later point. If no suitable uplink interface is found
-        the DNS server data from <filename>/etc/resolv.conf</filename> is used. Also, note that the
-        leases are not refreshed if the uplink network configuration changes. To ensure clients
-        regularly acquire the most current uplink DNS server information, it is thus advisable to
-        shorten the DHCP lease time via <varname>MaxLeaseTimeSec=</varname> described above.
-        </para></listitem>
+        will be converted to the address used by the DHCP server.</para>
+
+        <para>If the <varname>EmitDNS=</varname> option is enabled but no servers configured, the
+        servers are automatically propagated from an "uplink" interface that has appropriate servers
+        set. The "uplink" interface is determined by the default route of the system with the highest
+        priority. Note that this information is acquired at the time the lease is handed out, and does
+        not take uplink interfaces into account that acquire DNS server information at a later point.
+        If no suitable uplink interface is found the DNS server data from
+        <filename>/etc/resolv.conf</filename> is used. Also, note that the leases are not refreshed if
+        the uplink network configuration changes. To ensure clients regularly acquire the most current
+        uplink DNS server information, it is thus advisable to shorten the DHCP lease time via
+        <varname>MaxLeaseTimeSec=</varname> described above.</para>
+
+        <para>This setting can be specified multiple times. If an empty string is specified, then all
+        DNS servers specified earlier are cleared.</para></listitem>
       </varlistentry>
 
       <varlistentry>
index 32a129a6f6f34d045a5bc4d99d7f4af6d2c62c1f..48e919ce93175127de1bc024343267fe191888aa 100644 (file)
@@ -634,6 +634,12 @@ int config_parse_dhcp_server_emit(
         assert(emit);
         assert(rvalue);
 
+        if (isempty(rvalue)) {
+                emit->addresses = mfree(emit->addresses);
+                emit->n_addresses = 0;
+                return 0;
+        }
+
         for (const char *p = rvalue;;) {
                 _cleanup_free_ char *w = NULL;
                 union in_addr_union a;