Skip to content

Instantly share code, notes, and snippets.

@HouCoder
Created March 12, 2020 02:56
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 HouCoder/a6ebb79faa87de05e8d18a58730d829e to your computer and use it in GitHub Desktop.
Save HouCoder/a6ebb79faa87de05e8d18a58730d829e to your computer and use it in GitHub Desktop.
DuckDNS record updater
#!/bin/bash
domain="duckdns.org"
name="example-a-record"
token="your token"
# Get public IP from ipinfo.io
public_ip="$(curl --silent ipinfo.io/ip)"
# get current record
current_record="$(dig @8.8.8.8 +short $name.$domain)"
if [ "$current_record" != "$public_ip" ]; then
echo New public IP is $public_ip
curl "https://www.duckdns.org/update?domains=$name&token=$token&ip=$public_ip"
else
echo Nothing changed
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment