#!/bin/bash ## Skrip zum erneuern der Öffentlichen IPv6 Adresse ## Autor: Matthias Soika ## Version 0.4.1 ## Datum: 08.04.2022 | 15.07.2022 | 10.11.2023 ## Installation: ## wget -c --progress=dot -O /root/bin/dyndns_update.sh https://ftp.info-linux.de/arbeiten/Linux/dyndns.txt && chmod 755 /root/bin/dyndns_update.sh ## ## Setzen sie Ihren Hostname, DynDNS Benutzernamen und das Passwort. ## Crontab -e */5 * * * * /root/bin/dyndns_update.sh NORMAL='\033[0;39m' BLUE='\033[1;34m' GREEN='\033[1;32m' RED='\033[1;31m' YELLOW='\033[1;33m' ## Ermitteln der IPv6 Adresse myPublicHostName=$(hostname -f) myPublicIPv4Address=$(curl -s checkip.amazonaws.com) #myPublicIPv6Address=$(curl -fsSL https://svc.joker.com/nic/myip) myPublicIPv6Address=$(ip r get to 2001:4860:4860::8888 | perl -ne '/src ([\w:]+)/ && print "$1\n"') DynUserName= DynPW= ## UpdateURLs StratoUpdateURL="https://$DynUserName:$DynPW@dyndns.strato.com/nic/update?hostname=$myPublicHostName&myip=$myPublicIPv6Address" JokerUpdateURL="https://svc.joker.com/nic/update?username=$DynUserName&password=$DynPW&myip=$myPublicIPv6Address&hostname=$myPublicHostName" #UseURL=$StratoUpdateURL UseURL=$JokerUpdateURL ## Fehler Abfangen ERROR1=0 ERROR2=0 ERROR3=0 ERROR4=0 CURL=$(which curl) if [ -z $CURL ]; then ERROR1=1; fi if [ -z $DynUserName ]; then ERROR2=1; fi if [ -z $DynPW ]; then ERROR3=1; fi if [ -z $UseURL ]; then ERROR4=1; fi if [ $ERROR1 -eq 1 ] || [ $ERROR2 -eq 1 ] || [ $ERROR4 -eq 1 ] || [ $ERROR4 -eq 1 ]; then echo echo -e "\tEs sind folgende fehler aufgetreten:" if [ $ERROR1 -eq 1 ]; then echo -e "\tDas Programm Curl ist nicht installiert. Bitte installieren sie Curl!"; fi if [ $ERROR2 -eq 1 ]; then echo -ne $YELLOW; echo -e "\tEs ist kein Benutzername in der Variable DynUserName hinterlegt. $NORMAL"; fi if [ $ERROR3 -eq 1 ]; then echo -ne $YELLOW; echo -e "\tEs ist kein Passwort in der Variable DynPW hinterlegt. $NORMAL"; fi if [ $ERROR4 -eq 1 ]; then echo -ne $YELLOW; echo -e "\tDie Variable UseURL ist nicht gesetzt. $NORMAL"; fi echo exit 1; fi ## Debugmode? DebugMode=0 if [[ $1 == debug ]]; then echo; echo -e "\tDebugMode = On"; DebugMode=1; fi function DynUpdate { echo $myPublicIPv6Address | grep : > /dev/null 2>&1 GrepResult=$? if [ $GrepResult -eq 0 ]; then if [ $DebugMode -eq 1 ]; then echo echo -e "\tMy Hostname:$YELLOW $myPublicHostName $NORMAL" echo -e "\tMy WAN/Public IPv4 address:$YELLOW $myPublicIPv4Address $NORMAL" echo -e "\tMy WAN/Public IPv6 address:$YELLOW $myPublicIPv6Address $NORMAL" echo $CURL $UseURL else $CURL $UseURL > /dev/null 2>&1 fi else echo -e $YELLOW echo -e "\tIPv6 momentan nicht verfügbar." echo -e $NORMAL fi } DynUpdate