Skip to content

Instantly share code, notes, and snippets.

@KumaTea
Created July 2, 2020 03:58
Show Gist options
  • Select an option

  • Save KumaTea/03e948c1589cba7ec7235014272cca25 to your computer and use it in GitHub Desktop.

Select an option

Save KumaTea/03e948c1589cba7ec7235014272cca25 to your computer and use it in GitHub Desktop.
Update AAAA records of selected domains for dnsmasq in OpenWrt
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