-
-
Save Gilinho/0661abdc28aa59c329c9310c4af9efb1 to your computer and use it in GitHub Desktop.
A Python script to update DuckDNS
This file contains 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
import urllib2 | |
domains = ['YOUR_DOMAIN1', 'YOUR_DOMAIN2'] | |
token = 'YOUR_ACCESS_TOKEN' | |
ip_check_url = 'http://icanhazip.com' | |
def get_public_ip(): | |
response = urllib2.urlopen(url=ip_check_url) | |
return response.read().strip('\n') | |
def update_duckdns(public_ip): | |
global domains, token | |
duck_url = 'http://www.duckdns.org/update?domains=%s&token=%s&ip=%s' | |
domains = ','.join(domains) | |
duck_url = duck_url % (domains, token, public_ip) | |
response = urllib2.urlopen(url=duck_url) | |
return response.read() | |
if __name__ == '__main__': | |
print update_duckdns(public_ip=get_public_ip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment