diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 75a581816d..864dd6500b 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1491,8 +1491,9 @@ UseGateway= - When true (the default), the gateway will be requested from the DHCP server and added to the - routing table with a metric of 1024, and a scope of "link". + When true, the gateway will be requested from the DHCP server and added to the routing table with a + metric of 1024, and a scope of "link". When unset, the value specified with + is used. diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 9597176b1c..1a37c4ac9e 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -164,7 +164,7 @@ DHCPv4.UseMTU, config_parse_bool, DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname) DHCPv4.UseDomains, config_parse_dhcp_use_domains, 0, offsetof(Network, dhcp_use_domains) DHCPv4.UseRoutes, config_parse_bool, 0, offsetof(Network, dhcp_use_routes) -DHCPv4.UseGateway, config_parse_bool, 0, offsetof(Network, dhcp_use_gateway) +DHCPv4.UseGateway, config_parse_tristate, 0, offsetof(Network, dhcp_use_gateway) DHCPv4.RequestOptions, config_parse_dhcp_request_options, 0, 0 DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize) DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 9edf9e1561..d9646a21cb 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -267,6 +267,9 @@ int network_verify(Network *network) { network->dhcp_use_mtu = false; } + if (network->dhcp_use_gateway < 0) + network->dhcp_use_gateway = network->dhcp_use_routes; + if (network->dhcp_critical >= 0) { if (network->keep_configuration >= 0) log_warning("%s: Both KeepConfiguration= and deprecated CriticalConnection= are set. " @@ -385,7 +388,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi .dhcp_use_dns = true, .dhcp_use_hostname = true, .dhcp_use_routes = true, - .dhcp_use_gateway = true, + .dhcp_use_gateway = -1, /* NOTE: this var might be overwritten by network_apply_anonymize_if_set */ .dhcp_send_hostname = true, .dhcp_send_release = true, diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 240f6689dd..2665686143 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -110,7 +110,7 @@ struct Network { bool dhcp_use_sip; bool dhcp_use_mtu; bool dhcp_use_routes; - bool dhcp_use_gateway; + int dhcp_use_gateway; bool dhcp_use_timezone; bool rapid_commit; bool dhcp_use_hostname;