12345678910111213141516171819202122232425 |
- #! /bin/bash
- # This script is used on the dns server to do the actual update of the zone file
- zone=""
- subdomain=""
- old_ipv4=$(dig +short a ${subdomain} @127.0.0.1)
- new_ipv4=$(cat /var/www/dnsping/tmp/ipv4_address)
- old_ipv6=$(dig +short aaaa ${subdomain} @127.0.0.1)
- new_ipv6=$(cat /var/www/dnsping/tmp/ipv6_address)
- if [ "$new_ipv4" != "$old_ipv4" ] || [ "$new_ipv6" != "$old_ipv6" ];
- then
- nsupdate -l << EOF
- zone $zone
- update delete ${subdomain} A
- update delete ${subdomain} AAAA
- update add ${subdomain} 10 A $new_ipv4
- update add ${subdomain} 10 AAAA $new_ipv6
- show
- send
- EOF
- logger "Updated dynamic IPv4 address from $old_ipv4 to $new_ipv4"
- logger "Updated dynamic IPv6 address from $old_ipv6 to $new_ipv6"
- fi
|