home > code > How To Post Your Dynamic Internal IP To DynDNS From Your Windows Machine

How To Post Your Dynamic Internal IP To DynDNS From Your Windows Machine

October 9th, 2009 Leave a comment Go to comments

UpdateIP.bat screenshot

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:

http://login:password@members.dyndns.org/nic/update?hostname=host.domain.com&myip=10.0.0.1&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG

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:

  1. Install Cygwin including the ‘curl’ package. Curl allows you to make web requests from the command line.
  2. Create a batch file that gets your IP then makes the DynDNS update request (see below).
  3. 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:password@members.dyndns.org/nic/update?hostname=host.domain.com&myip=10.0.0.1&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"

Categories: code Tags: , , , ,
  1. March 4th, 2010 at 13:05 | #1

    Ok, I found an easier way. The old 3.x version of DynDns Updater supports an .ini file option that enables sending local network IP addresses.

    Download the client, install it, and get it setup using the default settings. Then quit the application, open the c:\program files\DynDNS updater\DynDNS.ini file in Notepad, and add the following under the “[Options]” section: “UseLanIP=1″. Launch DynDNS Updater again, switch to the dial-up connection setting (instead of LAN) and you should be done. Note that my instructions differ from the author’s instructions because I had trouble getting the official instructions to work.

  1. October 9th, 2009 at 12:39 | #1