diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-09-18 22:09:05 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-09-18 22:09:05 +0200 |
commit | d411a40a3598c55fae7abd8bc5f1876007aa704b (patch) | |
tree | 216b08561edb7fd8bbc795e62a9c2e65ede7f8e6 | |
parent | 564f05614b6e8650185c46b9625f6a0cd9661639 (diff) | |
download | vyos-1x-d411a40a3598c55fae7abd8bc5f1876007aa704b.tar.gz vyos-1x-d411a40a3598c55fae7abd8bc5f1876007aa704b.zip |
dhcp-server: T3839: support name-servers and domain config per shared-network
DHCP servers "shared-network" level only makes sense if one can specify
configuration items that can be inherited by individual subnets. This is now
possible for name-servers and the domain-name.
set service dhcp-server shared-network-name LAN domain-name 'vyos.net'
set service dhcp-server shared-network-name LAN name-server '192.0.2.1'
-rw-r--r-- | data/templates/dhcp-server/dhcpd.conf.tmpl | 6 | ||||
-rw-r--r-- | interface-definitions/dhcp-server.xml.in | 12 | ||||
-rw-r--r-- | interface-definitions/include/dhcp-domain-name.xml.i | 11 |
3 files changed, 20 insertions, 9 deletions
diff --git a/data/templates/dhcp-server/dhcpd.conf.tmpl b/data/templates/dhcp-server/dhcpd.conf.tmpl index ed39ff4da..108c9cc85 100644 --- a/data/templates/dhcp-server/dhcpd.conf.tmpl +++ b/data/templates/dhcp-server/dhcpd.conf.tmpl @@ -74,6 +74,12 @@ shared-network {{ network | replace('_','-') }} { {% if network_config.authoritative is defined %} authoritative; {% endif %} +{% if network_config.name_server is defined and network_config.name_server is not none %} + option domain-name-servers {{ network_config.name_server | join(', ') }}; +{% endif %} +{% if network_config.domain_name is defined and network_config.domain_name is not none %} + option domain-name "{{ network_config.domain_name }}"; +{% endif %} {% if network_config.shared_network_parameters is defined and network_config.shared_network_parameters is not none %} # The following {{ network_config.shared_network_parameters | length }} line(s) # were added as shared-network-parameters in the CLI and have not been validated diff --git a/interface-definitions/dhcp-server.xml.in b/interface-definitions/dhcp-server.xml.in index 5db46a0c4..e629d96ab 100644 --- a/interface-definitions/dhcp-server.xml.in +++ b/interface-definitions/dhcp-server.xml.in @@ -53,6 +53,8 @@ <valueless/> </properties> </leafNode> + #include <include/dhcp-domain-name.xml.i> + #include <include/name-server-ipv4.xml.i> #include <include/generic-description.xml.i> #include <include/generic-disable-node.xml.i> <leafNode name="shared-network-parameters"> @@ -114,15 +116,7 @@ </properties> </leafNode> #include <include/name-server-ipv4.xml.i> - <leafNode name="domain-name"> - <properties> - <help>Client Domain Name</help> - <constraint> - <validator name="fqdn"/> - </constraint> - <constraintErrorMessage>Invalid domain name (RFC 1123 section 2).\nMay only contain letters, numbers and .-_</constraintErrorMessage> - </properties> - </leafNode> + #include <include/dhcp-domain-name.xml.i> #include <include/dhcp-server-domain-search.xml.i> <leafNode name="exclude"> <properties> diff --git a/interface-definitions/include/dhcp-domain-name.xml.i b/interface-definitions/include/dhcp-domain-name.xml.i new file mode 100644 index 000000000..eb95596da --- /dev/null +++ b/interface-definitions/include/dhcp-domain-name.xml.i @@ -0,0 +1,11 @@ +<!-- include start from dhcp-domain-name.xml.i --> +<leafNode name="domain-name"> + <properties> + <help>Client Domain Name</help> + <constraint> + <validator name="fqdn"/> + </constraint> + <constraintErrorMessage>Invalid domain name (RFC 1123 section 2).\nMay only contain letters, numbers and .-_</constraintErrorMessage> + </properties> +</leafNode> +<!-- include end --> |