Skip to content

Instantly share code, notes, and snippets.

@Gilinho
Forked from tistaharahap/duckdns_updater.py
Created January 24, 2018 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gilinho/0661abdc28aa59c329c9310c4af9efb1 to your computer and use it in GitHub Desktop.
Save Gilinho/0661abdc28aa59c329c9310c4af9efb1 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())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment