summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-04-01 16:38:08 +0200
committerGitHub <noreply@github.com>2024-04-01 16:38:08 +0200
commitadb89e77eb8014b9245ee1f7419e84984f6854c6 (patch)
tree4870c244a68cd2b4755f6521a46abbdc32c0f464 /data
parent5e5bb5a40cbd3fad92f0d88c36f47b9b5fd41347 (diff)
parent4e37494b9cb15f3c85b876de700babbaf1b38215 (diff)
downloadvyos-1x-adb89e77eb8014b9245ee1f7419e84984f6854c6.tar.gz
vyos-1x-adb89e77eb8014b9245ee1f7419e84984f6854c6.zip
Merge pull request #3226 from vyos/mergify/bp/sagitta/pr-3224
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.j231
-rw-r--r--data/templates/dhcp-client/ipv6.j22
2 files changed, 32 insertions, 1 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.j2 b/data/templates/dhcp-client/ipv6.j2
index b5e55cdd1..311c856c8 100644
--- a/data/templates/dhcp-client/ipv6.j2
+++ b/data/templates/dhcp-client/ipv6.j2
@@ -23,6 +23,7 @@ interface {{ ifname }} {
send ia-pd {{ pd }}; # prefix delegation #{{ pd }}
{% endfor %}
{% endif %}
+ script "{{ dhcp6_script_file }}";
};
{% if address is vyos_defined and 'dhcpv6' in address %}
@@ -59,4 +60,3 @@ id-assoc pd {{ pd }} {
};
{% endfor %}
{% endif %}
-