DNSPark DDNS update with ColdFusion

Tuesday 25 September 2012 04:16 PM

This website is hosted in a server that has been laying under my TV stand for the past couple of years. I blogged about my initial setup, and even though the setup has improved a bit since then, I still use DNSPark.com to host my DNS records. By having a Dynamic IP, occasionally my IP address changes. Since I have not been running any DDNS update clients on my server as any other normal person would do, I had to update the new IP address directly in the DNSPark.com admin interface. Here I’m going to sort this out with ColdFusion.

My server is behind a NAT Router which, although quite adamantly owns my real IP and my server, has no clue about the IP it actually uses to connect to the rest of the world. I can’t use CGI variables or java.net.InetAddress in this case. However, DNSPark offers a web-based IP detection page at http://ipdetect.dnspark.net with the limitation of calling it no more than once every 10 minute interval. http://checkip.dyndns.org offers the same function and I’m sure they also have some sort of usage limitation. Following Code, fetch the IP address from either one of above URLs.

I’m behind a LinkSys E series router and, like most routers, the admin interface displays the real IP it’s currently occupying. With bit of fishing around on the admin section HTML page, here I was able to fetch out the real IP directly from the router without being a burden to a third party service.

Now having the real IP address, all we have to do is call DNSPark API URL with the correct information (documentation here). Bellow is the complete Code, and I used cfschedule to run this page every 10 minute, check if the IP address is changed, if true, Call DNSPark with the new IP. Also I add a text log on this, because I’m sort of turning into a log freak.