Skip to content

Instantly share code, notes, and snippets.

@francoisjacques
Last active December 10, 2021 00:51
Show Gist options
  • Save francoisjacques/bd309ab919c7d88b82f0 to your computer and use it in GitHub Desktop.
Save francoisjacques/bd309ab919c7d88b82f0 to your computer and use it in GitHub Desktop.
dns-o-matic client for asuswrt
#!/bin/sh
# Typical location - /jffs/scripts/ddns-start
# NOTE - USERNAME and PASSWORD must be URL encoded, example @ becomes %40
USERNAME=CHANGE_ME_URL_ENCODED
PASSWORD=CHANGE_ME_URL_ENCODED
HOSTNAME=all.dnsomatic.com
IP=`curl --silent http://canhazip.com`
# Should be no need to modify anything beyond this point
/usr/sbin/curl --silent "https://$USERNAME:$PASSWORD@updates.dnsomatic.com/nic/update?hostname=$HOSTNAME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&myip=$IP" > /dev/null
if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi
@francoisjacques
Copy link
Author

Variation on a DDNS script found on asuswrt-merlin

The original didn't specify the IP address to be used by the DNS provider. This version leverages canhazip service to retrieve the real IP address.

Remarks:

  • don't forget to make the script executable (chmod u+x /jffs/scripts/ddns-start)
  • remove the > /dev/null on line 10 and run the script manually. You should have a good answer if the credentials were properly provided, then put back the > /dev/null
  • vim+scp kicks ass - vim scp://my_router_ip_address//jffs/scripts/ddns-start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment