How to Add DNS in Cloudflare: A Detailed Guide
Setting up DNS in Cloudflare is a powerful way to improve your website’s security, speed, and reliability. Cloudflare offers features like DDoS protection, caching, and SSL, making it a popular choice for website owners. In this comprehensive guide, we’ll walk you through every step to add DNS records in Cloudflare, from setting up your account to configuring DNS settings.
Step 1: Create a Cloudflare Account
- Go to the Cloudflare website and click on Sign Up.
- Enter your email address and create a password.
- Once you’ve created an account, log in to access the Cloudflare dashboard.
Step 2: Add Your Domain to Cloudflare
- In the Cloudflare dashboard, click Add a Site at the top right.
- Enter your domain name (e.g.,
example.com
) and click Add Site. - Cloudflare will prompt you to select a plan. Cloudflare offers several plans, from Free to Enterprise. Choose the plan that best fits your needs and click Continue.
Step 3: Cloudflare Scans for Existing DNS Records
After adding your domain, Cloudflare will automatically scan your existing DNS records. This scan will identify records such as A, MX, CNAME, and TXT that may already be set up with your current DNS provider.
- Review the list of scanned DNS records.
- Ensure all necessary records are listed. If any are missing, you can add them manually (details below).
- Click Continue when you’re ready to move forward.
Step 4: Update Nameservers
To use Cloudflare’s DNS, you need to point your domain to Cloudflare’s nameservers.
- Cloudflare will display two nameservers assigned to your account (e.g.,
lana.ns.cloudflare.com
andgabe.ns.cloudflare.com
). - Log into your domain registrar’s website (the platform where you registered your domain).
- Locate the DNS or Nameservers section for your domain.
- Replace the existing nameservers with the Cloudflare nameservers provided.
- Save the changes at your registrar.
Note: It may take up to 24-48 hours for the DNS changes to propagate fully. During this time, your domain may experience brief connectivity disruptions.
Step 5: Add DNS Records in Cloudflare
After updating the nameservers, you can start managing your DNS records in Cloudflare. Here’s a breakdown of how to add and configure various types of DNS records:
Common DNS Records and How to Add Them
A Record
The A (Address) record points a domain or subdomain to an IP address. Here’s how to add an A record in Cloudflare:
- Go to the DNS tab in your Cloudflare dashboard.
- Select Add Record.
- Choose A from the Type dropdown.
- Enter the Name (e.g.,
@
for the root domain orwww
for a subdomain). - Enter the IPv4 address (e.g.,
192.0.2.1
). - Choose Proxied to route traffic through Cloudflare, or DNS only if you prefer direct DNS.
- Click Save.
CNAME Record
A CNAME (Canonical Name) record redirects one domain to another domain name.
- Under the DNS tab, click Add Record.
- Select CNAME from the Type dropdown.
- Enter the Name (e.g.,
blog
to set upblog.example.com
). - Enter the Target (e.g.,
example.net
to pointblog.example.com
toexample.net
). - Choose Proxied or DNS only based on your preference.
- Click Save.
MX Record
An MX (Mail Exchange) record routes email for your domain to the correct mail servers.
- Go to the DNS tab and click Add Record.
- Choose MX from the Type dropdown.
- Enter the Name (
@
for root domain). - Enter the Mail server (e.g.,
mail.example.com
). - Enter the Priority (the lower the number, the higher the priority).
- Click Save.
TXT Record
A TXT (Text) record is often used for domain verification and includes descriptive text.
- In the DNS section, click Add Record.
- Choose TXT from the Type dropdown.
- Enter the Name (often
@
for the root domain). - Enter the Content (e.g.,
v=spf1 include:_spf.example.com ~all
). - Click Save.
SRV Record
SRV records specify a service’s location, such as a VoIP or chat server.
- Under DNS, click Add Record.
- Select SRV from the Type dropdown.
- Enter the Service (e.g.,
_sip
). - Enter the Protocol (
TCP
orUDP
). - Enter the Name, Target, Priority, Weight, and Port.
- Click Save.
Step 6: Enable Cloudflare Features for Added Security and Performance
Once your DNS settings are configured, you can enable additional Cloudflare features to optimize your site.
- SSL/TLS: In the SSL/TLS settings, select the SSL mode (e.g., Flexible, Full, Full (Strict)) to secure your site with HTTPS.
- Caching: Enable caching to improve your website’s speed. Cloudflare caches static content to reduce server load.
- Firewall: Configure the Cloudflare firewall to add extra protection against threats like DDoS attacks.
- Speed Optimization: In the Speed tab, enable features like Auto Minify (for CSS, JS, and HTML) and Brotli compression.
Step 7: Verify DNS Settings and Domain Status
To ensure everything is working as expected:
- Go to the Overview tab in your Cloudflare dashboard.
- Cloudflare will display your domain status. It should say Active if your nameservers have been updated successfully.
- Use the DNS Propagation Checker (optional) to verify that your DNS settings have propagated globally.
Troubleshooting Common Issues
- DNS Propagation Delay: If changes are not visible immediately, it might be due to DNS propagation. Allow up to 24 hours.
- Incorrect Record Entries: Double-check all entries for typos and correct IP addresses.
- SSL Issues: Make sure SSL mode matches your server’s SSL certificate. For example, if your server has a full SSL, choose Full (Strict) in Cloudflare.
Conclusion
Setting up DNS records in Cloudflare is an essential step for improving your website’s security and performance. Cloudflare’s robust DNS management and additional features make it easy to protect your site, enhance loading speeds, and manage your domains effectively. Follow this guide to confidently set up your DNS records in Cloudflare, and take advantage of the powerful features it offers.