Dynamic DNS configuration on TrueNAS with ClouDNS
In this tutorial, I will show you how to config Dynamic DNS(DDNS) on TrueNAS with ClouDNS. Although this tutorial is written for TrueNAS, it also works on FreeNAS 11.3 and as well as the older versions.
What is Dynamic DNS?
Dynamic DNS, or DDNS for short, is a DNS service that provides the option to change the IP addresses of your A/AAAA records when the IP address of your device is changed dynamically by your Internet Service Provider. This is a good solution especially for home networks, which typically have dynamic public IP addresses from their ISP.
How do I setup a Dynamic DNS?
If you do not have a domain already, you can register for one at an affordable price at ClouDNS or you use the free subdomain offers by CloudDNS. The first step is to log in your ClouDNS at: https://www.cloudns.net. If you already have a domain name, you can easily create a Master DNS zone for your domain in a few clicks. From DNS Zones panel, click on Add new button. Input your domain name, keep the default options (you can add records later) and click on Create button. As shown in the below screenshot, sysadmin102.tech is a Master DNS Zone.
Click on sysadmin102.tech to acess DNS Zone Management Page. Since Dynamic DNS is a feature that allows an automatic update of your A records, you need to add such. To do so, at your DNS zone management page, click on the Add new record link. For Type choose A and type as follows:
I named the host as ddns for demonstration purpose. You should change it to your specific host. If you have static IP address you can set to point to your IP address (you properly don't need DDNS if you have static IP address). If you have a Dynamic IP address (IP Address may change at any time), use the private IP address 126.96.36.199. Once we config the DDNS on TrueNAS, it will automatically update the A record to reflect your public IP address. This way you will know if the DDNS service is actually running on TrueNAS.
To activate Dynamic DNS, at your DNS zone management page, find the A/AAAA record(s), you want this service to be activated on, and click on the up and down arrows icon (Active Dynamic URL). Once, you've clicked on it, a new window will pop up, which will prompt you to activate the service.
We will not use Dynamic DNS under Services on TrueNAS as it's potential security risk. We will use Cron Job to protect the ClouDNS user name and password. From TrueNAS web interface, click on Tasks button. Next click on Cron Jobs tab and click on Add Cron Job button.
For the description block, I will name this Cron Job as DDNS. For the Command block, paste the Wget command that you have copied from the Dynamic URL window. For the Run As User block, select root. For the Schedule drop down, select hourly to match with A record TTL. Click on Submit button to create a Cron Job.
Once you add the Cron Job, I recommend to click on it in the Cron Job list and then click on Run Now button on the bottom of the page in order to execute it instantly. Now, go back to ClouDNS and refresh the page. If you follow the step correctly, your A record will point to your Public IP address instead of the private IP address 192.168.1.1.
Congratulation! You have successfully config DDNS for your TrueNAS. Don't forget to check out my YouTube channel for more tutorial