FAQ    Produkte    Domains   DynDNS Linux Script

DynDNS Linux Script

Kopieren Sie dieses Script auf Ihr Linux System.
Setzen Sie entsprechend das +x Recht und passen Sie die Variablen
user,domain,paswswort an.

user:Im Liveconfig bei der Domain unter dem Punkt DynDNS festgelegter User.
passwort:Im Liveconfig bei der Domain unter dem Punkt DynDNS festgelegtes Passwort
domain:Die komplette Domain.


#!/bin/bash


#Variablen anpassen auf Ihre Domain

user="dynnbi";

domain="dyndns.nbiserv.de";

passwort="ReybBewfEbwik#";


#Soll IPv6 auch gesetzt werden 1=Ja 0=nein

nbiipv6=0




#DeBug

#date

#rm -rf  $HOME/.dyndns-aktual-ipv4_$domain;

#rm -rf  $HOME/.dyndns-aktual-ipv6_$domain;



#Statische Variablen

verbose="yes";

phpScriptUrlIPv4="http://ipv4.nbiserv.de"

phpScriptUrlIPv6="http://ipv6.nbiserv.de"

liveconfigHost="www.nbiserv.de:8443"

wgetOpts="--no-check-certificate"

goodresult="good";

myipv6="1"

oldipv6="1"


# Speicher Datei prüfen

if [ ! -e "$HOME/.dyndns-aktual-ipv4_$domain" ];

then

    echo "IPv4" > $HOME/.dyndns-aktual-ipv4_$domain;

    echo "####dyndns -- DynDNS IPv4 Speicherdatei war nicht da -> angelegt";

fi


# alte IP aus Datei holen

oldipv4=$(cat $HOME/.dyndns-aktual-ipv4_$domain);

# neue IP von Script holen

myipv4=$(wget --quiet -O - $phpScriptUrlIPv4);

echo "IPv4:#"$myipv4"#   OLD:#"$oldipv4"#"

if [ $nbiipv6 == '0' ]

    then

        refreshadr="https://$liveconfigHost/liveconfig/hosting/dnsupdate?hostname=$domain&myip=$myipv4&myip4"

    else

        if [ ! -e "$HOME/.dyndns-aktual-ipv6_$domain" ] && "$nbiipv6" == "1";

            then

                echo "IPv6" > $HOME/.dyndns-aktual-ipv6_$domain;

                echo "####dyndns -- DynDNS IPv6 Speicherdatei war nicht da -> angelegt";

        fi

        # alte IP aus Datei holen

        oldipv6=$(cat $HOME/.dyndns-aktual-ipv6_$domain);

        # neue IP von Script holen

        myipv6=$(wget --quiet -O - $phpScriptUrlIPv6);

        echo "IPv6:#"$myipv6"#   OLD:#"$oldipv6"#"

        refreshadr="https://$liveconfigHost/liveconfig/hosting/dnsupdate?hostname=$domain&myip=$myipv4&myip6=$myipv6"

fi

if [ "$myipv4" != "$oldipv4" ] ||  [ "$myipv6" != "$oldipv6" ] ;

        then

            if [ "$nbiipv6" == "1" ];

                then

                    refreshadr="https://$liveconfigHost/liveconfig/hosting/dnsupdate?hostname=$domain&myip=$myipv4&myip6=$myipv6"

                else

                    refreshadr="https://$liveconfigHost/liveconfig/hosting/dnsupdate?hostname=$domain&myip=$myipv4"

            fi

            result=$(wget $wgetOpts --quiet --user=$user --password=$passwort -O - $refreshadr);

            if [ "$result" = "$goodresult" ];

                then

                    echo $myipv4 > $HOME/.dyndns-aktual-ipv4_$domain;

                    echo "dyndns -- DynDNS Aktualisierung IPv4 erfolgreich";

                    if [ "$nbiipv6" == "1" ];

                        then

                            echo "dyndns -- DynDNS Aktualisierung IPv6 erfolgreich";

                            echo $myipv6 > $HOME/.dyndns-aktual-ipv6_$domain;

                    fi

                else

                    echo "dyndns -- DynDNS Aktualisierung fehlgeschlagen";

                    echo "####DEBUG START"

                    echo "####Result:"$result

                    echo "####Befehl:wget $wgetOpts --quiet --user=$user --password=$passwort -O - $refreshadr"

                    echo "####DEBUG ENDE"

            fi

        else

            echo "dyndns -- Keine DynDNS Aktualisierung notwendig";

fi

#Ende Script