Dynamic DNS
Dynamic DNS on Unifi Network
From my homelab post, I mention I use a Ubiquiti Dream Machine Special Edition (SE) for my network core which has a built in VPN server. Here I discuss how I setup a VPN configuration so I could remotely connect into my network and access my connected resources, such as my NAS, kubernetes cluster, and smart devices directly. On top of this I needed to setup a Dynamic DNS (DDNS) record to dynamically update the ISP provided IP. I use Namecheap as my DNS provider which offers a free DDNS services. I will also discuss various troubleshooting I had to perform and an IP tracker script I wrote to log the change in IP and verify DDNS was working properly.
In the Unifi Network Application, under
Settings > Internet > [desired network](Primary WAN1)
set the Advanced
option to Manual
and there will be a section for Dynamic DNS
. Here I selected the service namecheap
and put the following information:
Hostname: <subdomain or `@` for all>
Username: <domain>
Password: <password generated by namecheap>
Server: dynamicdns.park-your-domain.com
Example:
Hostname: remote
Username: example.com
Password: hunter2
Server: dynamicdns.park-your-domain.com
In the Namecheap control panel, select the domain to setup DDNS with and navigate to the ‘Advanced DNS’ tab. Under the ‘Dynamic DNS’ section, ensure the status is set to ‘enable’. Add a new record with:
Type | Host | Value | TTL |
---|---|---|---|
A + Dynamic DNS Record | <same entry as ‘Hostname’ from the Unifi console> | <any value, but best to use your current public IP> | Automatic |
Example:
Type | Host | Value | TTL |
---|---|---|---|
A + Dynamic DNS Record | remote | 129.21.42.42 | Automatic |
Save your changes for this new record.
Debugging
While debugging my setup, I came across a reddit post [4] with great details on using inadyn
within the Unifi OS to flush its cache. This requires SSH access to the Unifi console.
Checker
I made a bash script to check and compare the DDNS entry with the current public IP. This runs on a Raspberry pi running other home services as a cron job twice a day (00:00 + 12:00) and logs the output to a file.
/ I may convert this to a k8s time task. /
References:
-
https://www.namecheap.com/support/knowledgebase/article.aspx/583/11/how-do-i-configure-ddclient/
-
https://sionwilliams.com/posts/2021-03-28-unifi-namecheap-dynamic-dns/
-
https://www.reddit.com/r/Ubiquiti/comments/10zrz8f/udmp_dynamic_dns_settings_for_namecheap/
-
https://www.reddit.com/r/Ubiquiti/comments/1862ivc/how_to_debug_dynamic_dns_and_setup_namecheap/