Dynamic DNS (DDNS), the way to access your network devices at home from remote locations without static IP. But what if you already own a domain?
In the past I worked with a few DDNS services. They all work by running a script on your home server/network device that determines the external IP address and sends it to the DDNS service.
In my case I already have a domain name registered at TransIP which happens to have an API to automate tasks like managing DNS entries.
So Dynamic DNS is nothing more than updating a specific DNS entry with your current IP address… I wrote a little script which does exactly that. You can check the spectacular results here at github.
This script uses the python REST API module for TransIP, which can be found here.
To get this to work, you should have the following:
- have an account at TransIP
- have an domain name at TransIP
- on the API page:
- turn API on
- generate a keypair and copy the Private Key that is shown once
- save it in a file called privatekey.txt
- convert the private key to an RSA private key (you need openssl tools installed):
openssl rsa -in privatekey.txt -out rsaprivatekey.txt
For example, when you own the
example.com domain and you want to have
home.example.com point to your home server. Let’s assume your TransIP
dyndns.py script as follows:
./dyndns.py -u myusername -k rsaprivatekey.txt -n home -d example.com
I have this script running as a cron job on my server. When your dynamic IP address changes, it takes some time to update the DNS records. So your server should be unreachable for a little while.
Always nice not to depend on DDNS services, but provide my own solution!