middleware/reverse: random updates (#516)

* middleware/reverse: random updates

Make the documentation somewhat shorter (and hopefully clearer in the
process). Also to be on-par with the *auto* middleware, start counting
the referenced zones from 1 (instead of 0).
Some variable cleanups and use the NextOrFailure in the ServeDNS
function.

* More TODOs
This commit is contained in:
Miek Gieben
2017-02-10 12:48:51 +00:00
committed by GitHub
parent 87a39a6353
commit 3e196a6d57
5 changed files with 123 additions and 154 deletions

View File

@@ -1,42 +1,43 @@
# reverse
The *reverse* middleware allows CoreDNS to respond dynamic to an PTR request and the related A/AAAA request.
The *reverse* middleware allows CoreDNS to respond dynamicly to an PTR request and the related A/AAAA request.
## Syntax
~~~
reverse NETWORK.. {
reverse NETWORK... {
hostname TEMPLATE
[ttl TTL]
[fallthrough]
~~~
* **NETWORK** one or more CIDR formatted networks to respond on.
* `hostname` inject the ip and zone to an template for the hostname. Defaults to "ip-{ip}.{zone[0]}". See below for template.
* `hostname` inject the IP and zone to an template for the hostname. Defaults to "ip-{IP}.{zone[1]}". See below for template.
* `ttl` defaults to 60
* `fallthrough` If zone matches and no record can be generated, pass request to the next middleware.
### Template Syntax
The template for the hostname is used for generating the PTR for an reverse lookup and matching the forward lookup back to an ip.
The template for the hostname is used for generating the PTR for an reverse lookup and matching the
forward lookup back to an IP.
#### `{ip}`
This symbol is **required** to work.
V4 network replaces the "." with an "-". 10.1.1.1 results in "10-1-1-1"
V6 network removes the ":" and fills the zeros. "ffff::ffff" results in "ffff000000000000000000000000ffff"
The `{ip}` symbol is **required** to make reverse work.
For IPv4 lookups the "." is replaced with an "-", i.e.: 10.1.1.1 results in "10-1-1-1"
With IPv6 lookups the ":" is removed, and any zero ranged are expanded, i.e.:
"ffff::ffff" results in "ffff000000000000000000000000ffff"
#### `{zone[i]}`
This symbol is **optional** to use and can be replaced by a fix zone string.
The zone will be matched by the configured listener on the server block key.
`i` needs to be replaced to the index of the configured listener zones, starting with 0.
`arpa.:53 domain.com.:8053` will resolve `zone{0}` to `arpa.` and `zone{1}` to `domain.com.`
The `{zone[i]}` symbol is **optional** and can be replaced by a fixed (zone) string.
The zone will be matched by the zones listed in *this* configuration stanza.
`i` needs to be replaced to the index of the configured listener zones, starting with 1.
## Examples
~~~
# Serve on port 53
# match arpa. and compute.internal. to resolv reverse and forward lookup
.arpa.:53 compute.internal.:53 {
~~~ txt
arpa compute.internal {
# proxy unmatched requests
proxy . 8.8.8.8
@@ -48,32 +49,25 @@ The zone will be matched by the configured listener on the server block key.
# AAAA ip-fd010000000000000000000000000001.compute.internal. 3600 fd01::1
reverse 10.32.0.0/16 fd01::/16 {
# template of the ip injection to hostname, zone resolved to compute.internal.
hostname ip-{ip}.{zone[1]}
hostname ip-{ip}.{zone[2]}
# set time-to-live of the RR
ttl 3600
# forward unanswered or unmatched requests to proxy
# without this flag, requesting A/AAAA records on compute.internal. will end here
# Forward unanswered or unmatched requests to proxy # without this flag, requesting A/AAAA
records on compute.internal. will end here.
fallthrough
}
# cache with ttl timeout
cache
}
~~~
~~~
# Serve on port 53
# listen only on the specific network
32.10.in-addr.arpa.arpa.:53 arpa.company.org.:53 {
~~~ txt
32.10.in-addr.arpa.arpa arpa.company.org {
reverse 10.32.0.0/16 {
# template of the ip injection to hostname, zone resolved to arpa.company.org.
hostname "ip-{ip}.v4.{zone[1]}"
hostname "ip-{ip}.v4.{zone[2]}"
# set time-to-live of the RR
ttl 3600
# fallthrough is not required, v4.arpa.company.org. will be only answered here
@@ -84,14 +78,7 @@ The zone will be matched by the configured listener on the server block key.
# its also possible to set fix domain suffix
hostname ip-{ip}.fix.arpa.company.org.
# set time-to-live of the RR
ttl 3600
}
# cache with ttl timeout
cache
}
~~~