1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

DOCS: Added GitBook code blocks syntax for dnsconfig.js. (#2149)

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Jeffrey Cafferata
2023-03-13 21:30:21 +01:00
committed by GitHub
parent af99942a3e
commit 05be3b83ed
48 changed files with 148 additions and 5 deletions

View File

@ -16,6 +16,7 @@ The address should be an ip address, either a string, or a numeric value obtaine
Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/language-reference/record-modifiers) or JSON objects, which will be merged into the record's metadata.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("R53"),
A("@", "1.2.3.4"),
@ -24,3 +25,4 @@ D("example.com", REGISTRAR, DnsProvider("R53"),
A("*", "1.2.3.4", {foo: 42})
);
```
{% endcode %}

View File

@ -16,6 +16,7 @@ The address should be an IPv6 address as a string.
Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/language-reference/record-modifiers) or JSON objects, which will be merged into the record's metadata.
{% code title="dnsconfig.js" %}
```javascript
var addrV6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
@ -26,3 +27,4 @@ D("example.com", REGISTRAR, DnsProvider("R53"),
AAAA("*", addrV6, {foo: 42})
);
```
{% endcode %}

View File

@ -18,8 +18,10 @@ The name should be the relative label for the domain.
Target should be a string representing the target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("CLOUDFLARE"),
ALIAS("@", "google.com."), // example.com -> google.com
);
```
{% endcode %}

View File

@ -19,6 +19,7 @@ data model.
correct syntax is `AUTODNSSEC_ON` not `AUTODNSSEC_ON()`
{% endhint %}
{% code title="dnsconfig.js" %}
```javascript
D("example.com", .... ,
AUTODNSSEC_ON, // Enable AutoDNSSEC.
@ -30,6 +31,7 @@ D("insecure.com", .... ,
A("@", "10.2.2.2")
);
```
{% endcode %}
If neither `AUTODNSSEC_ON` or `AUTODNSSEC_OFF` is specified for a
domain no changes will be requested.

View File

@ -48,9 +48,11 @@ Alias records can reference other record sets of the same type.
For example, a DNS CNAME record set can be an alias to another CNAME record set.
This arrangement is useful if you want some record sets to be aliases and some non-aliases.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("AZURE_DNS"),
AZURE_ALIAS("foo", "A", "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2"), // record for traffic manager
AZURE_ALIAS("foo", "CNAME", "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/dnszones/example.com/A/quux."), // record in the same zone
);
```
{% endcode %}

View File

@ -24,6 +24,7 @@ Value is a string. The format of the contents is different depending on the tag.
Flags are controlled by modifier:
- `CAA_CRITICAL`: Issuer critical flag. CA that does not understand this tag will refuse to issue certificate for this domain.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("GCLOUD"),
// Allow letsencrypt to issue certificate for this domain
@ -35,5 +36,6 @@ D("example.com", REGISTRAR, DnsProvider("GCLOUD"),
CAA("@", "iodef", "mailto:test@example.com", CAA_CRITICAL)
);
```
{% endcode %}
DNSControl contains a [`CAA_BUILDER`](../record/CAA_BUILDER.md) which can be used to simply create `CAA()` records for your domains. Instead of creating each CAA record individually, you can simply configure your report mail address, the authorized certificate authorities and the builder cares about the rest.

View File

@ -33,8 +33,10 @@ only after sufficient time has elapsed to prove this is what you really want.
This example redirects the bare (aka apex, or naked) domain to www:
{% code title="dnsconfig.js" %}
```javascript
D("foo.com", .... ,
CF_REDIRECT("mydomain.com/*", "https://www.mydomain.com/$1"),
);
```
{% endcode %}

View File

@ -26,8 +26,10 @@ backups and manually verifying `dnscontrol preview` output before running
managed by DNSControl and those that aren't.
{% endhint %}
{% code title="dnsconfig.js" %}
```javascript
D("foo.com", .... ,
CF_TEMP_REDIRECT("example.mydomain.com/*", "https://otherplace.yourdomain.com/$1"),
);
```
{% endcode %}

View File

@ -25,9 +25,11 @@ backups and manually verifying `dnscontrol preview` output before running
This example assigns the patterns `api.foo.com/*` and `foo.com/api/*` to a `my-worker` script:
{% code title="dnsconfig.js" %}
```javascript
D("foo.com", .... ,
CF_WORKER_ROUTE("api.foo.com/*", "my-worker"),
CF_WORKER_ROUTE("foo.com/api/*", "my-worker"),
);
```
{% endcode %}

View File

@ -15,6 +15,7 @@ Using `@` or `*` for CNAME records is not recommended, as different providers su
Target should be a string representing the CNAME target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("R53"),
CNAME("foo", "google.com."), // foo.example.com -> google.com
@ -22,3 +23,4 @@ D("example.com", REGISTRAR, DnsProvider("R53"),
CNAME("def", "test"), // def.example.com -> test.example.com
);
```
{% endcode %}

View File

@ -26,8 +26,10 @@ Digest Type must be a number.
Digest must be a string.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider(R53),
DS("example.com", 2371, 13, 2, "ABCDEF")
);
```
{% endcode %}

View File

@ -12,6 +12,7 @@ the record will inherit the DNSControl global internal default of 300 seconds. S
NS records are currently a special case, and do not inherit from `DefaultTTL`. See [`NAMESERVER_TTL`](../domain/NAMESERVER_TTL.md) to set a default TTL for all NS records.
{% code title="dnsconfig.js" %}
```javascript
D('example.com', REGISTRAR, DnsProvider('R53'),
DefaultTTL("4h"),
@ -19,6 +20,7 @@ D('example.com', REGISTRAR, DnsProvider('R53'),
A('foo', '2.3.4.5', TTL(600)) // overrides default
);
```
{% endcode %}
The DefaultTTL duration is the same format as [`TTL`](../record/TTL.md), an integer number of seconds
or a string with a unit such as `'4d'`.

View File

@ -28,6 +28,7 @@ Technically `IGNORE_NAME` is a promise that DNSControl will not add, change, or
In this example, DNSControl will insert/update the "baz.example.com" record but will leave unchanged the "foo.example.com" and "bar.example.com" ones.
{% code title="dnsconfig.js" %}
```javascript
D("example.com",
IGNORE_NAME("foo"), // ignore all record types for name foo
@ -37,6 +38,7 @@ D("example.com",
A("baz", "1.2.3.4")
);
```
{% endcode %}
`IGNORE_NAME` also supports glob patterns in the style of the [gobwas/glob](https://github.com/gobwas/glob) library. All of
the following patterns will work:

View File

@ -24,12 +24,14 @@ IGNORE_TARGET is generally used in very specific situations:
In this example, DNSControl will insert/update the "baz.example.com" record but will leave unchanged a CNAME to "foo.acm-validations.aws" record.
{% code title="dnsconfig.js" %}
```javascript
D("example.com",
IGNORE_TARGET('**.acm-validations.aws.', 'CNAME'),
A("baz", "1.2.3.4")
);
```
{% endcode %}
IGNORE_TARGET also supports glob patterns in the style of the [gobwas/glob](https://github.com/gobwas/glob#example) library. Some example patterns:

View File

@ -43,6 +43,7 @@ bar.com:
Here's how you'd implement this in DNSControl:
{% code title="dnsconfig.js" %}
```javascript
var TRANSFORM_INT = [
// RANGE_START, RANGE_END, NEW_BASE
@ -62,6 +63,7 @@ D("bar.com", .... ,
IMPORT_TRANSFORM(TRANSFORM_INT, 'foo.com', 300),
);
```
{% endcode %}
Transform rules are: RANGE_START, RANGE_END, NEW_BASE. NEW_BASE may be:

View File

@ -9,6 +9,7 @@ parameter_types:
Includes all records from a given domain
{% code title="dnsconfig.js" %}
```javascript
D("example.com!external", REGISTRAR, DnsProvider(R53),
A("test", "8.8.8.8")
@ -19,3 +20,4 @@ D("example.com!internal", REGISTRAR, DnsProvider(R53),
A("home", "127.0.0.1")
);
```
{% endcode %}

View File

@ -18,9 +18,11 @@ Priority should be a number.
Target should be a string representing the MX target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider(R53),
MX("@", 5, "mail"), // mx example.com -> mail.example.com
MX("sub", 10, "mail.foo.com.")
);
```
{% endcode %}

View File

@ -20,6 +20,7 @@ delegations. `NAMESERVER()` is for informing upstream delegations.
For more information, refer to [this page](../../nameservers.md).
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, .... ,
DnsProvider(route53, 0),
@ -34,6 +35,7 @@ D("example2.com", REGISTRAR, .... ,
NAMESERVER("ns2.myserver.com."),
);
```
{% endcode %}
# The difference between NS() and NAMESERVER()
@ -78,9 +80,11 @@ special Registrar called "NONE". It makes no changes.
It looks like this:
{% code title="dnsconfig.js" %}
```javascript
var REG_THIRDPARTY = NewRegistrar('ThirdParty', 'NONE')
D("mydomain.com", REG_THIRDPARTY,
...
)
```
{% endcode %}

View File

@ -12,14 +12,18 @@ NAMESERVER_TTL sets the TTL on the domain apex NS RRs defined by [`NAMESERVER`](
The value can be an integer or a string. See [`TTL`](../record/TTL.md) for examples.
{% code title="dnsconfig.js" %}
```javascript
D('example.com', REGISTRAR, DnsProvider('R53'),
NAMESERVER_TTL('2d'),
NAMESERVER('ns')
);
```
{% endcode %}
Use `NAMESERVER_TTL('3600'),` or `NAMESERVER_TTL('1h'),` for a 1h default TTL for all subsequent `NS` entries:
{% code title="dnsconfig.js" %}
```javascript
D('example.com', REGISTRAR, DnsProvider('xyz'),
DefaultTTL("4h"),
@ -30,5 +34,6 @@ D('example.com', REGISTRAR, DnsProvider('xyz'),
A('foo', '2.3.4.5', TTL(600)) // overrides DefaultTTL for this record only
);
```
{% endcode %}
To apply a default TTL to all other record types, see [`DefaultTTL`](../domain/DefaultTTL.md)
To apply a default TTL to all other record types, see [`DefaultTTL`](../domain/DefaultTTL.md)

View File

@ -15,11 +15,13 @@ zone, but otherwise leave the zone alone. Changes to "foo"'s IP
address will update the record. Removing the A("foo", ...) record
from DNSControl will leave the record in place.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", .... , NO_PURGE,
A("foo","1.2.3.4")
);
```
{% endcode %}
The main caveat of NO_PURGE is that intentionally deleting records
becomes more difficult. Suppose a NO_PURGE zone has an record such

View File

@ -18,6 +18,7 @@ The difference between `NS()` and [`NAMESERVER()`](NAMESERVER.md) is explained i
Target should be a string representing the NS target. If it is a single label we will assume it is a relative name on the current domain. If it contains *any* dots, it should be a fully qualified domain name, ending with a `.`.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("R53"),
NS("foo", "ns1.example2.com."), // Delegate ".foo.example.com" zone to another server.
@ -26,3 +27,4 @@ D("example.com", REGISTRAR, DnsProvider("R53"),
A("ns2.example2.com", "10.10.10.20"), // Glue records
);
```
{% endcode %}

View File

@ -60,6 +60,7 @@ and A, B, C are the first 3 octets of the IP address. For example
`172.20.18.130/27` is located in a zone named
`128/27.18.20.172.in-addr.arpa`
{% code title="dnsconfig.js" %}
```javascript
D(REV('1.2.3.0/24'), REGISTRAR, DnsProvider(BIND),
PTR('1', 'foo.example.com.'),
@ -68,11 +69,19 @@ D(REV('1.2.3.0/24'), REGISTRAR, DnsProvider(BIND),
// If the first parameter is a valid IP address, DNSControl will generate the correct name:
PTR('1.2.3.10', 'ten.example.com.'), // '10'
);
```
{% endcode %}
{% code title="dnsconfig.js" %}
```javascript
D(REV('9.9.9.128/25'), REGISTRAR, DnsProvider(BIND),
PTR('9.9.9.129', 'first.example.com.'),
);
```
{% endcode %}
{% code title="dnsconfig.js" %}
```javascript
D(REV('2001:db8:302::/48'), REGISTRAR, DnsProvider(BIND),
PTR('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0', 'foo.example.com.'), // 2001:db8:302::1
// If the first parameter is a valid IP address, DNSControl will generate the correct name:
@ -80,6 +89,7 @@ D(REV('2001:db8:302::/48'), REGISTRAR, DnsProvider(BIND),
PTR('2001:db8:302::3', 'three.example.com.'), // '3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0'
);
```
{% endcode %}
In the future we plan on adding a flag to `A()` which will insert
the correct PTR() record if the appropriate `.arpa` domain has been

View File

@ -12,21 +12,26 @@ These three examples all are equivalent.
PURGE is the default:
{% code title="dnsconfig.js" %}
```javascript
D("example.com", .... ,
);
```
{% endcode %}
Purge is the default, but we set it anyway:
{% code title="dnsconfig.js" %}
```javascript
D("example.com", .... ,
PURGE,
);
```
{% endcode %}
Since the "last command wins", this is the same as `PURGE`:
{% code title="dnsconfig.js" %}
```javascript
D("example.com", .... ,
PURGE,
@ -36,3 +41,4 @@ D("example.com", .... ,
PURGE,
);
```
{% endcode %}

View File

@ -37,6 +37,7 @@ The zone id can be found depending on the target type:
* _S3 bucket_ (configured as website): specify the hosted zone ID for the region that you created the bucket in. You can find it in [the List of regions and hosted Zone IDs](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region)
* _Another Route 53 record_: you can either specify the correct zone id or do not specify anything and DNSControl will figure out the right zone id. (Note: Route53 alias can't reference a record in a different zone).
{% code title="dnsconfig.js" %}
```javascript
D('example.com', REGISTRAR, DnsProvider('ROUTE53'),
R53_ALIAS('foo', 'A', 'bar'), // record in same zone
@ -46,3 +47,4 @@ D('example.com', REGISTRAR, DnsProvider('ROUTE53'),
R53_ALIAS('foo', 'A', 'blahblah-bucket.s3-website-us-west-1.amazonaws.com.', R53_ZONE('Z2F56UZL2M1ACD')), // a website S3 Bucket in us-west-1
);
```
{% endcode %}

View File

@ -22,11 +22,13 @@ parameter_types:
`SOA` adds an `SOA` record to a domain. The name should be `@`. ns and mbox are strings. The other fields are unsigned 32-bit ints.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REG_THIRDPARTY, DnsProvider("DNS_BIND"),
SOA("@", "ns3.example.org.", "hostmaster@example.org", 3600, 600, 604800, 1440),
);
```
{% endcode %}
The email address should be specified like a normal RFC822/RFC5322 address (user@hostname.com). It will be converted into the required format (e.g. BIND format: `user.hostname.com`) by the provider as required. This has the benefit of being more human-readable plus DNSControl can properly handle escaping and other issues.

View File

@ -20,6 +20,7 @@ parameter_types:
Priority, weight, and port are ints.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("GCLOUD"),
// Create SRV records for a a SIP service:
@ -28,3 +29,4 @@ D("example.com", REGISTRAR, DnsProvider("GCLOUD"),
SRV('_sip._tcp', 10, 20, 5060, 'smallbox1.example.tld.'),
);
```
{% endcode %}

View File

@ -36,6 +36,8 @@ SSHFP contains a fingerprint of a SSH server which can be validated before SSH c
`value` is the fingerprint as a string.
{% code title="dnsconfig.js" %}
```javascript
SSHFP('@', 1, 1, '00yourAmazingFingerprint00'),
```
{% endcode %}

View File

@ -22,9 +22,11 @@ Usage, selector, and type are ints.
Certificate is a hex string.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, DnsProvider("GCLOUD"),
// Create TLSA record for certificate used on TCP port 443
TLSA("_443._tcp", 3, 1, 1, "abcdef0"),
);
```
{% endcode %}

View File

@ -22,6 +22,7 @@ will be done for you.
Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/language-reference/record-modifiers) or JSON objects, which will be merged into the record's metadata.
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REGISTRAR, ....,
TXT('@', '598611146-3338560'),
@ -32,6 +33,7 @@ Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/la
TXT('long', 'X'.repeat(300)) // Long strings are split automatically.
);
```
{% endcode %}
{% hint style="info" %}
**NOTE**: In the past, long strings had to be annotated with the keyword

View File

@ -21,6 +21,7 @@ Modifier arguments are processed according to type as follows:
- 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
be used like a macro in multiple domains.
{% code title="dnsconfig.js" %}
```javascript
var REGISTRAR = NewRegistrar("name.com");
var r53 = NewDnsProvider("R53");
@ -46,6 +47,7 @@ D("example.com", REGISTRAR, DnsProvider(r53),
GOOGLE_APPS_DOMAIN_MX
);
```
{% endcode %}
# Split Horizon DNS
@ -58,6 +60,7 @@ To differentiate the different domains, specify the domains as
`domain.tld!tag`, such as `example.com!inside` and
`example.com!outside`.
{% code title="dnsconfig.js" %}
```javascript
var REG = NewRegistrar("Third-Party");
var DNS_INSIDE = NewDnsProvider("Cloudflare");
@ -75,6 +78,7 @@ D_EXTEND("example.com!inside",
A("internal", "10.99.99.99")
);
```
{% endcode %}
A domain name without a `!` is assigned a tag that is the empty
string. For example, `example.com` and `example.com!` are equivalent.

View File

@ -14,6 +14,7 @@ arguments passed as if they were the first modifiers in the argument list.
We want to create backup zone files for all domains, but not actually register them. Also create a [`DefaultTTL`](../domain/DefaultTTL.md).
The domain `example.com` will have the defaults set.
{% code title="dnsconfig.js" %}
```javascript
var COMMON = NewDnsProvider("foo");
DEFAULTS(
@ -27,10 +28,12 @@ D("example.com",
A("@","1.2.3.4")
);
```
{% endcode %}
If you want to clear the defaults, you can do the following.
The domain `example2.com` will **not** have the defaults set.
{% code title="dnsconfig.js" %}
```javascript
DEFAULTS();
@ -40,3 +43,4 @@ D("example2.com",
A("@","1.2.3.4")
);
```
{% endcode %}

View File

@ -23,10 +23,13 @@ point (delegate) the domain at a specific list of DNS servers.
For example these two statements are equivalent:
{% code title="dnsconfig.js" %}
```javascript
DOMAIN_ELSEWHERE("example.com", REG_NAMEDOTCOM, ["ns1.foo.com", "ns2.foo.com"]);
```
{% endcode %}
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REG_NAMEDOTCOM,
NO_PURGE,
@ -34,6 +37,7 @@ D("example.com", REG_NAMEDOTCOM,
NAMESERVER("ns2.foo.com")
);
```
{% endcode %}
{% hint style="info" %}
**NOTE**: The `NO_PURGE` is used out of abundance of caution but since no

View File

@ -28,16 +28,20 @@ hard-code them in your dnsconfig.js file.
For example these two statements are equivalent:
{% code title="dnsconfig.js" %}
```javascript
DOMAIN_ELSEWHERE_AUTO("example.com", REG_NAMEDOTCOM, DSP_AZURE);
```
{% endcode %}
{% code title="dnsconfig.js" %}
```javascript
D("example.com", REG_NAMEDOTCOM,
NO_PURGE,
DnsProvider(DSP_AZURE)
);
```
{% endcode %}
{% hint style="info" %}
**NOTE**: The `NO_PURGE` is used to prevent DNSControl from changing the records.

View File

@ -32,6 +32,7 @@ Some operators only act on an apex domain (e.g.
`CF_REDIRECT` and `CF_TEMP_REDIRECT`). Using them
in a `D_EXTEND` subdomain may not be what you expect.
{% code title="dnsconfig.js" %}
```javascript
D("domain.tld", REG, DnsProvider(DNS),
A("@", "127.0.0.1"), // domain.tld
@ -56,6 +57,7 @@ D_EXTEND("sub.domain.tld",
CNAME("i", "j") // i.sub.domain.tld -> j.sub.domain.tld
);
```
{% endcode %}
This will end up in the following modifications: (This output assumes the `--full` flag)

View File

@ -20,6 +20,7 @@ Otherwise the syntax of `FETCH` is the same as `fetch`.
> 1. Relying on external sources adds a point of failure. If the external source doesn't work, your script won't either. Please make sure you are aware of the consequences.
> 2. Make sure DNSControl only uses verified configuration if you want to use `FETCH`. For example, an attacker can send Pull Requests to your config repo, and have your CI test malicious configurations and make arbitrary HTTP requests. Therefore, `FETCH` must be explicitly enabled with flag `--allow-fetch` on DNSControl invocation.
{% code title="dnsconfig.js" %}
```javascript
var REG_NONE = NewRegistrar('none');
var DNS_BIND = NewDnsProvider('bind');
@ -42,3 +43,4 @@ FETCH('https://example.com', {
]);
});
```
{% endcode %}

View File

@ -9,16 +9,19 @@ return: number
Converts an IPv4 address from string to an integer. This allows performing mathematical operations with the IP address.
{% code title="dnsconfig.js" %}
```javascript
var addrA = IP('1.2.3.4')
var addrB = addrA + 1
// addrB = 1.2.3.5
```
{% endcode %}
{% hint style="info" %}
**NOTE**: `IP()` does not accept IPv6 addresses (PRs gladly accepted!). IPv6 addresses are simply strings:
{% endhint %}
{% code title="dnsconfig.js" %}
```javascript
// IPv4 Var
var addrA1 = IP("1.2.3.4");
@ -27,3 +30,4 @@ var addrA2 = "1.2.3.4";
// IPv6 Var
var addrAAAA = "0:0:0:0:0:0:0:0";
```
{% endcode %}

View File

@ -25,6 +25,7 @@ This function will return an opaque string that should be assigned to a variable
Prior to [v3.16](../../v316.md):
{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");
@ -33,9 +34,11 @@ D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
A("@","1.2.3.4")
);
```
{% endcode %}
In [v3.16](../../v316.md) and later:
{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom");
var DNS_MYAWS = NewDnsProvider("myaws");
@ -44,3 +47,4 @@ D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
A("@","1.2.3.4")
);
```
{% endcode %}

View File

@ -25,6 +25,7 @@ This function will return an opaque string that should be assigned to a variable
Prior to [v3.16](../../v316.md):
{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom", "NAMEDOTCOM");
var DNS_MYAWS = NewDnsProvider("myaws", "ROUTE53");
@ -33,9 +34,11 @@ D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
A("@","1.2.3.4")
);
```
{% endcode %}
In [v3.16](../../v316.md) and later:
{% code title="dnsconfig.js" %}
```javascript
var REG_MYNDC = NewRegistrar("mynamedotcom");
var DNS_MYAWS = NewDnsProvider("myaws");
@ -44,3 +47,4 @@ D("example.com", REG_MYNDC, DnsProvider(DNS_MYAWS),
A("@","1.2.3.4")
);
```
{% endcode %}

View File

@ -9,6 +9,8 @@ ts_return: never
`PANIC` terminates the script and therefore DNSControl with an exit code of 1. This should be used if your script cannot gather enough information to generate records, for example when a HTTP request failed.
{% code title="dnsconfig.js" %}
```javascript
PANIC("Something really bad has happened");
```
{% endcode %}

View File

@ -32,6 +32,7 @@ Note that the lower bits (the ones outside the netmask) must be zeros. They are
zeroed out automatically. Thus, `REV('1.2.3.4/24')` is an error. This is done
to catch typos.
{% code title="dnsconfig.js" %}
```javascript
D(REV('1.2.3.0/24'), REGISTRAR, DnsProvider(BIND),
PTR("1", 'foo.example.com.'),
@ -48,6 +49,7 @@ D(REV('2001:db8:302::/48'), REGISTRAR, DnsProvider(BIND),
PTR("2001:db8:302::3", 'three.example.com.'), // 3.0.0...
);
```
{% endcode %}
In the future we plan on adding a flag to `A()` which will insert
the correct PTR() record if the appropriate `D(REV()` domain (i.e. `.arpa` domain) has been

View File

@ -10,6 +10,7 @@ configured at the time the function is called. Calling this function early or la
domains at the end of your configuration file.
Example for adding records to all configured domains:
{% code title="dnsconfig.js" %}
```javascript
var domains = getConfiguredDomains();
for(i = 0; i < domains.length; i++) {
@ -18,6 +19,7 @@ for(i = 0; i < domains.length; i++) {
)
}
```
{% endcode %}
This will end up in following modifications: (All output assumes the `--full` flag)
@ -40,6 +42,7 @@ Example for adding DMARC report records:
This example might be more useful, specially for configuring the DMARC report records. According to DMARC RFC you need to specify `domain2.tld._report.dmarc.domain1.tld` to allow `domain2.tld` to send aggregate/forensic email reports to `domain1.tld`. This can be used to do this in an easy way, without using the wildcard from the RFC.
{% code title="dnsconfig.js" %}
```javascript
var domains = getConfiguredDomains();
for(i = 0; i < domains.length; i++) {
@ -48,6 +51,7 @@ for(i = 0; i < domains.length; i++) {
);
}
```
{% endcode %}
This will end up in following modifications:

View File

@ -17,15 +17,19 @@ Possible parameters are:
Example to load `.js` files recursively:
{% code title="dnsconfig.js" %}
```javascript
require_glob("./domains/");
```
{% endcode %}
Example to load `.js` files only in `domains/`:
{% code title="dnsconfig.js" %}
```javascript
require_glob("./domains/", false);
```
{% endcode %}
One more important thing to note: `require_glob()` is as smart as `require()` is. It loads files always relative to the JavaScript
file where it's being executed in. Let's go with an example, as it describes it better:

View File

@ -24,6 +24,7 @@ authorized certificate authorities and the builder cares about the rest.
For example you can use:
{% code title="dnsconfig.js" %}
```javascript
CAA_BUILDER({
label: "@",
@ -36,6 +37,7 @@ CAA_BUILDER({
issuewild: "none",
})
```
{% endcode %}
The parameters are:
@ -47,9 +49,11 @@ The parameters are:
`CAA_BUILDER()` returns multiple records (when configured as example above):
{% code title="dnsconfig.js" %}
```javascript
CAA("@", "iodef", "mailto:test@domain.tld", CAA_CRITICAL)
CAA("@", "issue", "letsencrypt.org")
CAA("@", "issue", "comodoca.com")
CAA("@", "issuewild", ";")
```
{% endcode %}

View File

@ -39,6 +39,7 @@ DMARC policies for your domains.
### Simple example
{% code title="dnsconfig.js" %}
```javascript
DMARC_BUILDER({
policy: 'reject',
@ -47,6 +48,7 @@ DMARC_BUILDER({
],
})
```
{% endcode %}
This yield the following record:
@ -56,6 +58,7 @@ This yield the following record:
### Advanced example
{% code title="dnsconfig.js" %}
```javascript
DMARC_BUILDER({
policy: 'reject',
@ -72,8 +75,12 @@ DMARC_BUILDER({
],
failureOptions: '1',
reportInterval: '1h',
}),
});
```
{% endcode %}
{% code title="dnsconfig.js" %}
```javascript
DMARC_BUILDER({
label: 'insecure',
policy: 'none',
@ -84,8 +91,9 @@ DMARC_BUILDER({
SPF: false,
DKIM: true,
},
})
});
```
{% endcode %}
This yields the following records:

View File

@ -37,11 +37,13 @@ enforce the "10 lookup rule".
Here is an example of how SPF settings are normally done:
{% code title="dnsconfig.js" %}
```javascript
D("example.tld", REG, DNS, ...
TXT("v=spf1 ip4:198.252.206.0/24 ip4:192.111.0.0/24 include:_spf.google.com include:mailgun.org include:spf-basic.fogcreek.com include:mail.zendesk.com include:servers.mcsv.net include:sendgrid.net include:450622.spf05.hubspotemail.net ~all")
)
```
{% endcode %}
This has a few problems:
@ -51,6 +53,7 @@ This has a few problems:
## The DNSControl way
{% code title="dnsconfig.js" %}
```javascript
D("example.tld", REG, DSP, ...
A("@", "10.2.2.2"),
@ -80,6 +83,7 @@ D("example.tld", REG, DSP, ...
}),
);
```
{% endcode %}
By using the `SPF_BUILDER()` we gain many benefits:
@ -92,6 +96,7 @@ By using the `SPF_BUILDER()` we gain many benefits:
When you want to specify SPF settings for a domain, use the
`SPF_BUILDER()` function.
{% code title="dnsconfig.js" %}
```javascript
D("example.tld", REG, DSP, ...
...
@ -115,6 +120,7 @@ D("example.tld", REG, DSP, ...
...
);
```
{% endcode %}
The parameters are:
@ -283,6 +289,7 @@ record an include is added.
In some situations we define an SPF setting once and want to re-use
it on many domains. Here's how to do this:
{% code title="dnsconfig.js" %}
```javascript
var SPF_MYSETTINGS = SPF_BUILDER({
label: "@",
@ -306,3 +313,4 @@ D("example2.tld", REG, DSP, ...
SPF_MYSETTINGS
);
```
{% endcode %}

View File

@ -24,6 +24,7 @@ The value can be:
* If no unit is specified, the default is seconds.
* We highly recommend using units instead of the number of seconds. Would your coworkers understand your intention better if you wrote `14400` or `'4h'`?
{% code title="dnsconfig.js" %}
```javascript
D('example.com', REGISTRAR, DnsProvider('R53'),
DefaultTTL(2000),
@ -33,3 +34,4 @@ D('example.com', REGISTRAR, DnsProvider('R53'),
A('demo2', '3.4.5.12', TTL('5w')), // 5 weeks
);
```
{% endcode %}