Skip to content

Instantly share code, notes, and snippets.

@PaulMaddox
Created February 25, 2014 15:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PaulMaddox/9210543 to your computer and use it in GitHub Desktop.
Save PaulMaddox/9210543 to your computer and use it in GitHub Desktop.
No IP using Amazon Route53
#!/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