Technical Thursday – Dynamic DNS client for Linux (in Azure)

In the world of clouds there are some home servers and on-premise servers which work hard to do their daily tasks for their owners. The people who own these machines often try to reach them through internet. Due to internet suppliers – who provide dynamic IP for their customers – this is a real challenge sometimes. Luckily there are several good and free dynamic dns sites where we can register our home server to reach it with a dns name through the Internet. Here is a quite fresh list about the most popular: 17 Popular Sites Like No-ip

I used No-ip but I did not like the 30-days confirmation of my host there. I know, this is not a big deal. Additionally I am interested in Azure so the solution – I would like to show you – is a simple step on this way.

I had decided to make a solution on Azure basis which can replace No-ip client on my home server. And now that is ready and enough stable for “PROD” usage.

 

And now…I would like to introduce an alternative for dynamic DNS which works with Azure DNS zone. Sounds good? Let’s see..

 

This solution helps you to update your home server public IP dynamically. This is not 100% free. The monthly cost in case of a “Pay-AS-YOU-GO” subscription is about 1 EUR/month. Additionally you have to register a domain which you can use in Azure (you can do it in Azure).

Dynamic DNS in Azure (by the1bit)

Prerequisites

At the moment the v18.6.0 supports only Linux machines. Especially I have only tested on CentOS 7.

 

Step-by-step installation

  1. Pull the solution from my git
  2. Create a Service Principal for your account. More information is here
  3. Edit configuration file in config directory
    {
    	"zoneName": "<domain name>",
    	"aRecordName": "<subdomain>",
    	"dnsResourceGroup": "<DNS Zone resource group>",
    	"azure": {
    		"cloudName": "AzureCloud",
    		"clientID": "<Service Principal ID>",
    		"clientSecret": "<Service Principal Secret>",
    		"tenant": "<Tenant ID>",
    		"subscriptionID": "<Subscription ID>"
    	}
    }
  4. Save configuration file
  5. Configure crontab according to your update requirement
    # Edit crontab settings
    vim /etc/crontab
    
    ### Configure to execute at 7AM and 7PM every day
    0 7 * * * root cd /root/scripts/azdns;bash azdns.sh;
    0 19 * * * root cd /root/scripts/azdns;bash azdns.sh;

     

  6. Wait for the required time then check the logs according to execution in /var/log/azdns directory
    less /var/log/azdns/azdns20180614070001.log

    part of log file:

    ...
    Thu Jun 14 07:00:29 CEST 2018 : # Login success
    Thu Jun 14 07:00:29 CEST 2018 : # Set default subscription
    Thu Jun 14 07:00:38 CEST 2018 : # Default subscription has been set
    Thu Jun 14 07:00:38 CEST 2018 : # Get current Puplic IP from Internet
    ...
    

This means you have your own dynamic DNS solution with Azure DNS Zone. I think this is quite cool…

 

Please do not hesitate to contact me if you have any questions or feedback about this solution or Azure. 🙂