Skip to content

Instantly share code, notes, and snippets.

Last active July 6, 2023 07:37
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
CDMon dynamic DNS IP update script
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Python script to update CDMon dynamic DNS
# @author = @jovimon
# @version = 0.1.20200930
# Prerequisites: sudo pip install requests / sudo apt install python-requests
# Based on:
# You can find the last version on:
# Updated to python 3 as per the comments to the gist.
import requests
import hashlib
import datetime
user = 'example-user'
password = 'example-password'
# If you want, you can change how you obtain your external IP address.
# newip must contain just the IP without anything else, even spaces or newlines.
newip = requests.get('').text
# newip = requests.get('').text
# Obtain current date and time
curr_date ="%Y-%m-%d %H:%M:%S")
# Obtain password digest that will be used in the update request
pw_digest = hashlib.md5(bytes(password,"ascii")).hexdigest()
# Build the update URL
url = "" % (user, pw_digest, newip)
# Make the update request
r = requests.get(url)
# Check if everything went fine. If not, show the error.
if r.text.find('customok') < 0:
print("%s - Update error!\nResponse received: %s\nCheck cdmon KB for problems." % (curr_date, r.text))
print("%s - Update successful!" % curr_date)
Copy link

Need fix:
import md5 -> import hashlib
pw_digest = -> pw_digest = hashlib.md5(bytes(password,"ascii")).hexdigest()
print "..."-> print ("...")

Copy link

jovimon commented Sep 30, 2020

Thanks @otakuryo, I updated the gist to python 3.

Copy link

woonaval commented Sep 29, 2021

Hi, I tried to run this script in Debian 11 and the package "python-requests" can't be found. I tried installing with dpkg manually but it has a lot of unmet dependencies... any idea? Thank you!

Edit: if someone would have this issue: I changed the first line from python to python3, like this:
#!/usr/bin/env python3

Copy link

jovimon commented Oct 7, 2021

thanks @woonaval, just updated the first line with what you said.

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