Skip to content
Coritan Docs

Import and export a zone file

Copy DNS records into a zone from a BIND zone file, or download a zone's records as one.

View as Markdown

In the dashboard

A zone file lists DNS records in the text format that BIND and most DNS providers use. Import one to copy many records into a Coritan zone at once, such as when you move a domain's DNS from another provider. Export one to keep a copy of a zone or to move its records elsewhere.

  • The domain's DNS must be hosted on Coritan. If its DNS tab says No DNS zone for this domain, add the domain as an existing domain first.
  • To move records from another provider, download the zone file from that provider.

Import records from a zone file

Section titled Import records from a zone file
  1. In the dashboard, go to Websites, open the domain and select the DNS tab.
  2. Select More DNS actions, the three-dot button above the records table, then Import zone file….
  3. Paste the file into Zone file. Check it against How the import reads a file first.
  4. Select Import records.

Coritan reads the file one line at a time and adds a record for each line it can read. Write each record on one line, in the order name, TTL, class, type and content. A line needs at least four parts separated by spaces, so keep the TTL or the IN on a record whose content is one word, such as an A record:

DNS
@                3600 IN A     203.0.113.10
www              3600 IN CNAME example.com.
@                3600 IN MX    10 mail.example.com.
mail             3600 IN A     203.0.113.20
@                3600 IN TXT   "v=spf1 mx -all"
_minecraft._tcp  3600 IN SRV   0 5 25565 play.example.com.
Name
@ for the domain, a name relative to the zone such as www, or the full name with a trailing dot, such as www.example.com.. Every line starts with its name. Coritan does not carry a name over from the line above, as BIND does for a line that starts with a space.
TTL
Optional. A line without one gets 300 seconds, whatever $TTL says. Coritan moves a TTL below 60 or above 86,400 seconds to the nearest of the two.
Class
IN, which is optional.
Type and content
The types and formats in DNS record types, checked by the same rules as the dashboard. Write every hostname in the content in full, such as mail.example.com.. Coritan reads a hostname without its trailing dot as complete, where BIND would add the zone's domain to it. A hostname cannot be @: name the domain in full.

The import leaves out:

  • Blank lines, lines that start with ;, and lines that start with $, such as $ORIGIN and $TTL. The records always go into the zone you import into.
  • The SOA record, which it reports as an unsupported type. The zone keeps its own.

Before you import, remove comments at the ends of lines, and put a record that spans several lines in brackets onto one line. The import reads a comment as part of the content, and it cannot read a record over several lines.

The import does not compare the file with the records the zone already has. It adds records beside them, so importing a file twice adds every record twice. It also accepts a CNAME beside other records at the same name, which the dashboard refuses. Imported A and AAAA records are DNS only; turn Proxied on for the ones that should go through Coritan's edge (Add, edit and delete DNS records).

  1. On the domain's DNS tab, select More DNS actions, then Export zone file.
  2. Your browser downloads the file, named after the domain, such as example.com.zone.

The file starts with the zone's SOA record and lists every record, sorted by name and type:

DNS
; Zone file for example.com
$ORIGIN example.com.
$TTL 300

@    300    IN  SOA    ns1.coritan.com. hostmaster.example.com. ( 2026092501 7200 3600 1209600 300 )

@    86400  IN  NS     ns1.coritan.com
@    3600   IN  MX     10  mail.example.com
www  3600   IN  CNAME  example.com
  • The file writes a hostname in content without its trailing dot. Coritan's import reads the file as it is, but before you load it into another provider, add the dot to each hostname: BIND and most providers would read mail.example.com as mail.example.com.example.com.
  • A proxied record is written with the address you entered, and nothing marks it as proxied.
  • Record comments are left out.

After an import, the dashboard reports how many records it added and how many lines it could not read, such as 12 records imported; 2 lines skipped. The new records appear in the table, and Coritan's nameservers answer with them straight away. After an export, the dashboard confirms Zone file for example.com downloaded.

2 lines skipped
The dashboard does not say which lines it could not read. Compare the table with the file, or import the file through the API, which lists each line with the reason.
Line 4: too few fields
The line has fewer than four parts. Add a TTL or IN, such as www 3600 IN A 203.0.113.10.
Line 2: unsupported type SOA
Coritan leaves out the SOA record, and every other record in the file still imports. A type Coritan does not host, such as NAPTR, is reported the same way.
Line 7: Invalid hostname: @
A hostname in content cannot be @. Write the domain in full, such as example.com..
Record limit reached (1000), import truncated
A zone holds up to 1,000 records. The import added records up to the limit and stopped. Delete records the zone no longer needs, then import the rest.
A record in the export has quotes inside its quotes
A TXT record that you imported with its quotes is written with a second pair around them, such as "\"v=spf1 mx -all\"". Delete the inner pair before you load the file elsewhere.

Import a zone file by sending its text as zone_file. In JSON, each line break is \n:

Shell
curl -X POST https://api.coritan.com/api/v1/dns/zones/42/import \
  -H "Authorization: Bearer $CORITAN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"zone_file": "@ 3600 IN A 203.0.113.10\nwww 3600 IN CNAME example.com.\nbad line"}'

The answer counts the records added and lists each line the import could not read:

JSON
{
  "imported": 2,
  "errors": ["Line 3: too few fields"]
}

Export a zone with GET /api/v1/dns/zones/42/export. The answer holds the file as one string:

JSON
{
  "zone_file": "; Zone file for example.com\n$ORIGIN example.com.\n$TTL 300\n…"
}

API operations on this page

MethodPathWhat it does
POST/api/v1/dns/zones/{zone_id}/importImport zone
GET/api/v1/dns/zones/{zone_id}/exportExport zone