EdgeRouter CNAME records

Hey! Listen! This post is part of a series on the Ubiquiti EdgeRouter Lite. Check them all out!

DateURLPart
2019-02-03EdgeRouter CNAME records
  • Setup CNAME records
  • 2017-10-03Dyn DDNS on EdgeRouter
  • Setup DynDNS
  • 2017-04-25DuckDNS on EdgeRouter
  • Setup DuckDNS
  • 2017-01-08Ubiquiti EdgeRouter serial console settings
  • Serial console settings
  • 2016-11-29Ubiquiti UniFi controller setup on Raspberry Pi 3
  • Install UniFi Controller
  • 2016-08-30EdgeRouter Lite Dnsmasq setup
  • Setup dnsmasq
  • 2016-06-13EdgeRouter Lite software upgrade
  • Firmware upgrade
  • 2016-05-12EdgeRouter Lite OpenVPN setup
  • OpenVPN server setup
  • 2016-04-29Ubiquiti EdgeRouter Lite setup
  • Initial setup
  • Introduction

    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 --> 11.22.33.44
    example.com     --> 11.22.33.44

    However, with a CNAME record, you can do this:

    www.example.com --> example.com           <-- This is the CNAME record
    example.com     --> 11.22.33.44

    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!

    Logan

    Leave a Comment

    This site uses Akismet to reduce spam. Learn how your comment data is processed.