summaryrefslogtreecommitdiff
path: root/src/etc/dhcp/dhclient-exit-hooks.d
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2020-06-22 13:24:30 +0700
committerGitHub <noreply@github.com>2020-06-22 13:24:30 +0700
commit1d09b1a788cc91ff64134d853f063dc0a364ad50 (patch)
tree1dca2298b55d26ba24347a14dfc5a837d92aefff /src/etc/dhcp/dhclient-exit-hooks.d
parenta8041aa4a9e70c267c17451c14c7dcf9ca887023 (diff)
parent0ccdf15c0acb0be128fa2346b72cfdd8ce16b694 (diff)
downloadvyos-1x-1d09b1a788cc91ff64134d853f063dc0a364ad50.tar.gz
vyos-1x-1d09b1a788cc91ff64134d853f063dc0a364ad50.zip
Merge pull request #452 from jjakob/T2486-dns-hostsd-fixes
T2486: DNS, vyos-hostsd fixes
Diffstat (limited to 'src/etc/dhcp/dhclient-exit-hooks.d')
-rw-r--r--src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup b/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup
index 88a4d9db9..01981ad04 100644
--- a/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup
+++ b/src/etc/dhcp/dhclient-exit-hooks.d/01-vyos-cleanup
@@ -1,14 +1,24 @@
+##
+## VyOS cleanup
+##
# NOTE: here we use 'ip' wrapper, therefore a route will be actually deleted via /usr/sbin/ip or vtysh, according to the system state
+hostsd_client="/usr/bin/vyos-hostsd-client"
+hostsd_changes=
if [[ $reason =~ (EXPIRE|FAIL|RELEASE|STOP) ]]; then
- # delete dynamic nameservers from a configuration if lease was deleted
+ # delete search domains and nameservers via vyos-hostsd
+ logmsg info "Deleting search domains with tag \"dhcp-$interface\" via vyos-hostsd-client"
+ $hostsd_client --delete-search-domains --tag "dhcp-$interface"
logmsg info "Deleting nameservers with tag \"dhcp-${interface}\" via vyos-hostsd-client"
- vyos-hostsd-client --delete-name-servers --tag dhcp-${interface}
+ $hostsd_client --delete-name-servers --tag "dhcp-${interface}"
+ hostsd_changes=y
+
# try to delete default ip route
for router in $old_routers; do
logmsg info "Deleting default route: via $router dev ${interface}"
ip -4 route del default via $router dev ${interface}
done
+
# delete rfc3442 routes
if [ -n "$old_rfc3442_classless_static_routes" ]; then
set -- $old_rfc3442_classless_static_routes
@@ -72,7 +82,17 @@ if [[ $reason =~ (EXPIRE|FAIL|RELEASE|STOP) ]]; then
fi
if [[ $reason =~ (EXPIRE6|RELEASE6|STOP6) ]]; then
- # delete dynamic nameservers from a configuration if lease was deleted
+ # delete search domains and nameservers via vyos-hostsd
+ logmsg info "Deleting search domains with tag \"dhcpv6-$interface\" via vyos-hostsd-client"
+ $hostsd_client --delete-search-domains --tag "dhcpv6-$interface"
logmsg info "Deleting nameservers with tag \"dhcpv6-${interface}\" via vyos-hostsd-client"
- vyos-hostsd-client --delete-name-servers --tag dhcpv6-${interface}
+ $hostsd_client --delete-name-servers --tag "dhcpv6-${interface}"
+ 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