From: Yu Watanabe Date: Tue, 1 Feb 2022 22:20:25 +0000 (+0900) Subject: network: dhcp-server: make empty string to DNS= or friends clear previously specified... X-Git-Tag: v251-rc1~380 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=faa1b3c6c415abb201d03ab1c46f9e89100ab9b2;p=thirdparty%2Fsystemd.git network: dhcp-server: make empty string to DNS= or friends clear previously specified servers --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 71f5219363e..af431e4f2c9 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -2561,17 +2561,21 @@ Token=prefixstable:2002:da8:1:: handed out to clients shall contain DNS server information. Defaults to yes. The DNS servers to pass to clients may be configured with the DNS= option, which takes a list of IPv4 addresses, or special value _server_address which - will be converted to the address used by the DHCP server. If the EmitDNS= - 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 /etc/resolv.conf 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 MaxLeaseTimeSec= described above. - + will be converted to the address used by the DHCP server. + + If the EmitDNS= 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 + /etc/resolv.conf 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 + MaxLeaseTimeSec= described above. + + This setting can be specified multiple times. If an empty string is specified, then all + DNS servers specified earlier are cleared. diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c index 32a129a6f6f..48e919ce931 100644 --- a/src/network/networkd-dhcp-server.c +++ b/src/network/networkd-dhcp-server.c @@ -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;