Skip to content

Instantly share code, notes, and snippets.

@ckunte
Created June 16, 2019 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckunte/d2bacfd69bea1975b1c23e2c5247f1c7 to your computer and use it in GitHub Desktop.
Save ckunte/d2bacfd69bea1975b1c23e2c5247f1c7 to your computer and use it in GitHub Desktop.
DDNS setup for IP refresh using DNSimple
#!/bin/bash
#
# setup in /etc/anacrontab:
# 1 5 ping.daily /home/ckunte/.ddns/ddns.sh
#
TOKEN="<add token here>" # The API v2 OAuth token
ACCOUNT_ID="<add id here>" # Replace with your account ID
ZONE_ID="<add domain name here>" # The zone ID is the name of the zone (or domain)
RECORD_ID="<add record id here>" # Replace with the DNS Record ID (corresponds to A record)
IP=`curl -s http://icanhazip.com/`
curl -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-X "PATCH" \
-i "https://api.dnsimple.com/v2/$ACCOUNT_ID/zones/$ZONE_ID/records/$RECORD_ID" \
-d "{\"content\":\"$IP\"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment