phone

How To Use Cloudflare To Manage Your DNS

How to setup DNS on CloudFlare

If you’re reading this, we’re probably looking to manage DNS for your site on Cloudflare.

This post will walk you through that process, whichever way you would like us to go about it. First, here are some definitions of terms that might be helpful to know.

Helpful Definitions

Registrar
This is the company that you registered your domain name with, such as GoDaddy, Namecheap, Register.com, etc. It's also used here to refer to their website.

DNS Record
Domain Name System Record. An entry that primarily associates a URL with an IP address or another URL.

Nameserver
This is the server(s) that host the DNS records for a given domain. This is usually your registrar, but can be delegated to another server through the use of NS records.

CDN
Content Distribution Network. This is a collection of servers around the globe that hold temporary copies of portions of your site, such as images. Traffic routed through a CDN will retrieve such resources from these servers rather than your hosting server, improving load time and reducing load on the hosting server.

What Is Cloudflare?

Cloudflare is a service that, among other things, is used to host and manage DNS records. These are the records that point your computer to a website's IP address.

Normally this is done from your registrar (the place where you set up your domain name), but this task can be delegated to an external service.

Why Cloudflare?

The primary feature we're concerned with is called CNAME flattening. Ordinarily, due to some potential conflicts, you cannot point a top-level domain (top-level meaning there's no prefix such as www., mail., blog., etc) at another URL - It has to point to an IP address. This works fine most of the time, but if you want that IP to change, you have to update the record every time.

With CNAME flattening however, this is possible. They track down the final address of the URL you're pointing to, and then return that.

WP Engine, one of our hosting providers, does change your IP address on rare occasion - with as much notice as possible - for several reasons. As there may be emergencies which require things to be shuffled around, there may not be as much notice as would be preferred.

Fortunately, with CNAME flattening, we can point your domain name to a separate domain whose address is managed by WP Engine. Thus, if they should move your site, it will still resolve correctly.

We may or may not wish to active Cloudflare's CDN for your site - this will be decided case-by-case.

Setting Up Cloudflare

Should you choose to do so, you have a few options for getting set up.

The first is to delegate or otherwise grant us access to your registrar. Often this can be done by adding [email protected] as a technical contact, but not all registrars allow for this, so it may be necessary to send us direct access to your account.

How to Add DNS Records:
The exact method varies depending on who your domain is registered with, but here are instructions for some registrars.

Using SearchLab Cloudflare Manage Your DNS

If you'd prefer not to give us registrar access, but are willing to let us manage DNS through our Cloudflare account, here are the steps to set that up.

Note: While this will allow us to make DNS changes, you'll be able to revert this by changing back to your registrar's nameservers.

How to Setup SearchLab Cloudflare:
  1. Log in to your registrar, and go to the DNS management page for the site in question (sometimes this is called 'Advanced DNS')
  2. Copy or take a screenshot of all the records, and send them to your SearchLab contact (probably your project manager).
  3. Once SearchLab has set up Cloudflare with your domain records, you can change the nameservers. The exact method of doing so will vary depending on your registrar (see list above).
  4. Find your nameserver entries. These are usually located on the same page as your DNS records, and may be done by editing the NS (nameserver) records in that list.
  5. Change your DNS entries to these values:

       aragorn.ns.cloudflare.com
       melissa.ns.cloudflare.com  
  6. Wait. It will take some time for the change to propagate throughout the internet.

Creating Your Own Cloudflare Account

You may wish to use Cloudflare, but prefer to use your own account. Here are step by step instructions to setting up your own Cloudflare account:

How to Setup a Cloudflare Account:
  1. Go to Cloudflare and Sign up and/or Log In from the upper-right hand corner.
  2. Click Add Website and enter your domain name, leaving out any prefixes such as www., m., etc.
  3. Click on Begin Scan. Cloudflare will now try to find all the records for your domain.
  4. The scan doesn't always find everything, so go back to your registrar (or wherever your DNS is managed), and make sure that Cloudflare matches what it's showing. If not, add whatever is missing to Cloudflare. To do so, start by selecting the record type, then fill in the other fields accordingly.
  5. If the CDN is turned on for an entry (if the cloud is orange) click on it to toggle it to off. 
  6. Log in to your registrar, and go to your DNS management page. Check that everything found there is in Cloudflare, and add anything that's missing.
  7. Hit continue back on the Cloudflare page, select your plan (free is fine), and finalize the setup.
  8. Switch to the Cloudflare nameservers in your registrar. The method here varies depending on where your domain is registered.

    This can usually be done from the same page that has your DNS records, and may be done by editing your nameserver records (see How to Add DNS Records above).
  9. Use these nameservers:
    aragorn.ns.cloudflare.com
    melissa.ns.cloudflare.com 
  10. Wait. It will take some time for the change to propagate throughout the internet.