Close

Next problem up: D-Link dynDNS

A project log for Heimdall - dumb remote home

It's not smart. It's a raspberry pi I can ssh into. With a fancy mac inspired case.

davedarkodavedarko 12/08/2015 at 10:590 Comments

My router sets a wrong IP address when updating dynDNS, probably the one that my ISP gives me internally. So I had to write a little bash script for setting the IP address. Thanks to the api provided by dyn.com I was able to do just that.

#!/bin/bash
IP_stored=$(cat IP.txt)
IP_current=$(wget http://ipinfo.io/ip -qO -)


HOST="somewhere.dlinkddns.com"
USERNAME="username" //whaaaat
PASSWORD="password" //why did I post this??
URL="members.dyndns.org/nic/update"
URLEND="&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
if [ "$IP_stored" != "$IP_current" ]
then
        curl "http://${USERNAME}:${PASSWORD}@${URL}?hostname=${HOST}&myip=${IP_current}${URLEND}"
        echo "${IP_current}" > IP.txt
fi

Cronjob

*/5 * * * * cd /home/pi/script/ && bash dynDNSupdate.sh

https://help.dyn.com/remote-access-api/perform-update/

http://askubuntu.com/questions/95910/command-for-determining-my-public-ip

Discussions