diff options
author | Christian Breunig <christian@breunig.cc> | 2024-04-05 18:20:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 18:20:20 +0200 |
commit | d5750f0b6c338211b8c4a3ddd88365fe69ab008b (patch) | |
tree | d4af46d0cd7dfb7415389f08e41237e36d5e2097 /data | |
parent | ae96118ec38c4064552889aea5e50023a66aac1e (diff) | |
parent | acb01526bedfb0aa96aa59cad5dec092769bd676 (diff) | |
download | vyos-1x-d5750f0b6c338211b8c4a3ddd88365fe69ab008b.tar.gz vyos-1x-d5750f0b6c338211b8c4a3ddd88365fe69ab008b.zip |
Merge pull request #3250 from c-po/dhcpv6-T2590-equuleus
dhcpv6-client: T2590: fix vyos-hostsd update for nameserver and search domains (backport #3224)
Diffstat (limited to 'data')
-rw-r--r-- | data/templates/dhcp-client/dhcp6c-script.j2 | 31 | ||||
-rw-r--r-- | data/templates/dhcp-client/ipv6.tmpl | 1 |
2 files changed, 32 insertions, 0 deletions
diff --git a/data/templates/dhcp-client/dhcp6c-script.j2 b/data/templates/dhcp-client/dhcp6c-script.j2 new file mode 100644 index 000000000..14fb25cf6 --- /dev/null +++ b/data/templates/dhcp-client/dhcp6c-script.j2 @@ -0,0 +1,31 @@ +#!/bin/sh +# Update DNS information for DHCPv6 clients +# should be used only if vyos-hostsd is running + +if /usr/bin/systemctl -q is-active vyos-hostsd; then + hostsd_client="/usr/bin/vyos-hostsd-client" + hostsd_changes= + + if [ -n "$new_domain_name" ]; then + logmsg info "Deleting search domains with tag \"dhcpv6-{{ ifname }}\" via vyos-hostsd-client" + $hostsd_client --delete-search-domains --tag "dhcpv6-{{ ifname }}" + logmsg info "Adding domain name \"$new_domain_name\" as search domain with tag \"dhcpv6-{{ ifname }}\" via vyos-hostsd-client" + $hostsd_client --add-search-domains "$new_domain_name" --tag "dhcpv6-{{ ifname }}" + hostsd_changes=y + fi + + if [ -n "$new_domain_name_servers" ]; then + logmsg info "Deleting nameservers with tag \"dhcpv6-{{ ifname }}\" via vyos-hostsd-client" + $hostsd_client --delete-name-servers --tag "dhcpv6-{{ ifname }}" + logmsg info "Adding nameservers \"$new_domain_name_servers\" with tag \"dhcpv6-{{ ifname }}\" via vyos-hostsd-client" + $hostsd_client --add-name-servers $new_domain_name_servers --tag "dhcpv6-{{ ifname }}" + hostsd_changes=y + fi + + if [ $hostsd_changes ]; then + logmsg info "Applying changes via vyos-hostsd-client" + $hostsd_client --apply + else + logmsg info "No changes to apply via vyos-hostsd-client" + fi +fi diff --git a/data/templates/dhcp-client/ipv6.tmpl b/data/templates/dhcp-client/ipv6.tmpl index c292664e9..348ac1f22 100644 --- a/data/templates/dhcp-client/ipv6.tmpl +++ b/data/templates/dhcp-client/ipv6.tmpl @@ -23,6 +23,7 @@ interface {{ ifname }} { send ia-pd {{ pd }}; # prefix delegation #{{ pd }} {% endfor %} {% endif %} + script "{{ dhcp6_script_file }}"; }; {% if address is defined and 'dhcpv6' in address %} |