Use external service to determine IP address
This commit is contained in:
parent
d3094421ba
commit
f4c72fa7a9
1 changed files with 6 additions and 4 deletions
10
usr/local/bin/dynv6
Executable file → Normal file
10
usr/local/bin/dynv6
Executable file → Normal file
|
@ -95,7 +95,8 @@ echo "Checking ${hostname}"
|
||||||
# ipv6
|
# ipv6
|
||||||
if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then
|
if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then
|
||||||
echo "Testing IPv6";
|
echo "Testing IPv6";
|
||||||
ipv6Res=$(curl -fsS "http://ipv6.dynv6.com/api/update?hostname=${hostname}&ipv6=auto&token=${token}")
|
ipv6Address=$(curl -s "https://v6.ident.me/")
|
||||||
|
ipv6Res=$(curl -fsS "http://ipv6.dynv6.com/api/update?hostname=${hostname}&ipv6=${ipv6Address}&token=${token}")
|
||||||
ipv6Changed=true;
|
ipv6Changed=true;
|
||||||
|
|
||||||
if [ "${ipv6Res}" = "addresses unchanged" ]; then
|
if [ "${ipv6Res}" = "addresses unchanged" ]; then
|
||||||
|
@ -106,7 +107,7 @@ if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then
|
||||||
|
|
||||||
if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then
|
if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then
|
||||||
HOSTMACHINE=$(hostname)
|
HOSTMACHINE=$(hostname)
|
||||||
echo -e "IPv6 for ${hostname} on host ${HOSTMACHINE} changed" | mailx -s "[dynv6 IPv6 ${HOSTMACHINE}] IPv6 changed for ${hostname}" "${DYNV6_MAIL_ADDRESS}"
|
echo -e "IPv6 for ${hostname} on host ${HOSTMACHINE} changed to ${ipv6Address}" | mailx -s "[dynv6 IPv6 ${HOSTMACHINE}] IPv6 changed for ${hostname}" "${DYNV6_MAIL_ADDRESS}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -114,7 +115,8 @@ fi
|
||||||
# ipv4
|
# ipv4
|
||||||
if [ "${DYNV6_IPV4_ENABLED}" = "true" ]; then
|
if [ "${DYNV6_IPV4_ENABLED}" = "true" ]; then
|
||||||
echo "Testing IPv4";
|
echo "Testing IPv4";
|
||||||
ipv4Res=$(curl -fsS "http://ipv4.dynv6.com/api/update?hostname=${hostname}&ipv4=auto&token=${token}")
|
ipv4Address=$(curl -s "https://v4.ident.me/")
|
||||||
|
ipv4Res=$(curl -fsS "http://ipv4.dynv6.com/api/update?hostname=${hostname}&ipv4=${ipv4Address}&token=${token}")
|
||||||
ipv4Changed=true;
|
ipv4Changed=true;
|
||||||
if [ "$ipv4Res" = "addresses unchanged" ]; then
|
if [ "$ipv4Res" = "addresses unchanged" ]; then
|
||||||
ipv4Changed=false;
|
ipv4Changed=false;
|
||||||
|
@ -124,7 +126,7 @@ if [ "${DYNV6_IPV4_ENABLED}" = "true" ]; then
|
||||||
|
|
||||||
if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then
|
if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then
|
||||||
HOSTMACHINE=$(hostname)
|
HOSTMACHINE=$(hostname)
|
||||||
echo -e "IPv4 for ${hostname} on host ${HOSTMACHINE} changed" | mailx -s "[dynv6 IPv4 ${HOSTMACHINE}] IPv4 changed for ${hostname}" "${DYNV6_MAIL_ADDRESS}"
|
echo -e "IPv4 for ${hostname} on host ${HOSTMACHINE} changed changed to ${ipv4Address}" | mailx -s "[dynv6 IPv4 ${HOSTMACHINE}] IPv4 changed for ${hostname}" "${DYNV6_MAIL_ADDRESS}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
Loading…
Reference in a new issue