🚀
DNSControl
🚀
DNSControl
  • Introduction to DNSControl
  • Getting Started
    • Overview
    • Examples
    • Migrating zones to DNSControl
    • TypeScript autocomplete and type checking
  • Language Reference
    • JavaScript DSL
    • Top Level Functions
      • D
      • DEFAULTS
      • DOMAIN_ELSEWHERE
      • DOMAIN_ELSEWHERE_AUTO
      • D_EXTEND
      • FETCH
      • HASH
      • IP
      • NewDnsProvider
      • NewRegistrar
      • PANIC
      • REV
      • REVCOMPAT
      • getConfiguredDomains
      • require
      • require_glob
    • Domain Modifiers
      • A
      • AAAA
      • ALIAS
      • AUTODNSSEC_OFF
      • AUTODNSSEC_ON
      • CAA
      • CAA_BUILDER
      • CNAME
      • DHCID
      • DNAME
      • DNSKEY
      • DISABLE_IGNORE_SAFETY_CHECK
      • DMARC_BUILDER
      • DS
      • DefaultTTL
      • DnsProvider
      • FRAME
      • HTTPS
      • IGNORE
      • IGNORE_NAME
      • IGNORE_TARGET
      • IMPORT_TRANSFORM
      • IMPORT_TRANSFORM_STRIP
      • INCLUDE
      • LOC
      • LOC_BUILDER_DD
      • LOC_BUILDER_DMM_STR
      • LOC_BUILDER_DMS_STR
      • LOC_BUILDER_STR
      • M365_BUILDER
      • MX
      • NAMESERVER
      • NAMESERVER_TTL
      • NAPTR
      • NO_PURGE
      • NS
      • PTR
      • PURGE
      • SOA
      • SPF_BUILDER
      • SRV
      • SSHFP
      • SVCB
      • TLSA
      • TXT
      • URL
      • URL301
      • Service Provider specific
        • Akamai Edge Dns
          • AKAMAICDN
        • Amazon Route 53
          • R53_ALIAS
        • Azure DNS
          • AZURE_ALIAS
        • Cloudflare DNS
          • CF_REDIRECT
          • CF_SINGLE_REDIRECT
          • CF_TEMP_REDIRECT
          • CF_WORKER_ROUTE
        • ClouDNS
          • CLOUDNS_WR
    • Record Modifiers
      • TTL
      • Service Provider specific
        • Amazon Route 53
          • R53_ZONE
          • R53_EVALUATE_TARGET_HEALTH
    • Why CNAME/MX/NS targets require a "dot"
  • Provider
    • Supported providers
    • Akamai Edge DNS
    • Amazon Route 53
    • AutoDNS
    • AXFR+DDNS
    • Azure DNS
    • Azure Private DNS
    • BIND
    • Bunny DNS
    • CentralNic Reseller (CNR) - formerly RRPProxy
    • Cloudflare
    • ClouDNS
    • CSC Global
    • deSEC
    • DigitalOcean
    • DNS Made Easy
    • DNSimple
    • DNS-over-HTTPS
    • DOMAINNAMESHOP
    • Dynadot
    • easyname
    • Exoscale
    • Gandi_v5
    • Gcore
    • Google Cloud DNS
    • Hetzner DNS Console
    • HEXONET
    • hosting.de
    • Huawei Cloud DNS
    • Hurricane Electric DNS
    • Internet.bs
    • INWX
    • Linode
    • Loopia
    • LuaDNS
    • Microsoft DNS Server on Microsoft Windows Server
    • Mythic Beasts
    • Namecheap
    • Name.com
    • Netcup
    • Netlify
    • NS1
    • OpenSRS
    • Oracle Cloud
    • OVH
    • Packetframe
    • Porkbun
    • PowerDNS
    • Realtime Register
    • RWTH DNS-Admin
    • Sakura Cloud
    • SoftLayer DNS
    • TransIP
    • Vultr
  • Commands
    • preview/push
    • check-creds
    • get-zones
    • get-certs
    • fmt
    • creds.json
    • Global Flag
    • Disabling Colors
  • Advanced features
    • CI/CD example for GitLab
    • CLI variables
    • Nameservers and Delegations
    • Notifications
    • Useful code tricks
    • JSON Reports
  • Developer info
    • Code Style Guide
    • Documentation Style Guide
    • DNSControl is an opinionated system
    • Writing new DNS providers
    • Creating new DNS Resource Types (rtypes)
    • Integration Tests
    • Test a branch
    • Unit Testing DNS Data
    • Bug Triage Process
    • Bring-Your-Own-Secrets for automated testing
    • Debugging with dlv
    • ALIAS Records
    • TXT record testing
    • DNS records ordering
  • Release
    • How to build and ship a release
    • Changelog v3.16.0
    • GitHub releases
Powered by GitBook
On this page
Edit on GitHub
  1. Language Reference
  2. Domain Modifiers

IMPORT_TRANSFORM

Don't use this feature. It was added for a very specific situation at Stack Overflow.

IMPORT_TRANSFORM adds to the domain the records from another domain, after making certain transformations and resetting the TTL.

Not all records are copied and transformed:

  • The record must be record type A or CNAME.

  • Records are skipped if they have a metadata key import_transform_skip (any non-null value).

  • Records are skipped if a record of the same label+type already exist in the destination domain.

Example:

Suppose foo.com is a regular domain. bar.com is a regular domain, but certain records should be the same as foo.com with these exceptions: "bar.com" is added to the name, the TTL is changed to 300, if the IP address is between 1.2.3.10 and 1.2.3.20 then rewrite the IP address to be based on 123.123.123.100 (i.e. .113 or .114).

You wouldn't want to maintain bar.com manually, would you? It would be very error prone. Therefore instead you maintain foo.com and let IMPORT_TRANSFORM automatically generate bar.com.

foo.com:
    one.foo.com.    IN A 1.2.3.1
    two.foo.com.    IN A 1.2.3.2
    three.foo.com.  IN A 1.2.3.13
    four.foo.com.   IN A 1.2.3.14

bar.com:
    www.bar.com.    IN 123.123.123.123
    one.foo.com.bar.com.    IN A 1.2.3.1
    two.foo.com.bar.com.    IN A 1.2.3.2
    three.foo.com.bar.com.  IN A 123.123.123.113
    four.foo.com.bar.com.   IN A 123.123.123.114

Here's how you'd implement this in DNSControl:

dnsconfig.js
// Transforms that use newBase:
var TRANSFORM_CF = [
    // RANGE_START, RANGE_END, NEW_BASE
    { low: "1.2.3.10", high: "1.2.3.20", newBase: "123.123.123.100" },  //   .10 to .20 rewritten as 123.123.123.100+IP
    { low: "2.4.6.80", high: "2.4.6.90", newBase: "123.123.123.200" },  //   Another rule, just to show that you can have many.
]
// Transforms that use newIP
var TRANSFORM_FSTLY = [
    // RANGE_START, RANGE_END, NEW_BASE
    { low: "1.2.3.10", high: "1.2.3.10", newIP: "123.123.123.100" },  //   .10 is rewritten as 123.123.123.100
    { low: "2.4.6.20", high: "2.4.6.20", newIP: "123.123.123.200" },  //   .20 is rewritten as 123.123.123.200
]

D("foo.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
  A("one","1.2.3.1"),
  A("two","1.2.3.2"),
  A("three","1.2.3.13"),
  A("four","1.2.3.14"),
);

D("bar.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
  A("www","123.123.123.123"),
  IMPORT_TRANSFORM(TRANSFORM_CF, "foo.com", 300),
);

D("baz.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
  A("www","123.123.123.123"),
  IMPORT_TRANSFORM(TRANSFORM_FSTLY, "foo.com", 300),
);

Transform rules are: RANGE_START, RANGE_END, NEW_BASE or NEW_IP.

Only one of newBase and newBase may be specified. If both are non-null the behavior is undefined.

NEW_BASE works as follows:

  • An IP address. Rebase the IP address on this IP address. Extract the host part of the /24 and add it to the "new base" address.

  • A list of IP addresses. For each A record, inject an A record for each item in the list: newBase: ["1.2.3.100", "2.4.6.8.100"] would produce 2 records for each A record.

  • For CNAMEs, the .internal is appended to the end of the target.

NEW_IP works as follows:

  • An IP address. Change the IP address of the A record to this IP address. If there are multiple A records at this label, only one A record is generated.

  • A list of IP addresses. Not supported.

  • For CNAMEs, the .internal is appended to the end of the target. (same as NEW_BASE)

PreviousIGNORE_TARGETNextIMPORT_TRANSFORM_STRIP

Last updated 5 months ago