May 15 2014

Alias Record

Posted by Vitalie Cherpec

Today we are introducing the ALIAS Record, this pseudo record allows you to add CNAME functionality to root (naked, apex, bare) domains.

The problem

Many PaaS/service providers (Ex: Heroku, AppFog, dotCloud, GitHub Pages, etc) are requiring a CNAME record to work properly with custom domains. The DNS standards impose a restriction regarding CNAME records, when using a CNAME no other data should exists for that name. A CNAME at root is not a valid configuration because a minimum zone definition includes at least one SOA record and one NS record.

Solution

To avoid this CNAME restriction with root domains the ALIAS pseudo record should be used.

How it Works

The build system flattens the CNAME record resolving the CNAME and returning directly the IP4 & IPv6 addresses instead of CNAME.

Alias Syntax:

alias(name, target, ttl)

When you are creating an ALIAS record, the target is automatically resolved and A & AAAA are injected for the name. The target is polled periodically and A && AAAA records are updated when changes occurs. Polling frequency is using the ttl parameter.

The DNS provider for target may use multiple IP addresses in a Round Robin DNS configuration. While resolving target multiple DNS queries are issued in order to capture multiple unique IP addresses (up to 4 x IPv4 and 4 x IPv6).

Usage

Example usage of ALIAS record:

-- templates/heroku.lua
function heroku_app(root, app)
  -- Use alias for root domain
  -- Syntax: alias(name, target, ttl)
  alias(root, app, 300)

  -- Use a CNAME for www
  -- Syntax: cname(name, target, ttl)
  cname(concat("www", root), app)
end

-- example.com.lua
heroku_app(_a, "myapp.herokuapp.com")