Last active
October 8, 2015 07:29
-
-
Save RC1140/3299314 to your computer and use it in GitHub Desktop.
DynamicDNS For Use With AmazonRoute53
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
| #!/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__() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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