mirror of
https://github.com/coredns/coredns.git
synced 2026-01-18 14:51:18 -05:00
This commit is contained in:
committed by
John Belamaric
parent
556a289d9a
commit
d35f2c73ec
@@ -96,3 +96,48 @@ rewrite edns0 subnet set 24 56
|
||||
|
||||
* If the query has source IP as IPv4, the first 24 bits in the IP will be the network subnet.
|
||||
* If the query has source IP as IPv6, the first 56 bits in the IP will be the network subnet.
|
||||
|
||||
### Name Field Rewrites
|
||||
|
||||
The `rewrite` plugin offers the ability to match on the name in the question section of
|
||||
a DNS request. The match could be exact, substring, or based on a prefix, suffix, or regular
|
||||
expression.
|
||||
|
||||
The syntax for the name re-writing is as follows:
|
||||
|
||||
```
|
||||
rewrite [continue|stop] name [exact|prefix|suffix|substring|regex] STRING STRING
|
||||
```
|
||||
|
||||
The match type, i.e. `exact`, `substring`, etc., triggers re-write:
|
||||
|
||||
* **exact** (default): on exact match of the name in the question section of a request
|
||||
* **substring**: on a partial match of the name in the question section of a request
|
||||
* **prefix**: when the name begins with the matching string
|
||||
* **suffix**: when the name ends with the matching string
|
||||
* **regex**: when the name in the question section of a request matches a regular expression
|
||||
|
||||
If the match type is omitted, the `exact` match type is being assumed.
|
||||
|
||||
The following instruction allows re-writing the name in the query that
|
||||
contains `service.us-west-1.example.org` substring.
|
||||
|
||||
```
|
||||
rewrite name substring service.us-west-1.example.org service.us-west-1.consul
|
||||
```
|
||||
|
||||
Thus:
|
||||
* Incoming Request Name: `ftp.service.us-west-1.example.org`
|
||||
* Re-written Request Name: `ftp.service.us-west-1.consul`
|
||||
|
||||
The following instruction uses regular expressions. The name in a request
|
||||
matching `(.*)-(us-west-1)\.example\.org` regular expression is being replaces with
|
||||
`{1}.service.{2}.consul`, where `{1}` and `{2}` are regular expression match groups.
|
||||
|
||||
```
|
||||
rewrite name regex (.*)-(us-west-1)\.example\.org {1}.service.{2}.consul
|
||||
```
|
||||
|
||||
Thus:
|
||||
* Incoming Request Name: `ftp-us-west-1.example.org`
|
||||
* Re-written Request Name: `ftp.service.us-west-1.consul`
|
||||
|
||||
Reference in New Issue
Block a user