Zone management
dnsconfig.js import and export
Import DNSControl dnsconfig.js in a sandboxed browser worker or export a managed zone as code. Review supported functions, providers, and known limits.
7 min read
On this page
Config as code supports DNSControl dnsconfig.js and octoDNS YAML. dnsconfig.js imports run in a sandboxed browser Worker with optional variables and server-mediated SPF TXT lookups; HASH() works locally. octoDNS imports are parsed as data and can merge split zone files. Both exports use the saved zone and never include connection credentials.
Export a saved zone#
Open Zones → a zone → Config as code. The dnsconfig.js section renders the saved zone and offers Download. Unsaved browser edits are excluded, so select Save changes first when they belong in the file.
The exporter converts each attached provider to its DNSControl type, derives a safe declaration key from the connection label, and emits no token, password, account secret, or service-account document. A small result looks like this:
// Generated by DNSMigrator. DNSControl-compatible dnsconfig.js.
var REG_NONE = NewRegistrar("none");
var DSP_PRODUCTION_DNS = NewDnsProvider("production_dns", "CLOUDFLAREAPI");
D("example.com", REG_NONE,
DnsProvider(DSP_PRODUCTION_DNS),
DefaultTTL(300),
NO_PURGE,
A("@", "192.0.2.10"),
CNAME("www", "@"),
MX("@", 10, "mx1.mail.example.net."),
TXT("@", "v=spf1 include:_spf.example.net -all"),
CAA("@", "issue", "letsencrypt.org")
);The release exporter represents provider assignments and nameserver counts, default and per-record TTLs, explicit nameservers, ignore rules, external-dns ownership, purge and ignore-safety settings, DNSSEC intent, import transforms, absent markers, aliases, Cloudflare proxy/comment metadata, Hurricane Electric dynamic flags, and Route 53 weighted routing with an optional health-check ID.
Unsupported metadata or record functions produce warnings above the code. Keep the file in version control if useful, but configure credentials separately when running it with DNSControl.
Import dnsconfig.js#
Open the importer
Go to Zones → Add zone → dnsconfig.js, or use Config as code → Load from dnsconfig.js inside an existing zone.
Provide the script and variables
Paste JavaScript, select Open file, or choose Use an example. A pasted script is limited to 1,000,000 JavaScript characters; a selected file is limited to 1,000,000 bytes. Expand Variables (dnscontrol -v name=value) and enter one name=value per line when the config expects CLI variables.
Evaluate it
Select Read the config. Review Zones in this config plus every error and warning. Script evaluation has a three-second limit; any SPF TXT lookups run afterward with their own 20-second limit.
Map provider declarations
During multi-zone import, use Match each DnsProvider to a connection. The UI preselects the first active DNS connection with the same provider type; Skip for now leaves that declaration unattached.
Create saved drafts
Select Import n zones. Already-managed names are skipped. No provider record changes until a later preview and push.
A single import action accepts at most 100 zones and still enforces the workspace’s managed-zone limit.
Provider declarations should include a type, for example NewDnsProvider("production", "CLOUDFLAREAPI"). When it is absent, the runtime tries the declaration name and known name hints. A guessed type warns. Unknown and non-DNS declarations are not attached to the zone and also warn.
Load a config into an existing zone#
Inside a zone, select Config as code → Load from dnsconfig.js, evaluate the script, then select Load example.com into the editor. The button appears only when a D() name matches the current normalized zone.
This keeps the current zone name and attached provider connections while loading the declaration’s records and supported settings into the browser draft. Review it under Records, then select Save changes. Loading does not contact a provider.
Supported domain and control functions#
“Supported” below means the release runtime maps the call into its desired-zone model. Provider capability checks still happen later.
| Group | Functions and constants |
|---|---|
| Domains | D, D_EXTEND, DEFAULTS, DOMAIN_ELSEWHERE, DOMAIN_ELSEWHERE_AUTO, INCLUDE |
| Declarations | NewRegistrar, NewDnsProvider, DnsProvider |
| TTL and nameservers | TTL, DefaultTTL, NAMESERVER, NAMESERVER_TTL, GIDINET_PREMIUM_NS |
| Ignore and ownership | IGNORE, IGNORE_NAME, IGNORE_TARGET, IGNORE_EXTERNAL_DNS, DISABLE_IGNORE_SAFETY_CHECK, NO_PURGE, PURGE, ENSURE_ABSENT_REC |
| DNSSEC | AUTODNSSEC_ON, AUTODNSSEC_OFF; deprecated AUTODNSSEC warns and does nothing |
| Transforms and reverse DNS | IMPORT_TRANSFORM, IMPORT_TRANSFORM_STRIP, IP, REV, REVCOMPAT |
| Builders | SPF_BUILDER, DMARC_BUILDER, CAA_BUILDER, DKIM_BUILDER, M365_BUILDER, LOC_BUILDER_DD, LOC_BUILDER_DMM_STR, LOC_BUILDER_DMS_STR, LOC_BUILDER_STR, and the DKIM array helper |
| Route 53 | R53_ALIAS, R53_ZONE, R53_EVALUATE_TARGET_HEALTH, R53_WEIGHT, R53_HEALTH_CHECK_ID |
| Hurricane Electric | HEDNS_DYNAMIC_ON, HEDNS_DYNAMIC_OFF, HEDNS_DDNS_KEY |
| Other helpers | CAA_CRITICAL, DISABLE_REPEATED_DOMAIN_CHECK, PANIC, getConfiguredDomains, CLI_DEFAULTS; AUTOSPLIT and END are accepted empty compatibility values |
CLI_DEFAULTS() installs defaults for variables you did not provide under Variables; supplied values take precedence and are strings, matching DNSControl's -v name=value. HASH(algorithm, value) returns a lowercase hexadecimal SHA1, SHA256, or SHA512 digest without network or filesystem access. PANIC() stops evaluation, and getConfiguredDomains() returns names declared so far. Unicode zone, owner, and target names are normalized to lowercase ASCII IDNA form.
Supported record constructors#
The standard and extended constructors mapped into canonical records are:
A AAAA ALIAS CAA CNAME DHCID DNAME DNSKEY DS FRAME HTTPS LOC MX NAPTR NS
OPENPGPKEY PTR RP SMIMEA SOA SRV SSHFP SVCB TLSA TXT URL URL301The provider-specific constructors mapped in this release are:
ADGUARDHOME_A_PASSTHROUGH ADGUARDHOME_AAAA_PASSTHROUGH
AKAMAICDN AKAMAITLC AZURE_ALIAS BUNNY_DNS_PZ BUNNY_DNS_RDR
CF_REDIRECT CF_SINGLE_REDIRECT CF_TEMP_REDIRECT CF_WORKER_ROUTE
CLOUDNS_WR LUA MIKROTIK_FORWARDER MIKROTIK_FWD MIKROTIK_NXDOMAIN
PORKBUN_URLFWD R53_ALIASBUNNY_DNS_PZ, BUNNY_DNS_RDR, and PORKBUN_URLFWD now create managed records and export back to DNSControl-style constructors. Porkbun import options accept permanent, temporary, 301, 302, 307, or masked behavior plus path and wildcard choices; invalid options are import errors. Export warns when 307 or masked behavior must be emitted as the constructor's temporary form.
The obsolete DNS SPF() constructor is not registered; use TXT() or SPF_BUILDER. CERT(), URI(), and MXE() are also not runtime globals even though those canonical types exist elsewhere in the record model.
Cloudflare compatibility modifiers#
The Worker exposes these Cloudflare names:
CF_PROXY_OFF CF_PROXY_ON CF_PROXY_FULL
CF_CNAME_FLATTEN_OFF CF_CNAME_FLATTEN_ON
CF_PROXY_DEFAULT_OFF CF_PROXY_DEFAULT_ON
CF_UNIVERSALSSL_OFF CF_UNIVERSALSSL_ON
CF_MANAGE_COMMENTS CF_MANAGE_TAGS CF_COMMENT CF_TAGSTheir release behavior is not uniform:
CF_PROXY_ON,CF_PROXY_FULL, andCF_PROXY_OFFmap per-record proxy metadata.- Domain-level
CF_PROXY_DEFAULT_ONmarks A, AAAA, and CNAME records proxied when they have no explicit proxy value. CF_COMMENT()maps to the canonical record comment and is emitted again by the exporter.- Domain-level flattening, Universal SSL, and manage-comments/manage-tags values are retained as generic zone metadata, but the managed-zone planner does not act on them.
- Per-record
CF_TAGS()has no canonical equivalent; collection warns and drops it.CF_MANAGE_TAGSdoes not make record tags round-trip.
Import and export octoDNS YAML#
Open Zones → a zone → Config as code, then switch Config format to octoDNS. The page renders octoDNS zone YAML in YamlProvider format from the saved zone. Select Zone YAML to download <zone>.yaml or Starter config to download config.yaml.
The starter config creates a YAML source under ./config, adds targets for the zone's attached providers, lists the Python packages to install, and uses env/NAME placeholders instead of real credentials. When DNSMigrator does not know an octoDNS provider class, the warning and placeholder tell you to fill it in before running octodns-sync.
To import into the current zone:
Open one or more YAML files
Under Load from octoDNS YAML, paste a zone file or select Open files. Several SplitYamlProvider files are merged and checked for cross-file duplicate records. Keep the total under 2 MB.
Preview changes
Select Preview changes. DNSMigrator reports file and line errors, warnings, provider-specific data kept aside, and the add/change/remove comparison with the saved zone.
Load the draft
Fix every error, then select Load n record sets into the editor. The load replaces the current draft records, merges any octodns.ignored entries into the zone's IGNORE rules, and preserves the zone name, attached connections, and other settings. Save and run the normal provider preview before pushing.
The importer handles octoDNS value shapes for MX, SRV, CAA, SSHFP, TLSA, DS, NAPTR, LOC, HTTPS/SVCB, URI, ALIAS, Route 53 aliases, and URLFWD. Whole-hostname URL forwards map to DNSMigrator redirect types; path-specific forwards that cannot map safely are kept aside with a warning. Cloudflare proxied metadata is retained.
Weighted, failover, and geo dynamic records map to routing sets when their pools and rules can be represented. Subnet rules, pool status flags, deep fallback chains, and unsupported provider metadata are reported rather than silently invented. On export, DNSMigrator also stores the exact routing under octodns.dnsmigrator so supported round trips retain policies that native octoDNS YAML cannot fully express.
YAML is parsed as data only. Custom tags such as !include are rejected, aliases are capped, duplicate keys and records are errors, and no YAML content is executed. Records octoDNS cannot hold are listed in export warnings and in a trailing comment.
Browser sandbox limits#
Each evaluation creates a new module Worker. The Worker passes only runtime globals as parameters to a strict Function and posts a JSON-cloned result. Script execution is stopped after three seconds. When SPF flattening needs TXT data, the Worker pauses after evaluation and asks the authenticated page for validated DNS lookups; those lookups have a separate 20-second deadline and a 50-query cap.
The worker removes fetch, XMLHttpRequest, WebSocket, EventSource, importScripts, IndexedDB, Cache Storage, broadcast channels, nested workers, WebTransport, navigator, and location. The runtime versions of FETCH() and lowercase fetch() also throw. SPF's narrow TXT resolver is the only network path exposed to collection.
Known import deviations#
The browser runtime intentionally differs from a full DNSControl process:
require(),require_glob(), andglob()throw because there is no filesystem. Combine required content into one script.FETCH()and lowercasefetch()throw because direct network access is blocked.HASH()supports SHA1, SHA256, and SHA512 and returns lowercase hexadecimal; other algorithms fail the import.IGNORE_NAME_DISABLE_SAFETY_CHECK()throws with guidance to use domain-wideDISABLE_IGNORE_SAFETY_CHECK.SPF_BUILDERflattening sends requested TXT names to DNSMigrator after sandbox evaluation. An import can make at most 50 lookups; lookup errors leave the affected policy unflattened and add a warning.- Variables under Variables (dnscontrol -v name=value) are strings.
CLI_DEFAULTS()supplies only missing names. - Provider and domain names are normalized to lowercase DNSMigrator names, with Unicode DNS names converted to punycode. Unknown provider types are warned about and not attached.
- Empty-value passthrough and NXDOMAIN constructors can be collected, but the managed-zone save guard later rejects their empty values.
Known export losses#
The generated callout reports these release exporter losses:
- routing policies other than Route 53 weighted routing are dropped with a warning;
- an HE dynamic-DNS key is withheld unless an internal caller explicitly enables secret export, which the web UI does not;
- a canonical SPF record is emitted as
TXT(); - a CAA flag other than 0 or 128 is represented as
CAA_CRITICALand warns; - the SOA serial is omitted because the constructor lets DNSControl manage it;
- records outside the zone are skipped;
- a canonical type with no constructor, including CERT, URI, or MXE, is left as a JavaScript comment; and
- record tags cannot be exported because the release canonical metadata has no tag field.
Resolve warnings before treating export followed by import as a round trip. For a data-only copy, use a BIND zone file; its parser has a separate, shorter record-type list.