diff options
Diffstat (limited to 'dhcpcd-hooks/20-dns.conf')
-rw-r--r-- | dhcpcd-hooks/20-dns.conf | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/dhcpcd-hooks/20-dns.conf b/dhcpcd-hooks/20-dns.conf new file mode 100644 index 0000000..a92e91d --- /dev/null +++ b/dhcpcd-hooks/20-dns.conf @@ -0,0 +1,32 @@ +# Set net.<iface>.dnsN properties that contain the +# DNS server addresses given by the DHCP server. + +set_dns_props() +{ + case "${new_domain_name_servers}" in + "") return 0;; + esac + + count=1 + for i in 1 2 3 4; do + setprop dhcp.${interface}.dns${i} "" + done + + count=1 + for dnsaddr in ${new_domain_name_servers}; do + setprop dhcp.${interface}.dns${count} ${dnsaddr} + count=$(($count + 1)) + done +} + +unset_dns_props() +{ + for i in 1 2 3 4; do + setprop dhcp.${interface}.dns${i} "" + done +} + +case "${reason}" in +BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_dns_props;; +EXPIRE|FAIL|IPV4LL|RELEASE|STOP) unset_dns_props;; +esac |