I recently got a new internet connection from Hyperoptic… which is night and day compared to the rubbish Sky ADSL2+ I had before (6/1mbit vs 1000/1000mbit). As such, it is now practical to run servers from my home connection. (for personal use only, if you’re reading this hyperoptic 😉 )

When I was living in Australia and had a decent internet connection, I typically used DynDNS as it was free (it no longer is) and was supported by my router.

Now that DnyDNS isn’t free, nor does my new router support it, I had to find another solution.

I use DreamHost for my web hosting (i.e this site), so I wondered if there was a way to leverage their DNS dynamically.

As it turns out, DreamHost have an API, which has support for creation/deletion/etc of DNS records, and there is some documentation on this on their wiki.

From this, I decided to build my own Dynamic DNS daemon in Java. This daemon will run on my Raspberry Pi3.

The daemon itself is pretty simple, at a set interval it checks my external IP (using this amazon service) and then checks the DNS record for the domain I specify. If it’s the same, nothing is done. If the IP is different, the old record is removed and a new one added. If there is no record there, a new one is added.

It uses a simple JSON file for storing preferences. This version doesn’t have much in the way of logging or error handling… But it was written in a few hours and is very much a work in progress.

If you want to take a look at the source/fork it, it is available on my github here.

If you just want to run it, you can download it from here and then use: java -jar dh-dyn-dns.jar to start it.

Adding and changing a record
Adding and changing a record, as you can see, it’s pretty basic.

If you want to run it as a service on *nix, download this and follow the instructions below; (this service *might* also work on windows, however I haven’t tested it)

  1. You will need a Dreamhost API key, which you can get here, when setting it up, only chose the ‘All DNS functions’ option
  2. Then you will need to install Apache Jsvc, if you are using ubuntu/raspbian/debian/etc run the following command;
    sudo apt-get install Jsvc
  3. Extract the zip to your home directory
  4. Edit the ‘preferences.json’ file to match your confiuration
  5. If you are using a Raspberry Pi, you should be good to go. You can start the service by running the below command;
    ./dh-dyn-dns start
  6. If you are using another configuration, you will need to edit the dh-dyn-dns file and set the correct $JAVA_HOME path.

You can then add the service to init.d (for raspbian/ubuntu/etc) if you want it to start automatically on boot.

Feel free to leave a comment below if you have any questions/comments/ideas 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.