[Eisfair] [E1] Strato DynDNS vom EIS aus aktualisieren?

Marcus Roeckrath marcus.roeckrath at gmx.de
So Sep 18 00:19:06 CEST 2016


Hallo Armin,

Armin Weinmann wrote:

> Ich habe in der Zwischenzeit herausgefunden, daß der ganze Zirkus auch
> ganz einfach durch den Aufruf einer URL erledigt werden kann:
> 
> Alternative:
> curl --insecure
>
https://sub.domain.de:passwort@dyndns.strato.com/nic/update?hostname=sub.domain.de
> 
> Geht soweit prima, nur kommt nach mehrmaligem Aufruf (bei dem die
> Adresse sich nicht geändert hat) die Antwort
> 
> abuse <IP-Adresse>
> 
> D. h. ich sollte vor dem Aufruf prüfen ob sich die aktuell zugeteilte
> Adresse und der bei dyndns.strato.com hinterlegte wert geändert haben
> und nur bei Änderungen wird der Aufruf gemacht.
> 
> Wie kann ich denn sowas machen? Gibts da evtl schon irgendwelche Scripte?

Hast Du eine Fritzbox, dann könnte folgendes Skript hilfreich sein (alles
was unmotiviert wieder an den Zeilenanfang springt ist ein ungewollter
Zeilenumbruch):

if [ "$1" = "" ]
then
    FBIP='192.168.178.1'
else
    FBIP="$1"
fi

FBPORT='49000'
CURL_BIN=`which curl 2>/dev/null`

if [ $? -eq 0 ]
then
    # curl binary exists, go on...
    ip_address=''
    exit_code=0

    # check if host is reachable
    /bin/ping -c 3 ${FBIP} >/dev/null

    if [ $? -eq 0 ]
    then
        # host is reachable, go on...
        # read control URL from description
        #     <controlURL>/upnp/control/WANIPConn1</controlURL>
        control_url="`${CURL_BIN} -s "http://${FBIP}:${FBPORT}/igddesc.xml"
| \
                    sed -e '/WANIPConn1<\/controlURL\>/!d' -e
's/^<controlURL>//' -e 's/<\/controlURL>.*$//'`"

        # get external IP address
        ip_address="`${CURL_BIN} "http://${FBIP}:${FBPORT}${control_url}" \
                -H "Content-Type: text/xml; charset="utf-8"" \
                -H
"SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress"
\
                -d "<?xml version='1.0' encoding='utf-8'?> <s:Envelope
s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
                    xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body>
                    <u:GetExternalIPAddress
xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" /> </s:Body>
</s:Envelope>" \
                -s | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}
{3}\>'`"
#----------------------------------------------------------------
        if [ "${ip_address}" = "" ]
        then
            exit_code=3
        else
            # output ip address
            if [ -f /tmp/wan_ip ] ; then
              if grep -qv "${ip_address}" /tmp/wan_ip ; then
                echo "${ip_address} "`date` > /tmp/wan_ip
                  curl --insecure
"https://sub.domain.de:passwort@dyndns.strato.com/nic/update?hostname=sub.domain.de"
>/dev/null 2>/dev/null
              fi
            else
              echo "${ip_address} "`date` > /tmp/wan_ip
                curl --insecure
"https://sub.domain.de:passwort@dyndns.strato.com/nic/update?hostname=sub.domain.de"                 
>/dev/null 2>/dev/null
            fi
        fi
    else
        exit_code=2
    fi
else
    exit_code=1
fi

echo "${ip_address}"

# exit ${exit_code}
exit 0

Falls keine Fritzbox, dann den Teil über dem

#-----------------------------------------------------

durch etwas anderes ersetzen, was Dir Deine externe IP mitteilt, z. B. eine
Seite im Internet (gibt es zuhauf).

-- 
Gruss Marcus


Mehr Informationen über die Mailingliste Eisfair