Skip to content

Instantly share code, notes, and snippets.

@RC1140
Last active October 8, 2015 07:29
Show Gist options
  • Select an option

  • Save RC1140/3299314 to your computer and use it in GitHub Desktop.

Select an option

Save RC1140/3299314 to your computer and use it in GitHub Desktop.
DynamicDNS For Use With AmazonRoute53
#!/usr/bin/env python
import stun
import socket
import boto
from cirrus.r53 import Zone
domainName = ''
access_id = ''
secret_key = ''
try:
oldIP = socket.gethostbyname(domainName)
except:
oldIP = 'Not found'
nat_type, current_ip, external_port = stun.get_ip_info()
if oldIP.__str__() != current_ip.__str__():
print 'IPs do not match : '
print 'Old : 'oldIP.__str__()
print 'Current : 'current_ip.__str__()
conn = boto.connect_route53(access_id,secret_key)
r53zone = Zone(conn, domainName)
rtype = 'A'
existing = r53zone.get_host(domainName)
r53zone.update_host(domainName, rtype, None, existing, current_ip.__str__())
print 'Zone Updated'
else:
print 'IPs are still the same'
print 'Old : 'oldIP.__str__()
print 'Current : 'current_ip.__str__()
@RC1140
Copy link
Author

RC1140 commented Sep 25, 2013

If you are unable to install pytz because of issues with pip , add the following to a file called requirements.txt
"pytz>=2013b"
and then install with with , pip install -r requirements.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment