Import a zone into STACKIT DNS
The zone import feature allows you to import DNS zone files or lists of records into the DNS management system. This is useful when you:
- want to migrate your DNS records from another provider
- have a large number of records to add
- want to save a current zone and use point in time recovery
- want to bulk update records
- want to bulk delete records
Prerequisites
Section titled “Prerequisites”- You have a STACKIT DNS zone: Manage DNS Zones
- You have a valid DNS Zone file (content of the desired DNS Zone or list of records in CSV, JSON or BIND format).
Import Types
Section titled “Import Types”Restore
Section titled “Restore”Restore sets the whole zone to the input (except for the SOA Record). Every single record that is not present in the input will be deleted. Only records and record sets from the input remain or will be created.
Update
Section titled “Update”Update will update record sets in a constructive way. Records present in the input will be created if a fitting Record Set exists. Existing records and record sets that are not mentioned in the input will not be deleted. Also TTL and the comment in the RRSet can be updated.
Delete
Section titled “Delete”Delete will delete all records from the input that match records within the zone in Type, Content and Name. No new Records will be created and unmatched records will be ignored.
upsert
Section titled “upsert”Upsert will update and create records and record sets in a constructive way. Records will be created in a fitting Record Set. Non-fitting Records will be turned into new Record Sets. Nothing will be deleted but TTL and the comment can be changed.
Import Formats
Section titled “Import Formats”All of the viable import formats are compatible with the respective export format.
The CSV format needs 5 fields, but the comment can be empty and similar to the BIND format all records are individual. The header row is optional.
name,ttl,type,content,commentexamplezone.test.,3600,SOA,"ns1.stackit.cloud. hostmaster.stackit.cloud. 2024040500 3600 600 1209600 60",examplezone.test.,3600,NS,"ns1.stackit.cloud.",examplezone.test.,3600,NS,"ns2.stackit.zone.",a.examplezone.test.,500,A,"1.2.3.4",commentb,3600,A,"2.3.4.5",In the JSON format records need to be grouped together to their respective record set.
{ "rrSets": [ { "name": "examplezone.test.", "type": "SOA", "ttl": 3600, "comment": "", "content": [ "ns1.stackit.cloud. hostmaster.stackit.cloud. 2024040500 3600 600 1209600 60" ] }, { "name": "examplezone.test.", "type": "NS", "ttl": 3600, "comment": "", "content": [ "ns1.stackit.cloud.", "ns2.stackit.zone." ] }, { "name": "b.", "type": "A", "ttl": 3600, "comment": "", "content": [ "2.3.4.5" ] }, { "name": "a.examplezone.test.", "type": "A", "ttl": 500, "comment": "comment", "content": [ "1.2.3.4" ] } ]}The BIND format needs a row for each record which then get grouped into record sets. The comment is optional.
examplezone.test. 3600 SOA ns1.stackit.cloud. hostmaster.stackit.cloud. 2024040500 3600 600 1209600 60examplezone.test. 3600 NS ns1.stackit.cloud.examplezone.test. 3600 NS ns2.stackit.zone.b 3600 A 2.3.4.5a.examplezone.test. 500 A 1.2.3.4 ; commentHow to Import
Section titled “How to Import”There are two ways to import a zone into STACKIT DNS. Both using the API (via Postman in the example) or via Portal will result in the same outcome.
The Portal allows to either import a zone using raw input in a small web editor or uploading a zone file. Both possibilities allow all import types as well as all zone formats and are fully compatible with the zone export.
Import records raw input
Section titled “Import records raw input”Using the import records raw input feature, you can paste multiple records or the content of a zone file.
- Open your project in the STACKIT Portal.
- Navigate to Networking > DNS.
- Click Create resource record and in the dropdown on Import records raw input.
- On the pane select the Format, the Import type and insert the actual zone data.
- Click on Import to finish.
Import records file
Section titled “Import records file”The Import records file feature is especially useful for migrating or restore a prior backed up zone. It allows you to upload a complete zone file.
- Open your project in the STACKIT Portal.
- Navigate to Networking > DNS.
- Click Create resource record and in the dropdown on Import records file.
- On the pane select the Format, the Import type and select a file on your local computer.
- Click on Next.
- Check if everything is correct and then click on Import to finish.
When using zone import via API its important to specify the format of the zone as well as the type of the import in the query parameters of the URI.
| Parameter | Description | Example |
|---|---|---|
| Auth-Token | The auth token to authenticate your client | eynsdhf89… |
| projectId | Defines how often on every day a backup is created | 23142134-21… |
| zoneId | Defines how often on every day a backup is created | 4389782-43… |
| format | The format of the backup file | csv |
| import-type | The type of import operation | restore |
| backup-file-as-ascii | The content of the backup file as ASCII | pitr.test.,3600,SOA,“ns1.stackit.clo… |
| zone-file | Filename of the zone file to import | zone.file |
Sending a raw body
Section titled “Sending a raw body”Sending a raw body allow for the best control and overview about the zone import without using the portal.
curl --location --request POST 'https://dns.api.stackit.cloud/v1/projects/[projectId]/zones/[zoneId]/import?format=[format]&importType=[import-type]' \[backup-file-as-ascii]' | jq.Sending a binary
Section titled “Sending a binary”curl --location --request POST 'https://dns.api.stackit.cloud/v1/projects/[projectId]/zones/[zoneId]/import?format=[format]&importType=[import-type]' \--data-binary "@[zone-file]"' | jq.Even though Postman calls it a binary, it also works with text files like BIND, CSV or JSON. Using the file upload is especially useful when working with backed up files.