Monday, January 11, 2010

N900 Hack: Dynamic DNS Update

I just discovered that my 3G provider is actually issuing me a public IP address (the previous one I had gave me a private 10.something address). That is pretty cool since it means I can SSH into the device via the Internet and run all kinds of services on it - if I ever got that desire (yes yes I know it's pretty pointless but who cares).

The N900 got python installed already so I googled around a bit for a python script that could update dyndns service. I found one at: http://ipcheck.sourceforge.net/.

The download is a single file ipcheck.py so I created a directory /opt/ipcheck and copied the ipcheck.py into this directory.

Now I ran a check to see if it worked - something along the line of:

cd /opt/ipcheck
./ipcheck.py --makedat -l -r checkip.dyndns.org:8245 username password domain

Where:

username: my username on dyndns.org
password: my password at dyndns.org
domain: the hostname + domain I registered at dyndns.org

Now all that's left is to get this command run automatically each time the device connects. To do this I created a small shell script /etc/network/if-up.d/ipcheck like this:

#!/bin/sh
#
if [ ! -d /opt/ipcheck ]; then
exit 1
fi

cd /opt/ipcheck
./ipcheck.py -l -r checkip.dyndns.org:8245 username password hostname.getmyip.com
exit 0

That is about it. Now I don't have to check the external IP address of my device.

No comments:

Post a Comment