-
-
Save PaulMaddox/9210543 to your computer and use it in GitHub Desktop.
No IP using Amazon Route53
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 | |
# Requires cli53 to be installed | |
# https://github.com/barnybug/cli53 | |
DNS_NAME="home"; | |
DNS_ZONE="example.com"; | |
export AWS_ACCESS_KEY_ID= | |
export AWS_SECRET_ACCESS_KEY= | |
NS=$(dig +short NS $DNS_ZONE | head -1) | |
DNS=$(dig @$NS +short ${DNS_NAME}.${DNS_ZONE}); | |
IP=$(dig +short @resolver1.opendns.com myip.opendns.com); | |
if [ "$IP" != "$DNS" ]; then | |
echo "Update required: Our IP is $IP but our DNS record points to $DNS"; | |
cli53 rrcreate $DNS_ZONE $DNS_NAME A $IP --ttl 60 --replace | |
else | |
echo "No update required"; | |
exit 0; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment