Skip to content

Cloudflare DNS Setup: Add Domain, Configure Records — Complete Guide

DodaTech Updated 2026-06-23 5 min read

In this tutorial, you will learn how to add a domain to Cloudflare, configure DNS records including A, CNAME, and MX entries, and verify that name resolution is working correctly for your web properties.

Why DNS Setup on Cloudflare Matters

DNS is the phonebook of the internet — it maps human-readable domain names to machine-readable IP addresses. Cloudflare's DNS is one of the fastest in the world, with a global anycast network that averages under 10ms response times. Without proper DNS setup, your visitors cannot reach your site, and your email cannot be delivered. This tutorial is the foundation for everything else you will do with Cloudflare.

Real-world use: When a user types example.com into a browser, DNS resolves it to an IP address. Cloudflare performs this resolution in under 5ms from nearly any location on earth, and it also protects against DDoS attacks and hides your origin server IP.

DNS Resolution Flow

flowchart LR
  A[User types example.com] --> B[ISP DNS Recursor]
  B --> C[Cloudflare NS]
  C --> D[Cloudflare Edge]
  D --> E[Origin Server]
  D --> F[DDoS Protection]
  D --> G[SSL Termination]
  style C fill:#f90,color:#fff
  style D fill:#f90,color:#fff

Prerequisites

Before you start, you need:

  • A registered domain name (purchased from any registrar)
  • A Cloudflare account (free tier works)
  • Access to your domain registrar's DNS settings panel
  • Your origin server IP address or hostname

Step 1: Add Your Domain to Cloudflare

Log in to your Cloudflare dashboard and click "Add a Site". Enter your domain name and click "Add Site". Cloudflare scans your existing DNS records automatically and presents them for review.

# After adding the domain, Cloudflare shows you two nameservers like:
# darl.ns.cloudflare.com
# neil.ns.cloudflare.com
# You must update these at your registrar.

Expected output: Cloudflare displays a list of existing DNS records from your current provider. Review and confirm them, then proceed to the nameserver update step.

Step 2: Update Nameservers at Your Registrar

Go to your domain registrar (Namecheap, GoDaddy, Google Domains, etc.) and find the "Custom Nameservers" or "DNS Management" section. Replace the existing nameservers with the Cloudflare nameservers shown in step 1.

# Before (at registrar)
ns1.yourregistrar.com
ns2.yourregistrar.com

# After (at registrar)
darl.ns.cloudflare.com
neil.ns.cloudflare.com

Expected output: The registrar confirms the changes. Propagation takes 5-30 minutes for most TLDs, though it can take up to 48 hours for some older registry systems.

Step 3: Verify Nameserver Propagation

Use whois or dig to verify that your nameservers have updated globally.

dig NS example.com +short
# Expected output:
# darl.ns.cloudflare.com.
# neil.ns.cloudflare.com.
whois example.com | grep -i "name server"
# Expected output:
# Name Server: DARL.NS.CLOUDFLARE.COM
# Name Server: NEIL.NS.CLOUDFLARE.COM

Step 4: Create DNS Records

Once Cloudflare is authoritative for your domain, create the necessary DNS records. At minimum you need an A record for your web server.

# Create an A record pointing to your origin server
# Type: A
# Name: @ (root domain)
# IPv4: 203.0.113.10
# Proxy status: Proxied (orange cloud)
# TTL: Auto

# Verify with dig
dig A example.com +short
# Expected output:
# 203.0.113.10

When the orange cloud (proxied) is enabled, Cloudflare's CDN serves your content and hides your origin IP. When gray cloud (DNS only) is selected, traffic goes directly to your origin.

Common DNS Record Types You Will Need

Record Type Purpose Example
A Maps domain to IPv4 example.com -> 203.0.113.10
AAAA Maps domain to IPv6 example.com -> 2001:db8::1
CNAME Alias to another domain www -> example.com
MX Mail server routing @ -> mail.example.com
TXT Verification and SPF @ -> v=spf1 include:_spf.<a href="/web-servers-hosting/cloudflare/">Cloudflare</a>.com

Verify Everything Works

Run a final check to confirm all records resolve correctly.

dig A example.com +short
dig AAAA example.com +short
dig MX example.com +short
dig TXT example.com +short

Expected output: Each command returns the corresponding record value you configured. Empty output for AAAA is acceptable if you do not have IPv6.

FAQ

How long does DNS propagation take?

Typically 5-30 minutes for Cloudflare nameservers, but full global propagation can take up to 48 hours depending on TLD and ISP cache policies.

Can I keep my existing nameservers with Cloudflare?

No. Cloudflare requires you to use their nameservers to become authoritative for your domain. This is how they route traffic through their edge network.

What happens to my email during nameserver change?

Your email may experience brief interruptions during propagation. Keep your MX records intact in Cloudflare's DNS settings to minimize downtime. Set the MX records to DNS-only (gray cloud) since Cloudflare does not proxy email traffic.

Practice Questions

  1. What is the primary purpose of updating nameservers when adding a domain to Cloudflare?
  2. Why should MX records be set to DNS-only (gray cloud) rather than proxied (orange cloud)?
  3. What command do you use to verify that Cloudflare nameservers are authoritative for your domain?

Summary

Adding a domain to Cloudflare requires four steps: add the site, copy the Cloudflare nameservers, update them at your registrar, and configure your DNS records. Once complete, Cloudflare handles all DNS resolution through its global anycast network, providing speed, security, and reliability.

This pattern is used by Doda Browser's sync services and Durga Antivirus Pro's update infrastructure to ensure fast and secure name resolution worldwide. Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro — security-first tools for the modern web.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro