Dodge DeBoulet DD-WRT User
Joined: 20 Jan 2007 Posts: 61
|
Posted: Tue May 26, 2020 18:11 Post subject: Google DDNS and DD-WRT Solution |
|
Since the inadyn version supplied with dd-wrt doesn't support HTTPS, Google is my domain registrar, and I'm tired of paying No-IP for DDNS service, I've created a solution that appears to be working well for me. I'm posting it here for absolutely no good reason.
Although inadyn doesn't support HTTPS, the version of curl provided with dd-wrt does. And Google has a straightforward API for updating their DDNS.
To use the scripts, you should first enable JFFS, then create the directories /jffs/bin and /jffs/tmp. The scripts will go in /jffs/bin, and the ddnscfg.sh script will need to be edited for your specific DDNS configuration (you can create and use different directories, but ddns.sh will have to be edited to point to the new location for ddnscfg.sh, and the log file location will need to be updated in ddnscfg.sh). The user and pass values need to be replaced with the user and password values Google provides for each DDNS entry you create in their administration portal. The host and domain values must be modified for your short hostname and registered domain name, respectively. It's unlikely you'll need to change anything else.
Once that's complete, the only task remaining is to add the scheduled job to cron through the Administration | Management menu. I have it run every 5 minutes, although it only makes a call to the Google API if 1) it's the first time the script has been run or 2) if the IP address has changed between its previous invocation and the current invocation. It's a pretty lightweight process, so you could run it more (or less) often depending on your needs.
Here's the cron job (every 5 min):
Code: | */5 * * * * root /jffs/bin/ddns.sh |
When ddns.sh is executed, it will check to see if an IP address has been cached from its previous invocation. If it hasn't, it creates a cache file named /tmp/ddns_status.cache that contains the WAN ip address. It then invokes the Google API with curl and logs the result to /jffs/tmp/ddns_YYYYmmdd.log.
If there is a prior cached IP address, it's compared to the WAN IP address. If they match, the fact that no change was required is logged and the script exits. If they don't match (i.e. DHCP has assigned the router a new address), the API is called with the new WAN IP address and the status is logged.
The logs are not automatically rotated or deleted, so you'll need to purge them every few years (or more often, depending on the size and utilization of your JFFS partition).
The scripts are attached in the zip archive below. Constructive criticism is tolerated
Description: |
Scripts for using Google DDNS |
|
Download |
Filename: |
GoogleDDNS.zip |
Filesize: |
1.02 KB |
Downloaded: |
117 Time(s) |
|
|