Skip to content

Instantly share code, notes, and snippets.

@migeorge
Created February 15, 2017 02:27
Show Gist options
  • Save migeorge/1531291f0810dfb5931f4a887936b44c to your computer and use it in GitHub Desktop.
Save migeorge/1531291f0810dfb5931f4a887936b44c to your computer and use it in GitHub Desktop.
DD-WRT DigitalOcean Dynamic DNS
IPADDR=$(nvram get wan_ipaddr)
DO_KEY="Your DigitalOcean API Key"
DOMAIN="yourdomain.name"
DO_RECORD_ID=id_for_record_you_want_to_update
echo $IPADDR
echo Updating name server
curl -k "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$DO_RECORD_ID" \
-X PUT \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DO_KEY" \
-d "{ \"data\": \"$IPADDR\" }"
@migeorge
Copy link
Author

migeorge commented Feb 15, 2017

Usage

  1. Log in to router web access
  2. Setup custom script
    1. Navigate to Administration > Commands
    2. Paste above into text area
    3. Update Variables
      • DO_KEY - A DigitalOcean API Key for your account
      • DOMAIN - The domain you're updating
      • DO_RECORD_ID - The ID of the A record you're updating (you can get that with a get request to https://api.digitalocean.con/v2/domains/$DOMAIN/records
    4. Press Save Custom Script
  3. Setup cron to run at desired interval
    1. Navigate to Administration > Management
    2. Insert cron job in Additional Cron Jobs (To run at midnight daily: 0 0 * * * root /tmp/custom.sh)
    3. Press Apply Settings

Disclaimer

This script leverages curl in insecure mode (-k), use at your own risk.

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