github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/language-reference/domain-modifiers/IMPORT_TRANSFORM.md (about)

     1  ---
     2  name: IMPORT_TRANSFORM
     3  parameters:
     4    - transform table
     5    - domain
     6    - modifiers...
     7  ts_ignore: true
     8  ---
     9  
    10  {% hint style="warning" %}
    11  Don't use this feature. It was added for a very specific situation at Stack Overflow.
    12  {% endhint %}
    13  
    14  `IMPORT_TRANSFORM` adds to the domain all the records from another
    15  domain, after making certain transformations and resetting the TTL.
    16  
    17  Example:
    18  
    19  Suppose foo.com is a regular domain.  bar.com is a regular domain,
    20  but certain records should be the same as foo.com with these
    21  exceptions: "bar.com" is added to the name, the TTL is changed to
    22  300, if the IP address is between 1.2.3.10 and 1.2.3.20 then rewrite
    23  the IP address to be based on 123.123.123.100 (i.e. .113 or .114).
    24  
    25  You wouldn't want to maintain bar.com manually, would you?  It would
    26  be very error prone. Therefore instead you maintain foo.com and
    27  let `IMPORT_TRANSFORM` automatically generate bar.com.
    28  
    29  ```text
    30  foo.com:
    31      one.foo.com.    IN A 1.2.3.1
    32      two.foo.com.    IN A 1.2.3.2
    33      three.foo.com.  IN A 1.2.3.13
    34      four.foo.com.   IN A 1.2.3.14
    35  
    36  bar.com:
    37      www.bar.com.    IN 123.123.123.123
    38      one.foo.com.bar.com.    IN A 1.2.3.1
    39      two.foo.com.bar.com.    IN A 1.2.3.2
    40      three.foo.com.bar.com.  IN A 123.123.123.113
    41      four.foo.com.bar.com.   IN A 123.123.123.114
    42  ```
    43  
    44  Here's how you'd implement this in DNSControl:
    45  
    46  {% code title="dnsconfig.js" %}
    47  ```javascript
    48  var TRANSFORM_INT = [
    49      // RANGE_START, RANGE_END, NEW_BASE
    50      { 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
    51      { 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.
    52  ]
    53  
    54  D("foo.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
    55    A("one","1.2.3.1"),
    56    A("two","1.2.3.2"),
    57    A("three","1.2.3.13"),
    58    A("four","1.2.3.14"),
    59  END);
    60  
    61  D("bar.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
    62    A("www","123.123.123.123"),
    63    IMPORT_TRANSFORM(TRANSFORM_INT, "foo.com", 300),
    64  END);
    65  ```
    66  {% endcode %}
    67  
    68  Transform rules are: RANGE_START, RANGE_END, NEW_BASE.  NEW_BASE may be:
    69  
    70  * 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.
    71  * 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.