Import and export records
Use import and export to have more control over your DNS records and make processes like migrating a domain or bulk editing record comments easier.
Create a BIND zone file ↗ for your domain. If you need help, use a third-party tool ↗.
If you are using certain record types — for example, CNAME
, DNAME
, MX
, NS
, PTR
, or SRV
records — make sure that the content of those records contains fully qualified domain names (which end in a trailing period like example.com.
). For more details, refer to RFC 1035 ↗ or this post on Stack Exchange ↗.
To import a zone file using the dashboard:
- 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 do not want applicable records proxied, unselect Proxy imported DNS records.
To import records using the API, send a POST request with a properly formatted file.
You can also bulk export records from Cloudflare.
To export records using the dashboard:
- Log in to the Cloudflare dashboard ↗ and select your account and domain.
- Go to DNS > Records.
- Select Import and Export.
- Select Export.
To export records using the API, send a GET request.
When exporting or importing a zone file, Cloudflare formats comments and tags using the following structure, appending the attributes as inline comment using the ;
character after each record in accordance with RFC 1035 section 5 ↗:
Combination | Description |
---|---|
Only tags | Tag names contain a small set of characters. Additionally, tag values must be contained by a double quote ( " ) if they contain " , = , , , or \ . When enclosed within double quotes (" ), tag values are represented as JSON strings, so other quotes within the value can be escaped as \" .A tag with an empty value can be represented either as my-tag-name:"" , my-tag-name: , or my-tag-name . |
Only a comment | Comments have fewer limitations on characters, meaning that the comment is included verbatim. If the comment includes the string cf_tags= , you need to include an additional cf_tags= at the end of the line. |
Comment and tags | The zone file comment would be of the form ; <comment> cf_tags=<tags> , as described above. Note the added space character before cf_tags= . |
Neither attribute | The comment in the zone file may be empty or omitted entirely. Comments in the zone file that do not immediately follow a record are also ignored. |
A DNS zone file can be constructed using directives in addition to resource records (RRs). Directives start with $
and are standardized - $ORIGIN
and $INCLUDE
are defined in RFC 1035 ↗, and $TTL
is defined in RFC 2308 ↗. Additionally, BIND provides the non-standard ↗ $GENERATE
directive.
Cloudflare supports $ORIGIN
, $TTL
, and $GENERATE
directives.
$INCLUDE
is not supported. When a zone file contains a $INCLUDE
directive, Cloudflare responds with a parsing error $INCLUDE directive not allowed
.