I looked around for an easier way to post an internal IP to DynDNS, but I didn’t find one. Scripting to the rescue.
If you have a paid account at DynDNS (may work for free ones too, I’m not sure), you can update a DNS entry by hitting a URL like this:
So, to update your DNS entry, you just need to get your IP alone in a variable that a batch file can use, then setup a task to request that URL every so often. In more detail, the steps are:
- Install Cygwin including the ‘curl’ package. Curl allows you to make web requests from the command line.
- Create a batch file that gets your IP then makes the DynDNS update request (see below).
- Create a new scheduled task through the Windows Control Panel: setup multiple schedules so it runs the batch file you created in step #2 at startup, login, and when the machine is idle 60 minutes.
The batch file is like so, be sure to update the curl location, DynDNS login, password, and hostname info before you use it:
:: Script from: http://www.ericphelps.com/batch/samples/ip.txt @echo off cd %temp% :: Make a line fragment "temp.txt" echo e 100 "call temp2.bat "> script echo rcx>> script echo f>> script echo n temp.txt>> script echo w>> script echo q>>script debug < script > junk del script :: Make the working file "temp2.bat" echo shift> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo shift>> temp2.bat echo set IP=%%9>> temp2.bat :: Run the command that finds the IP and create "temp1.bat" copy temp.txt temp1.bat > junk ipconfig.exe | find "IP Address" | find /v " 0.0.0.0" >> temp1.bat :: Run the temp1.bat, which runs temp2.bat, which sets the IP variable call temp1.bat :: Remove temporary files del temp1.bat del temp2.bat del temp.txt del junk :: Display the result echo Your IP is %IP% :: Send to DynDNS c:\cygwin\bin\curl "http://login:firstname.lastname@example.org/nic/update?hostname=host.domain.com&myip=10.0.0.1&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"