Created
July 2, 2020 03:58
-
-
Save KumaTea/03e948c1589cba7ec7235014272cca25 to your computer and use it in GitHub Desktop.
Update AAAA records of selected domains for dnsmasq in OpenWrt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| host_file="/tmp/hosts-custom" | |
| if test -f "$host_file"; then | |
| rm $host_file | |
| echo "$host_file exists, now is removed." | |
| else | |
| echo "$host_file does not exist." | |
| fi | |
| domains="npupt.com 4.npupt.com 6.npupt.com checkipv6.dyndns.com checkipv6.dyndns.com checkipv6.dyndns.com checkipv6.dyndns.com" | |
| dns="223.5.5.5" | |
| for domain in $domains; do | |
| ns_result=$(nslookup $domain $dns | tail -n 1) | |
| if [ -z "${ns_result##*Address*}" ]; | |
| then | |
| result=$(echo $ns_result | cut -b 12-) | |
| echo "Add AAAA: $result for $domain to hosts file..." | |
| echo "$result $domain" >> $host_file | |
| else | |
| echo "ERROR: $domain cannot be found, ignored." | |
| fi | |
| done | |
| echo "Restarting dnsmasq..." | |
| /etc/init.d/dnsmasq restart | |
| echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment