Hey! Listen! This post is part of a series on the Ubiquiti EdgeRouter Lite. Check them all out!
|2019-06-28||Migrating away from the Ubiquiti EdgeRouter Lite||Migrated to a Netgate SG-1100|
|2019-02-03||EdgeRouter CNAME records||Setup CNAME records|
|2017-10-03||Dyn DDNS on EdgeRouter||Setup DynDNS|
|2017-04-25||DuckDNS on EdgeRouter||Setup DuckDNS|
|2017-01-08||Ubiquiti EdgeRouter serial console settings||Serial console settings|
|2016-11-29||Ubiquiti UniFi controller setup on Raspberry Pi 3||Install UniFi Controller|
|2016-08-30||EdgeRouter Lite Dnsmasq setup||Setup dnsmasq|
|2016-06-13||EdgeRouter Lite software upgrade||Firmware upgrade|
|2016-05-12||EdgeRouter Lite OpenVPN setup||OpenVPN server setup|
|2016-04-29||Ubiquiti EdgeRouter Lite setup||Initial setup|
What is a CNAME record?
A canonical name (CNAME) record is a special type of DNS record that points one domain name to another.
It’s easier to explain with an example. Let’s say you own the website example.com, and you want to setup both www.example.com and example.com to go to the same place application (e.g., WordPress). You could maintain two separate A records, like this:
www.example.com --> 220.127.116.11 example.com --> 18.104.22.168
However, with a CNAME record, you can do this:
www.example.com --> example.com <-- This is the CNAME record example.com --> 22.214.171.124
With this setup, if your server address changes, you only need to update one record (the record for example.com).
CNAMEs as “shortcuts”
The really cool part about CNAME records is that you can create DNS “shortcuts” with them.
Time for another example. Let’s say you want to setup a backup server (with the hostname backup01) at your house and connect all your devices to it. This way, every device can backup to one central location.
device01 --\ device02 ---|--> backup01.localdomain device03 --/
However, eventually, the server named backup01 will need to be replaced with backup02, and when that happens, you’ll need to reconfigure every device in your house to point to the new server. But, what if you could setup a DNS name between each device and the backup server? This record is the CNAME record.
device01 --\ device02 ---|--> storage.localdomain --> backup01.localdomain device03 --/
With this setup, you can point every device to storage. Then, when backup01 eventually needs to be replaced with backup02, you can just update the CNAME record of storage. This is exactly what I’m using CNAME records for at home.
Setting up CNAME records
First, you’ll need to be using dnsmasq on your EdgeRouter instead of the default DHCP server (written by the ISC). If you don’t have dnsmasq running, I have a quick guide for that here, and Ubiquiti’s official guide is here.
Next, you simply set your CNAME records with the command below. In this case, storage is the CNAME record, while backup01 is the actual server name.
configure set service dns forwarding options cname=storage.localdomain,backup01.localdomain commit save
Now, you can use the name storage on all your devices, and then update the CNAME record when you replace the server that’s behind the record.
Hope this helps!