
Cloudflare's DNS records are a crucial part of managing your online presence. Cloudflare offers a comprehensive set of DNS records that can be used to configure various aspects of your website or application.
To get started with Cloudflare DNS records, you'll need to create a Cloudflare account and set up a DNS zone. This involves linking your domain to Cloudflare and configuring your DNS settings.
Cloudflare supports a wide range of DNS record types, including A, CNAME, MX, and TXT records. These records can be used to point your domain to a specific IP address, create aliases for your domain, and more.
Cloudflare's DNS records are designed to be flexible and scalable, making them suitable for websites and applications of all sizes.
Creating and Managing Records
Creating a DNS record in the Cloudflare dashboard involves selecting an account and domain, going to DNS > Records, and choosing Add record. From there, you'll select a record Type and complete the required fields, which vary per record.
To create records with the API, you'll use a POST request, and for field definitions, select a record type under the request body specification. You can also refer to DNS record types for specific API examples.
You can create a new DNS record directly from cloudflared, which will create a CNAME record that points to the tunnel subdomain. However, this will not proxy traffic if the tunnel is not currently running.
Here are the steps to create a DNS record using the API:
Create Records
To create records, you can either use the Cloudflare dashboard or the API. In the dashboard, you can select an account and domain, go to DNS > Records, and then select Add record.
To create a DNS record, you'll need to choose a record Type and complete the required fields, which vary per record. For example, for a CNAME record, you'll need to input the target hostname.

You can create a new DNS record for your tunnel by logging in to the Cloudflare dashboard, selecting your account and domain, and going to DNS > Records. Then, select Add record and input the required information.
If you want to create a DNS record using the API, you'll need to use a POST request. For field definitions, select a record type under the request body specification.
To create multiple DNS records that point to the same tunnel subdomain, you'll need to create a CNAME entry for each hostname. This is useful if you're routing traffic from multiple hostnames to multiple services.
Here are the steps to create a DNS record:
- Log in to the Cloudflare dashboard and select an account and domain.
- Go to DNS > Records.
- Select Add record.
- Choose a record Type.
- Complete the required fields.
- Select Save.
Cf Flatten Cname
If you're on a paid zone and want to use Per-record CNAME flattening, you can use the tag cf-flatten-cname next to each flattened CNAME record in your zone file.
This tag is automatically added to reflect the record configuration when you export your zone. The tag is specifically designed for paid zones, so if you're on a free zone, you won't need to worry about it.
To use this feature, simply add the cf-flatten-cname tag next to each flattened CNAME record in your zone file. This will enable Per-record CNAME flattening for your paid zone.
Additional reading: Dns Records Pihole Use Port
DNS Record Types
To create a DNS record, you'll need to choose a record type. This can be done through the Cloudflare dashboard or API.
The Cloudflare dashboard allows you to select a record type when creating a new record. In contrast, the API requires a POST request with a record type specified in the request body.
For specific record types, refer to the DNS record types documentation for field definitions and API examples.
Discover more: Dns Query Types
Ptr
PTR records specify the allowed hosts for a given IP address.
PTR records are used for reverse DNS lookups within Cloudflare.
PTR records should preferably be added to reverse zones.
PTR records are used for reverse DNS lookups.
Check this out: Ptr Records in Dns
Ns
NS records are used for authoritative DNS, indicating which server should be used.
You only need to add NS records to your DNS records table in Cloudflare when using subdomain setup or delegating subdomains outside of Cloudflare.
A nameserver record is required for subdomain setup or delegating subdomains.
Take a look at this: Virualservice Setup Dns Records
SVCB and HTTPS
Service Binding (SVCB) and HTTPS records allow you to provide a client with information about how it should connect to a server upfront, without the need of an initial plaintext HTTP connection.
If your domain has HTTP/2 or HTTP/3 enabled and proxied DNS records, Cloudflare automatically generates HTTPS records on the fly, to advertise to clients how they should connect to your server.
You can find more details and context in the announcement blog post.
For example, if you have SVCB records set up, clients can use them to establish a secure connection to your server without needing to make an initial plaintext HTTP request.
You might like: Fortigate Dns Server
Zone File Management
To manage your zone file effectively, you should format it correctly. This means ensuring that certain record types, such as CNAME, DNAME, MX, NS, PTR, or SRV records, contain fully qualified domain names ending in a trailing period, like example.com.
For instance, I once had to troubleshoot an issue with a CNAME record that didn't include the trailing period. It took me a while to realize the problem, but once I added the period, everything worked smoothly.
If you're importing your zone file to Cloudflare, follow these steps: Log in to the Cloudflare dashboard and select your account and domain.Go to DNS > Records.Select Import and Export.For Import DNS records, select your formatted file.If you don't want applicable records proxied, unselect Proxy imported DNS records.
A fresh viewpoint: Dns Zone Azure
Format Zone File
Formatting your zone file is crucial for DNS lookup to work correctly. Make sure to include fully qualified domain names ending in a trailing period for certain record types like CNAME, DNAME, MX, NS, PTR, or SRV records.
For instance, if you're using a CNAME record, the content should be example.com. This ensures that the DNS lookup process can resolve the domain name correctly.
You can refer to RFC 1035 for more details on the requirements for these record types.
You might enjoy: List of DNS Record Types
Import Zone File
Importing a zone file to Cloudflare is a straightforward process. You can do this by logging in to the Cloudflare dashboard and selecting your account and domain.
To get started, go to DNS > Records. This is where you'll find the option to import and export DNS records. Select Import and Export to proceed.
Next, choose the Import DNS records option and select your formatted file. Make sure it's in the correct format for Cloudflare to read it properly.
If you don't want Cloudflare to proxy the imported DNS records, unselect the Proxy imported DNS records option. This will prevent Cloudflare from caching the records.
Zone File Directives
Zone File Directives are an essential part of managing your DNS zone file. They allow you to add additional information and instructions to your zone file, making it easier to manage and maintain.
A DNS zone file can be constructed using directives in addition to resource records (RRs). Directives start with a dollar sign ($) and are standardized. For example, $ORIGIN and $INCLUDE are defined in RFC 1035.
Cloudflare supports three types of directives: $ORIGIN, $TTL, and $GENERATE. These directives can be used to specify the origin of the zone file, set a default TTL, and generate records automatically.
However, it's worth noting that Cloudflare does not support the $INCLUDE directive. If your zone file contains a $INCLUDE directive, Cloudflare will respond with a parsing error.
Here are the directives supported by Cloudflare:
Record Attributes and Settings
To create a DNS record, you'll need to select a record type. This can be done in the Cloudflare dashboard by choosing a record type under the "Add record" option.
You can also create records using a POST request with the API. For field definitions, refer to the record type under the request body specification.
When editing DNS records, you'll want to make any necessary changes and then select Save. This can be done in the dashboard by selecting Edit on a specific record.
To update part of a record with the API, use a PATCH request. If you want to overwrite the entire existing record, use a PUT request.
Optional settings in Cloudflare include cache rules and firewall policies, which will default to the settings of the hostname in your account that includes the Cloudflare Tunnel DNS record.
Cf Proxied
The cf-proxied tag is a crucial attribute in determining whether a DNS record should be proxied or not. This tag is present in proxied DNS records and has a value of true, while DNS-only records have a value of false.
If you're importing zone files, the value in the cf-proxied tag takes precedence over other settings. This means that if the tag is present, its value will override any general import options or API settings.
You might like: Dns Settings Hostinger
Here's a breakdown of how this works:
- If the tag is present, its value will be used regardless of the Proxy imported DNS records option being selected or the proxied parameter being set.
- If the tag is absent, the proxied status will fall back to the general import option, meaning Proxy imported DNS records selected or not, or the proxied parameter set to true or false.
Reserved CF Tags
Reserved CF tags are special tags that start with "cf-" and allow you to control specific Cloudflare configurations.
These tags are automatically added to your zone file on export, reflecting the current configuration for each record.
The cf-proxied tag is used to control proxying of DNS records. On export, proxied records will have cf-proxied:true, while DNS-only records will have cf-proxied:false.
The value in the cf-proxied tag takes precedence over other settings when importing zone files. If the tag is present, its value will be used, regardless of other import options.
If the tag is absent, the proxied status will fall back to the general import option.
Here's a summary of the cf-proxied tag behavior:
The cf-flatten-cname tag is used to enable per-record CNAME flattening. On export, this tag is automatically added to reflect the record configuration.
This tag is only applicable on paid zones.
IP Address and Tunnel Settings
To set up a Cloudflare DNS record, you'll need to know your IP address, which can be found in the "IP Address" section.
Cloudflare recommends using a static IP address, which can be set up through your internet service provider (ISP).
If this caught your attention, see: Azure Dns Server Ip
IP Address Resolution
IP Address Resolution is a crucial step in setting up your Cloudflare account. At least one IP address resolution record is required for each domain on Cloudflare.
These records are the only ones you can proxy through Cloudflare. They're a necessary part of the setup process, so be sure to create them for each domain.
By having the right IP address resolution records in place, you'll be able to take full advantage of Cloudflare's features and benefits. This includes improved security, faster page loading speeds, and enhanced performance.
For another approach, see: How to Fix a Dns Error
Create Tunnel Record
To create a tunnel record, start by logging in to the Cloudflare dashboard and selecting your account and domain. You can also create a new DNS record directly from cloudflared using a command.
When you create a new DNS record, you'll need to input specific information, including selecting "Add record" and inputting the tunnel subdomain as the target. Make sure to select "Save" to complete the process.
You can create multiple DNS records that point to the same tunnel subdomain, but keep in mind that each record should have its own CNAME entry if you're routing traffic from multiple hostnames to multiple services.
On a similar theme: Nextcloud Cloudflare Tunnel
Email and Authentication
Email authentication records are recommended for all domains, regardless of whether they send email messages, to protect against email spoofing.
Creating secure email records can help prevent spam and phishing attacks.
If your domain doesn't send email messages, you can learn more about creating recommended restrictive records.
A mail exchange (MX) record is required to deliver email to a mail server.
To create an MX record, you'll need to follow the MX record syntax.
Discover more: Dns and Mx Records
MX
MX records are a crucial part of the email delivery process.
To deliver email to a mail server, a mail exchange (MX) record is required. This record directs incoming email to the correct mail server.
MX record syntax is specific, and it's essential to get it right. The syntax is not explicitly mentioned here, but it's referenced as ↗.
To set up email delivery, you'll need to create an MX record. This involves specifying the mail server that should handle incoming email for your domain.
A fresh viewpoint: Dns over Quic Server
Email Authentication
Email authentication is crucial to protect your domain against email spoofing. Creating secure email records can help prevent this.
These records are recommended regardless of whether your domain sends email messages. They're a safeguard against unauthorized email sending.
If your domain is not used to send email messages, you can still benefit from creating restrictive records. This can help prevent email spoofing and keep your domain secure.
Suggestion: Dns Email Records
Limits
Cloudflare DNS records have some limitations to be aware of.
Cloudflare supports only three standardized directives: $ORIGIN, $TTL, and $GENERATE.
You can use the $ORIGIN directive to specify the origin of the DNS zone, which is the base domain name for all resource records.
The $TTL directive is used to set the default time to live for all resource records in the zone file.
The $GENERATE directive is a non-standard directive provided by BIND that allows you to generate a range of resource records.
Cloudflare does not support the $INCLUDE directive, which means you can't include the contents of another file in your zone file.
If you try to use a $INCLUDE directive in your zone file, Cloudflare will respond with a parsing error.
Discover more: Dns Resource Records
Deleting and Resolving Records
Deleting DNS records is a straightforward process. Click the appropriate Cloudflare account for the domain where you will delete records.
To delete a specific DNS record, head to the DNS Records section. Click X to delete the record.
You'll want to be careful when deleting records, as it's a permanent action. Make sure you have a backup of your DNS records before making any changes.
Featured Images: pexels.com


