From f4c72fa7a992d9081a9ee6ab4c8c8b34ff0c5b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=A4ferdiek?= Date: Mon, 3 Feb 2020 21:05:10 +0000 Subject: [PATCH] Use external service to determine IP address --- usr/local/bin/dynv6 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) mode change 100755 => 100644 usr/local/bin/dynv6 diff --git a/usr/local/bin/dynv6 b/usr/local/bin/dynv6 old mode 100755 new mode 100644 index 329f968..8c3834e --- a/usr/local/bin/dynv6 +++ b/usr/local/bin/dynv6 @@ -95,7 +95,8 @@ echo "Checking ${hostname}" # ipv6 if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then 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; if [ "${ipv6Res}" = "addresses unchanged" ]; then @@ -106,7 +107,7 @@ if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then 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 @@ -114,7 +115,8 @@ fi # ipv4 if [ "${DYNV6_IPV4_ENABLED}" = "true" ]; then 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; if [ "$ipv4Res" = "addresses unchanged" ]; then ipv4Changed=false; @@ -124,7 +126,7 @@ if [ "${DYNV6_IPV4_ENABLED}" = "true" ]; then if [ "${DYNV6_MAIL_ENABLED}" = "true" ]; then 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 \ No newline at end of file