HostOnNet Blog

Python script to update

I want to set DDNS (Dynamic DNS, that will point A record like to your dynamic IP) with, i don’t want to install their program. I found they allow making custom clients. I made a small program in Python to do the update. Here is the code

import urllib

myurl = ""

web_page = urllib.urlopen("")
myip =

print "Your IP is " + myip + "\n"

update_url = "http://" + username + ":" + password + "" + myurl + "&myip=" + myip

print update_url + "\n"

print urllib.urlopen(update_url).read()

You can run it with crontab or schedule task.

Posted in Python

  • Thanks for using No-IP!

  • eNeKuX

    Thanks for the script. It runs perfectly in my N900 (maemo 5).

  • My proposition of little modified script, to avoid sending of open text username and password over HTTP 😉

    import urllib2
    import base64

    myurl = “”
    username = “YOUR_USSERNAME_HERE”
    password = “YOUR_PASSWORD_HERE”

    web_page = urllib2.urlopen(“”)
    myip =

    print “Your IP is ” + myip + “\n”

    update_url = “” + myurl + “&myip=” + myip

    req = urllib2.Request(update_url)
    req.add_header(‘Authorization’, ‘Basic ‘+base64.encodestring(username+”:”+password).replace(“\n”,””))
    resp = urllib2.urlopen(req)
    content =
    print content

  • dodd

    sorry I don’t understand how to use this script in the windows, Anyone can explain more detail?

  • You can run it with command


    Python should be in your path or use full path to python.exe

    Instead of cronjob, use Scheduled Task in Windows.

  • Matthew Tinnion

    This worked like a charm. Thanks for sharing. I was having a problem with random data being downloaded all the time on my Raspberry pi, I can now shut down the Wlan0 when im not using it and update noip after I re-instate the interface.

    solved a huge problem I didn’t have time to solve.