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:
committed by
GitHub
parent
af99942a3e
commit
05be3b83ed
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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.
|
||||
|
@ -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 %}
|
||||
|
@ -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.
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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'`.
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 %}
|
||||
|
@ -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
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user