Skip to content

Instantly share code, notes, and snippets.

@raaghulr
Forked from imvaskii/noip-dyndns-update.py
Created September 6, 2023 11:37
Show Gist options
  • Save raaghulr/42f6871169cfec42d1aa224069325090 to your computer and use it in GitHub Desktop.
Save raaghulr/42f6871169cfec42d1aa224069325090 to your computer and use it in GitHub Desktop.
A python (python3) script to update no-ip (https://www.noip.com) dynamic dns ip.
#!/usr/bin/env python
import requests, socket
username = ""
password = ""
hostname = "" # your domain name hosted in no-ip.com
# Gets the current public IP of the host machine.
myip = requests.get('http://api.ipify.org').text
# Gets the existing dns ip pointing to the hostname.
old_ip = socket.gethostbyname(hostname)
# Noip API - dynamic DNS update.
# https://www.noip.com/integrate/request.
def update_dns(config):
r = requests.get("http://{}:{}@dynupdate.no-ip.com/nic/update?hostname={}&myip={}".format(*config))
if r.status_code != requests.codes.ok:
print(r.content)
pass
# Update only when ip is different.
if myip != old_ip:
update_dns( (username, password, hostname, myip) )
pass
@raaghulr
Copy link
Author

raaghulr commented Sep 6, 2023

test

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