github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/language-reference/top-level-functions/D.md (about) 1 --- 2 name: D 3 parameters: 4 - name 5 - registrar 6 - modifiers... 7 parameter_types: 8 name: string 9 registrar: string 10 "modifiers...": DomainModifier[] 11 --- 12 13 `D` adds a new Domain for DNSControl to manage. The first two arguments are required: the domain name (fully qualified `example.com` without a trailing dot), and the 14 name of the registrar (as previously declared with [NewRegistrar](NewRegistrar.md)). Any number of additional arguments may be included to add DNS Providers with [DNSProvider](NewDnsProvider.md), 15 add records with [A](../domain-modifiers/A.md), [CNAME](../domain-modifiers/CNAME.md), and so forth, or add metadata. 16 17 Modifier arguments are processed according to type as follows: 18 19 - A function argument will be called with the domain object as it's only argument. Most of the [built-in modifier functions](https://docs.dnscontrol.org/language-reference/domain-modifiers-modifiers) return such functions. 20 - An object argument will be merged into the domain's metadata collection. 21 - An array argument will have all of it's members evaluated recursively. This allows you to combine multiple common records or modifiers into a variable that can 22 be used like a macro in multiple domains. 23 24 {% code title="dnsconfig.js" %} 25 ```javascript 26 // simple domain 27 D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), 28 A("@","1.2.3.4"), 29 CNAME("test", "foo.example2.com."), 30 END); 31 32 // "macro" for records that can be mixed into any zone 33 var GOOGLE_APPS_DOMAIN_MX = [ 34 MX("@", 1, "aspmx.l.google.com."), 35 MX("@", 5, "alt1.aspmx.l.google.com."), 36 MX("@", 5, "alt2.aspmx.l.google.com."), 37 MX("@", 10, "alt3.aspmx.l.google.com."), 38 MX("@", 10, "alt4.aspmx.l.google.com."), 39 ] 40 41 D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER), 42 A("@","1.2.3.4"), 43 CNAME("test", "foo.example2.com."), 44 GOOGLE_APPS_DOMAIN_MX, 45 END); 46 ``` 47 {% endcode %} 48 49 # Split Horizon DNS 50 51 DNSControl supports Split Horizon DNS. Simply 52 define the domain two or more times, each with 53 their own unique parameters. 54 55 To differentiate the different domains, specify the domains as 56 `domain.tld!tag`, such as `example.com!inside` and 57 `example.com!outside`. 58 59 {% code title="dnsconfig.js" %} 60 ```javascript 61 var REG_THIRDPARTY = NewRegistrar("ThirdParty"); 62 var DNS_INSIDE = NewDnsProvider("Cloudflare"); 63 var DNS_OUTSIDE = NewDnsProvider("bind"); 64 65 D("example.com!inside", REG_THIRDPARTY, DnsProvider(DNS_INSIDE), 66 A("www", "10.10.10.10"), 67 END); 68 69 D("example.com!outside", REG_THIRDPARTY, DnsProvider(DNS_OUTSIDE), 70 A("www", "20.20.20.20"), 71 END); 72 73 D_EXTEND("example.com!inside", 74 A("internal", "10.99.99.99"), 75 END); 76 ``` 77 {% endcode %} 78 79 A domain name without a `!` is assigned a tag that is the empty 80 string. For example, `example.com` and `example.com!` are equivalent. 81 However, we strongly recommend against using the empty tag, as it 82 risks creating confusion. In other words, if you have `domain.tld` 83 and `domain.tld!external` you now require humans to remember that 84 `domain.tld` is the external one. I mean... the internal one. You 85 may have noticed this mistake, but will your coworkers? Will you in 86 six months? You get the idea. 87 88 DNSControl command line flag `--domains` matches the full name (with the "!"). If you 89 define domains `example.com!george` and `example.com!john` then: 90 91 * `--domains=example.com` will not match either domain. 92 * `--domains='example.com!george'` will match only match the first. 93 * `--domains='example.com!george",example.com!john` will match both. 94 95 {% hint style="info" %} 96 **NOTE**: The quotes are required if your shell treats `!` as a special 97 character, which is probably does. If you see an error that mentions 98 `event not found` you probably forgot the quotes. 99 {% endhint %}