Skip to main content

CNAME Flattening for Web Agencies

CNAME Flattening for Web Agencies

The acquisition of Cloudways by Digital Ocean stirred up quite a few conversations about how challenging it can be to migrate websites to a new server or platform. Justin Korn shared a fantastic post in The Admin Bar Facebook Community explaining how he uses CNAME Flattening to manage all that mess.

I’ve been using CNAME Flattening for a long time in pretty much the same way he described, and I was surprised to see that this concept was new for so many people. A text write-up of CNAME Flattening can get a little complicated, so I thought I’d do a quick video to help describe it.

This video assumes that you have a basic understanding of DNS concepts. If you need a refresher, you can visit my blog post called Domains & DNS Definitely Demystified, which lays the foundation for you.

YouTube video

Resources

Transcript

The Problem

PowerPoint Slide titled The Problem. The text on the slide is described in this post.

As Agencies, we manage a lot of websites. And all those websites have their own individual set of DNS servers and DNS records. We also might not have access to all the DNS servers. A lot of times, clients will manage them themselves, or they’ll have their IT departments and vendors handle it for them. Moving websites between servers can also be a logistical nightmare for all of us. 

A Simple Solution

PowerPoint Slide titled A Simple Solution. The text on the slide is described in this post.

A simple solution to all of this is called CNAME flattening. Some other places call these ANAMEs or ALIASs, but really what it does is it lets us use a CNAME record to get the root IP addresses for a domain from a different domain. That lets us control all our client’s host records from a domain that we control, and it allows your clients to maintain control over their own DNS servers while we manage the website-related records on our own servers. 

For this to work, though, both your DNS server and the client DNS server have to support this. Some of the big-name DNS servers that do support it are Cloudflare, DNS Made Easy, DNSimple, Easy DNS, and Amazon. Unfortunately, places like GoDaddy and Google domains do not support it. 

Technical Articles

If you’re interested in the technology behind all of this, there are some great resources out there. Cloudflare has a blog post called Introducing CNAME Flattening: RFC-Compliant CNAMEs at a Domain’s Root, and DNS made easy has a blog post called How does CNAME flattening work? I definitely recommend checking both of those out. 

How to Configure CNAME Flattening

PowerPoint Slide titled How to Configure CNAME Flattening. The text on the slide is described in this post.

So to set this up, you would need to do things on both your server and the client’s server. On your server, you start by creating a dummy domain, something like myagencyrecords.net, and this is what’s going to hold all the records for your clients and for your servers. Then, you’ll create ANAMEs which are host records for your servers. Things like server1.myagencyrecords.net will point to 135.148.47.71, etc. Then you would create CNAME alias records for each of your client sites. Something like client1 one would point to server1.myagencyrecords.net, client2.myagencyrecords.net would point to server1.myagencyrecords.net, etcetera, etcetera until you have all of your clients on there pointed to the CNAME records for all of your servers.

On the client side, you want to make sure that you delete the A record for the root domain. In this example, the A record for client1.com would be deleted. Then you would create a new CNAME record for that root domain, and you’d point the CNAME to the client record that you created on your server. For example, you might point client1.com to client1.myagencyrecords.net. Look very carefully, though, that you point that CNAME record to the client record on your server, not the server record. I’ll get to that in a minute.

The last thing you want to do is make sure that the WWW CNAME record points to the root domain. This just keeps you from having to manage yet another record since most times, that WWW CNAME name is going to go to the same place as the root domain.

How does this work?

PowerPoint Slide titled How does this work. The text on the slide is described in this post.

Let’s see how all this works in practice. We start off by wanting to go to client1.com. Client1’s DNS server is going to respond and say, “Hey, I see a CNAME record for client1.com. It points to client1.myagencyrecords.net. Let’s get you an IP address for that.” Then the Client1 DNS server says, “Hey, myagencyrecords.net, What’s the IP address for client1.myagencyrecords.net?” Myagencyrecords.net’s DNS server comes back and says, “Cool, I have CNAME for this, and it points to server1.myagencyrecords.net, and the IP address for server one is 135.148.47.71.” Client1’s DNS server then gets that IP address and says, “Awesome! I got that!” and it tells the client, “Hey, I talked to everybody, and here’s the address you’re looking for.”

Looking up a Flattened Record 

PowerPoint Slide titled Looking Up a Flattened Record. The text on the slide is described in this post.

Put another way, to get the IP address for client1.com; you’ll start off by getting that CNAME for client1.myagencyrecords.net. That CNAME points to another CNAME for server1.myagencyrecords.net. And that server record points to an A record that says 135.148.47.71. The CNAME flattening process just flattens all those steps so that client1.com can get that IP address of 135.148.47.71.

And for the next part of that, to resolve the WWW, you’re just getting that CNAME record for www, and it’s saying, “Hey, the IP address for this is the same thing as the IP address for the root domain.”

Questions & Answers

PowerPoint Slide titled Questions and Answers. The text on the slide is described in this post.

So here are a few questions and answers about the whole thing.

  • Q: Can’t I just point the CNAME for client1.com to an A record on myagencyrecords.net?
    • A: Yep. You can do that, and it’ll work just fine. The downside is that you’ll have tons of duplicate A records to manage. The CNAME that points to the server lets you change an IP address in one place and have it reflected for all clients that are using that server.
  • Q: Does this slow things down?
    • A: The performance hit is negligible, especially compared to all the other things happening. Besides, chances are that the servers that support CNAME Flattening already have most of this cached anyway.
  • Q: I’m getting a Cloudflare Error 1014: CNAME Cross-User Banned. What’s that?
    • A: Flattening is seamless when both client and agency records are on the same Cloudflare account. If they are on separate accounts, you may need to use the (paid) CloudFlare for SaaS addon.
  • Q: Does this work with CDNs?
    • A: You’ll have to check your specific DNS servers. I have successfully used it with DNS Made Easy and QUIC.Cloud but most of my clients use Cloudflare so I haven’t tested it with too many providers.

Wrap Up

I hope this was helpful, and if you have any questions, don’t hesitate to reach out to me. You can find me on the web at www.peakperformancedigital.com

Recent Posts

  • Pinegrow is Not a Page Builder

    After yesterday’s announcement of the Pinegrow WordPress plugin, the question I was asked over and over was, “How is this different from every other page builder?” Put simply, Pinegrow is not a page builder. It’s a fully featured, visual, custom blocks and themes builder.

  • A new kind of visual builder plugin for WordPress

    Today I have something special to share with you. It’s a first look at the most flexible, powerful, way to create native, custom WordPress blocks and themes with little to no code.

  • Create a Native WordPress Block Plugin Using Pinegrow Web Editor

    In this tutorial, we create a plugin with native WordPress blocks to display a custom biography grid using the Pinegrow Web Editor.

  • Creating an Accessible HTML and CSS Biography Card Using the Pinegrow Web Editor

    In this video, I show how we can build an accessible and responsive biography grid using plain HTML and CSS inside the Pinegrow website editor.

  • CNAME Flattening for Web Agencies

    The acquisition of Cloudways by Digital Ocean stirred up quite a few conversations about how challenging it can be to migrate websites to a new server or platform. Justin Korn shared a fantastic post in The Admin Bar Facebook Community explaining how he uses CNAME Flattening to manage all that mess. I’ve been using CNAME […]