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