A better way to ensure we only get the IPv4 address. An added advantage is that, if we check the IP on the VPN host, we should get our actual IP address, not the VPN-assigned address.

This commit is contained in:
Timothy Allen 2018-03-09 23:45:04 +02:00
parent 848d673257
commit d9a44ff531

View File

@ -6,7 +6,7 @@ zone=dyn.example.com
host=desktop host=desktop
secret="" secret=""
ip=$(wget -q -O - http://treehouse.org.za/ip) ip=$(wget -4 -q -O - http://treehouse.org.za/ip)
set_ip=$(dig +short ${host}.${zone}) set_ip=$(dig +short ${host}.${zone})
if [ -z ${ip} ] || [ -z ${cache} ]; then if [ -z ${ip} ] || [ -z ${cache} ]; then
@ -17,11 +17,6 @@ if [ -f "${HOME}/${cache}" ]; then
old_ip=$(cat "${HOME}/${cache}") old_ip=$(cat "${HOME}/${cache}")
fi fi
# Exit if we're at an IPv6 address
if [ -z "${ip##*:*}" ]; then
exit;
fi
if [ "${set_ip}" = "${ip}" ] && [ "${ip}" = "${old_ip}" ]; then if [ "${set_ip}" = "${ip}" ] && [ "${ip}" = "${old_ip}" ]; then
exit; exit;
else else