Skip to content

Instantly share code, notes, and snippets.

@tistaharahap
Created July 24, 2014 14:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tistaharahap/b2348551f1382200aa78 to your computer and use it in GitHub Desktop.
Save tistaharahap/b2348551f1382200aa78 to your computer and use it in GitHub Desktop.
A Python script to update DuckDNS
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())
@cmsethi
Copy link

cmsethi commented Mar 8, 2024

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

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