Skip to content

Instantly share code, notes, and snippets.

@bergerx
Last active August 29, 2015 14:27
Show Gist options
  • Save bergerx/d6a8fb52a7ed92cfb159 to your computer and use it in GitHub Desktop.
Save bergerx/d6a8fb52a7ed92cfb159 to your computer and use it in GitHub Desktop.
own no-ip service with route53
sudo pip install awscli
mkdir ~/.aws
cat <<EOF > credentials
[default]
aws_access_key_id = AKIA***
aws_secret_access_key = ***
EOF
cat <<EOF > bin/update-ev-bdgn-net
CURRENT_IP=`curl ifconfig.me`
RECORDED_IP=`aws route53 list-resource-record-sets --hosted-zone-id Z3M3D2PIHQDDU | jq -c '.ResourceRecordSets[] | select(.Name | contains("ev.bdgn.net.")) | .ResourceRecords[0].Value' | tr -d '"'`
if [ "$CURRENT_IP" != "$RECORDED_IP" ]; then
aws route53 change-resource-record-sets --hosted-zone-id Z3M3D2PIHQDDU --change-batch '{"Comment": "auto-update from '`hostname`' ('`hostname -i`')", "Changes": [{"Action": "UPSERT", "ResourceRecordSet": {"Name": "ev.bdgn.net.", "Type": "A", "TTL": 60, "ResourceRecords": [{"Value": "'$CURRENT_IP'"}]}}]}'
fi
EOF
chmod +x bin/update-ev-bdgn-net
bin/update-ev-bdgn-net
crontab -e
* * * * * ~/bin/update-ev-bdgn-net &>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment