diff options
author | Christian Breunig <christian@breunig.cc> | 2023-01-15 19:53:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-15 19:53:58 +0100 |
commit | 598dcad7237d49861ca6216deea254b7c942241f (patch) | |
tree | 5133e57907702aa5f214ca80a1be6048aaa2b591 | |
parent | 80a0cee308c33d8cdc64014eb47558f48cc90f23 (diff) | |
parent | 407d469be919f1841fb3bac49947c758c4a24b67 (diff) | |
download | vyos-1x-598dcad7237d49861ca6216deea254b7c942241f.tar.gz vyos-1x-598dcad7237d49861ca6216deea254b7c942241f.zip |
Merge pull request #1670 from vfreex/dhcp-v6-only-option-1.3
[1.3] T4832: dhcp: Add dhcp option to signal IPv6-only support (RFC 8925)
-rw-r--r-- | data/templates/dhcp-server/dhcpd.conf.tmpl | 7 | ||||
-rw-r--r-- | interface-definitions/dhcp-server.xml.in | 13 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_service_dhcp-server.py | 3 |
3 files changed, 23 insertions, 0 deletions
diff --git a/data/templates/dhcp-server/dhcpd.conf.tmpl b/data/templates/dhcp-server/dhcpd.conf.tmpl index 0f0c622d4..13272ade3 100644 --- a/data/templates/dhcp-server/dhcpd.conf.tmpl +++ b/data/templates/dhcp-server/dhcpd.conf.tmpl @@ -22,6 +22,7 @@ ddns-update-style {{ 'interim' if dynamic_dns_update is defined else 'none' }}; option rfc3442-static-route code 121 = array of integer 8; option windows-static-route code 249 = array of integer 8; option wpad-url code 252 = text; +option rfc8925-ipv6-only-preferred code 108 = unsigned integer 32; {% if global_parameters is defined and global_parameters is not none %} # The following {{ global_parameters | length }} line(s) have been added as @@ -78,6 +79,9 @@ shared-network {{ network }} { {% if network_config.ntp_server is defined and network_config.ntp_server is not none %} option ntp-servers {{ network_config.ntp_server | join(', ') }}; {% endif %} +{% if network_config.ntp_server is defined and network_config.ntp_server is not none %} + option ntp-servers {{ network_config.ntp_server | join(', ') }}; +{% endif %} {% if network_config.ping_check is defined %} ping-check true; {% endif %} @@ -118,6 +122,9 @@ shared-network {{ network }} { {% if subnet_config.wins_server is defined and subnet_config.wins_server is not none %} option netbios-name-servers {{ subnet_config.wins_server | join(', ') }}; {% endif %} +{% if subnet_config.ipv6_only_preferred is defined and subnet_config.ipv6_only_preferred is not none %} + option rfc8925-ipv6-only-preferred {{ subnet_config.ipv6_only_preferred }}; +{% endif %} {% if subnet_config.static_route is defined and subnet_config.static_route is not none %} {% set static_default_route = '' %} {% if subnet_config.default_router and subnet_config.default_router is not none %} diff --git a/interface-definitions/dhcp-server.xml.in b/interface-definitions/dhcp-server.xml.in index 8c10ccf99..c1f2fe2fd 100644 --- a/interface-definitions/dhcp-server.xml.in +++ b/interface-definitions/dhcp-server.xml.in @@ -357,6 +357,19 @@ </leafNode> </children> </tagNode > + <leafNode name="ipv6-only-preferred"> + <properties> + <help>Disable IPv4 on IPv6 only hosts (RFC 8925)</help> + <valueHelp> + <format>u32</format> + <description>Seconds</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 0-4294967295"/> + </constraint> + <constraintErrorMessage>Seconds must be between 0 and 4294967295 (49 days)</constraintErrorMessage> + </properties> + </leafNode> <leafNode name="subnet-parameters"> <properties> <help>Additional subnet parameters for DHCP server. You must diff --git a/smoketest/scripts/cli/test_service_dhcp-server.py b/smoketest/scripts/cli/test_service_dhcp-server.py index 9adb9c042..8568d96eb 100755 --- a/smoketest/scripts/cli/test_service_dhcp-server.py +++ b/smoketest/scripts/cli/test_service_dhcp-server.py @@ -112,6 +112,7 @@ class TestServiceDHCPServer(VyOSUnitTestSHIM.TestCase): bootfile_server = '192.0.2.1' wpad = 'http://wpad.vyos.io/foo/bar' server_identifier = bootfile_server + ipv6_only_preferred = 300 pool = base_path + ['shared-network-name', shared_net_name, 'subnet', subnet] # we use the first subnet IP address as default gateway @@ -132,6 +133,7 @@ class TestServiceDHCPServer(VyOSUnitTestSHIM.TestCase): self.cli_set(pool + ['server-identifier', server_identifier]) self.cli_set(pool + ['static-route', '10.0.0.0/24', 'next-hop', '192.0.2.1']) + self.cli_set(pool + ['ipv6-only-preferred', ipv6_only_preferred]) # check validate() - No DHCP address range or active static-mapping set with self.assertRaises(ConfigSessionError): @@ -169,6 +171,7 @@ class TestServiceDHCPServer(VyOSUnitTestSHIM.TestCase): self.assertIn(f'max-lease-time 86400;', config) self.assertIn(f'range {range_0_start} {range_0_stop};', config) self.assertIn(f'set shared-networkname = "{shared_net_name}";', config) + self.assertIn(f'option rfc8925-ipv6-only-preferred {ipv6_only_preferred};', config) # weird syntax for those static routes self.assertIn(f'option rfc3442-static-route 24,10,0,0,192,0,2,1, 0,192,0,2,1;', config) |