DynDNS Update-Skript
Ein Skript zum automatischen DynDNS-Update
Auf einem Server im Internet folgendes kurzes PHP-Skript ablegen:
ip.php
<?phpecho $_SERVER['REMOTE_ADDR']?>
Dann auf einem Rechner im LAN:
dyndns.sh
#!/bin/sh server="http://example.org/ip.php" user=benutzername passwd=passwort host="mydomain.dyndns.org" file=/tmp/ip dynip=$(nslookup $host | tail -2 | awk '{ print $2 }') wget -q -O $file "$server" if [ -f $file ] then ip=$(cat $file) if [ $ip != $dynip ] then wget -q -O /dev/null \ --no-check-certificate \ --http-user=${user} \ --http-passwd=${passwd} \ "https://members.dyndns.org/nic/update?hostname=${host}&myip=${ip}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" fi rm $file fi
Datei ausführbar machen:
chmod 755 dyndns.sh
Als letztes noch ein Eintrag in die Crontab:
*/1 * * * * /path/to/script/dyndns.sh