A collection of windows scripts that support updating dynamic DNS records
While Dynamic DNS has probably passed its popularity, there are still occasions when it comes in handy. (Really, have a look at other options like CloudFlare Tunnel or Tailscale or ZeroTier first).
The primary goal here is to find your public IP from behind a local NAT router (not a CG-NAT router, you'll need to talk to your ISP about that one) and update a remote Dynamic DNS service, without installing any additional packages inside of a windows environment.
Yes, batch scripts are clunky, but they're also transparent and within a few minutes you can read through every line and know exactly what you're putting on your system, unlike closed sourced GUI updaters.
Why? Most scripts appear to be bash based for Linux / Unix. Other scripts use random websites to extract the IP, which are here today, could be gone tomorrow. Instead this script uses OpenDNS's DNS resolvers with the help of nslookup (rather than dig. dig is easier, but not native to windows)
- Discovers Public IP via a nslookup to OpenDNS and drops this into ip.txt
- Checks ip.txt against lastip.txt, if different (or lastip.txt is missing) it pushes the IP update to the 3rd party service.
- ip.txt is copied to lastip.txt so that subsequent checks don't send unnecessary updates (which are sometimes rate limited by free services)
- The check against lastip.txt prevents subsequent checks from sending unnecessary updates
- Because the checking it does by comparing the local files ip.txt and lastip.txt, if a 3rd party service updates the record, it won't trigger an update as it doesn't actually resolve the current record information (although if this was important to you, you could adapt the script pretty easily).
- Lack of logging.
- No error reporting/alerting when things don't update. To prevent the cmd window, we need a vbs script to call our bat script silently
- Update [servicename]-dynamicdns.bat with the variables at the top of the file.
- Call either the [servicename]-dynamicdns.bat or [servicename]-dynamicdns.vbs file.
- Create a Scheduled Task in Windows Task Scheduler.
- Set the trigger to 'On log on' and 'Repeat task every 30 minutes' for a duration of 'Indefinitely'.
- Set the Actions to 'Start a program' and set the Program/Script to
namecheap-dynamicdns-run.vbs
.
- Providing up to date DNS info for your onsite VPN server
- Assiting with remote access to PVR/NVR/Secuirty Cameras/RDP/etc (again, there's probably better options out their now than port forwarding).
- Hosting your own website from a raspberry pi in your bedroom, just because you can.
- CloudFlare
- DNSMadeEasy
- No-IP
- Dyn.com