diff options
author | kroy-the-rabbit <kroy@kroy.io> | 2020-05-28 00:39:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 07:39:45 +0200 |
commit | 5b1ac79562bd60494c9ec31723b27b0affe7fe5c (patch) | |
tree | 6bc442bb106f39995f2170b5c3198a594faf61f4 | |
parent | 47a08a610e13648074392b981af7d52f0c5506d0 (diff) | |
download | vyos-1x-5b1ac79562bd60494c9ec31723b27b0affe7fe5c.tar.gz vyos-1x-5b1ac79562bd60494c9ec31723b27b0affe7fe5c.zip |
dhcp: T2465: T2483: fix DNS resolution (pdns restatt)
-rwxr-xr-x | src/services/vyos-hostsd | 14 | ||||
-rwxr-xr-x | src/system/on-dhcp-event.sh | 12 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd index 6017cea82..bf5d67cfa 100755 --- a/src/services/vyos-hostsd +++ b/src/services/vyos-hostsd @@ -28,6 +28,7 @@ import zmq import collections import jinja2 +from vyos.util import popen, process_named_running debug = True @@ -212,13 +213,17 @@ def handle_message(msg_json): op = get_option(msg, 'op') _type = get_option(msg, 'type') + changes = 0 + if op == 'delete': tag = get_option(msg, 'tag') if _type == 'name_servers': delete_name_servers(STATE, tag) + changes += 1 elif _type == 'hosts': delete_hosts(STATE, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'add': @@ -226,8 +231,10 @@ def handle_message(msg_json): entries = get_option(msg, 'data') if _type == 'name_servers': add_name_servers(STATE, entries, tag) + changes += 1 elif _type == 'hosts': add_hosts(STATE, entries, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'set': @@ -236,6 +243,7 @@ def handle_message(msg_json): data = get_option(msg, 'data') if _type == 'host_name': set_host_name(STATE, data) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'get': @@ -255,6 +263,12 @@ def handle_message(msg_json): with open(STATE_FILE, 'w') as f: json.dump(STATE, f) + if changes > 0: + if process_named_running("pdns_recursor"): + (ret,return_code) = popen("sudo rec_control --socket-dir=/run/powerdns reload-zones") + if return_code > 0: + logger.exception("PowerDNS rec_control failed to reload") + def exit_handler(sig, frame): """ Clean up the state when shutdown correctly """ logger.info("Cleaning up state") diff --git a/src/system/on-dhcp-event.sh b/src/system/on-dhcp-event.sh index 385ae460f..57f492401 100755 --- a/src/system/on-dhcp-event.sh +++ b/src/system/on-dhcp-event.sh @@ -20,7 +20,6 @@ client_ip=$3 client_mac=$4 domain=$5 file=/etc/hosts -changes=0 if [ -z "$client_name" ]; then logger -s -t on-dhcp-event "Client name was empty, using MAC \"$client_mac\" instead" @@ -44,13 +43,11 @@ case "$action" in fi # add host /usr/bin/vyos-hostsd-client --add-hosts --tag "DHCP-$client_ip" --host "$client_fqdn_name,$client_ip" - ((changes++)) ;; release) # delete mapping for released address # delete host /usr/bin/vyos-hostsd-client --delete-hosts --tag "DHCP-$client_ip" - ((changes++)) ;; *) @@ -59,15 +56,6 @@ case "$action" in ;; esac -if [ $changes -gt 0 ]; then - echo Success - pid=`pgrep pdns_recursor` - if [ -n "$pid" ]; then - sudo rec_control --socket-dir=/run/powerdns reload-zones - fi -else - echo No changes made -fi exit 0 |