Use different technique to determine ipv6

This commit is contained in:
Alexander Schäferdiek 2020-06-18 18:20:57 +02:00
parent ea0e49f5f3
commit 8c82fa5b70
2 changed files with 12 additions and 7 deletions

View file

@ -18,6 +18,7 @@ The following are at least required for the script to work:
- DYNV6_HOSTNAME="" // the dynv6 hostname - DYNV6_HOSTNAME="" // the dynv6 hostname
- DYNV6_IPV4_ENABLED=true // if should update ipv4 - DYNV6_IPV4_ENABLED=true // if should update ipv4
- DYNV6_IPV6_ENABLED=true // if should update ipv6 - DYNV6_IPV6_ENABLED=true // if should update ipv6
- DYNV6_IPV6_INTERFACE=eth0 // which interface to track, be sure that Privacy Extensions are disabled
You can copy this script to '/usr/local/bin' and use create a custom CONFIG_FILE as user. Examples can be found in '/usr/share/doc/<scriptname>'. You can copy this script to '/usr/local/bin' and use create a custom CONFIG_FILE as user. Examples can be found in '/usr/share/doc/<scriptname>'.
EOF EOF
@ -65,6 +66,9 @@ apply_defaults() {
if [ -z ${DYNV6_IPV6_ENABLED} ]; then if [ -z ${DYNV6_IPV6_ENABLED} ]; then
DYNV6_IPV6_ENABLED=true; DYNV6_IPV6_ENABLED=true;
fi fi
if [ -z ${DYNV6_IPV6_INTERFACE} ]; then
DYNV6_IPV6_INTERFACE="eth0";
fi
} }
check_required() { check_required() {
@ -95,7 +99,7 @@ echo "Checking ${hostname}"
# ipv6 # ipv6
if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then if [ "${DYNV6_IPV6_ENABLED}" = "true" ]; then
echo "Testing IPv6"; echo "Testing IPv6";
ipv6Address=$(curl -s "https://v6.ident.me/") ipv6Address=$(LC_ALL=C /usr/bin/ip -c=never -6 -o a s dev ${DYNV6_IPV6_INTERFACE} | grep --color=never -Po '(?<=inet6 )(2.*?)(?=\/64 scope global dynamic mngtmpaddr)')
ipv6Res=$(curl -s -v "https://ipv6.dynv6.com/api/update?hostname=${hostname}&ipv6=${ipv6Address}&token=${token}") ipv6Res=$(curl -s -v "https://ipv6.dynv6.com/api/update?hostname=${hostname}&ipv6=${ipv6Address}&token=${token}")
ipv6Changed=true; ipv6Changed=true;

View file

@ -1,7 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DYNV6_MAIL_ENABLED="false" // if notify via mail DYNV6_MAIL_ENABLED="false" # if notify via mail
DYNV6_MAIL_ADDRESS="" // (optional) mail.rc has to be configured DYNV6_MAIL_ADDRESS="" # (optional) mail.rc has to be configured
DYNV6_TOKEN="" // the dynv6 token DYNV6_TOKEN="" # the dynv6 token
DYNV6_HOSTNAME="" // the dynv6 hostname DYNV6_HOSTNAME="" # the dynv6 hostname
DYNV6_IPV4_ENABLED=true // if should update ipv4 DYNV6_IPV4_ENABLED=true # if should update ipv4
DYNV6_IPV6_ENABLED=true // if should update ipv6 DYNV6_IPV6_ENABLED=true # if should update ipv6
DYNV6_IPV6_INTERFACE=eth0 # which interface to track, be sure that Privacy Extensions are disabled