Created
March 12, 2020 02:56
-
-
Save HouCoder/a6ebb79faa87de05e8d18a58730d829e to your computer and use it in GitHub Desktop.
DuckDNS record updater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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