Created
July 24, 2014 14:26
-
-
Save tistaharahap/b2348551f1382200aa78 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
hello, thanks for writing this script. The script shows the output 'OK'/'OK', and when I add verbose mode like: 'http://www.duckdns.org/update?domains=%s&token=%s&ip=%s&verbose=True' (as described on the duckdns website), it gives an error. But a batch file works fine in verbose mode. Is there any way to get the 'ip address and NOCHANGE/UPDATED' as well in your script. thanks