@@ -11,16 +11,16 @@ Rewrites are invisible to the client. There are simple rewrites (fast) and compl
...
@@ -11,16 +11,16 @@ Rewrites are invisible to the client. There are simple rewrites (fast) and compl
## Syntax
## Syntax
A simplified/easy to digest syntax for *rewrite* is...
A simplified/easy-to-digest syntax for *rewrite* is...
~~~
~~~
rewrite [continue|stop] FIELD [FROM TO|FROM TTL]
rewrite [continue|stop] FIELD [FROM TO|FROM TTL]
~~~
~~~
***FIELD** indicates what part of the request/response is being re-written.
***FIELD** indicates what part of the request/response is being re-written.
*`type` - the type field of the request will be rewritten. FROM/TO must be a DNS record type (`A`, `MX`, etc);
*`type` - the type field of the request will be rewritten. FROM/TO must be a DNS record type (`A`, `MX`, etc.);
e.g., to rewrite ANY queries to HINFO, use `rewrite type ANY HINFO`.
e.g., to rewrite ANY queries to HINFO, use `rewrite type ANY HINFO`.
*`class` - the class of the message will be rewritten. FROM/TO must be a DNS class type (`IN`, `CH`, or `HS`) e.g., to rewrite CH queries to IN use `rewrite class CH IN`.
*`class` - the class of the message will be rewritten. FROM/TO must be a DNS class type (`IN`, `CH`, or `HS`); e.g., to rewrite CH queries to IN use `rewrite class CH IN`.
*`name` - the query name in the _request_ is rewritten; by default this is a full match of the
*`name` - the query name in the _request_ is rewritten; by default this is a full match of the
name, e.g., `rewrite name example.net example.org`. Other match types are supported, see the **Name Field Rewrites** section below.
name, e.g., `rewrite name example.net example.org`. Other match types are supported, see the **Name Field Rewrites** section below.
*`answer name` - the query name in the _response_ is rewritten. This option has special restrictions and requirements, in particular it must always combined with a `name` rewrite. See below in the **Response Rewrites** section.
*`answer name` - the query name in the _response_ is rewritten. This option has special restrictions and requirements, in particular it must always combined with a `name` rewrite. See below in the **Response Rewrites** section.
...
@@ -31,37 +31,37 @@ e.g., to rewrite ANY queries to HINFO, use `rewrite type ANY HINFO`.
...
@@ -31,37 +31,37 @@ e.g., to rewrite ANY queries to HINFO, use `rewrite type ANY HINFO`.
***TO** is the destination name or type to rewrite to
***TO** is the destination name or type to rewrite to
***TTL** is the number of seconds to set the TTL value to
***TTL** is the number of seconds to set the TTL value to
If you specify multiple rules and an incoming query matches on multiple rules, the rewrite
If you specify multiple rules and an incoming query matches multiple rules, the rewrite
will behave as following
will behave as follows:
*`continue` will continue apply the next rule in the rule list.
*`stop` will consider the current rule is the last rule and will not continue. Default behaviour
*`continue` will continue applying the next rule in the rule list.
for not specifying this rule processing mode is `stop`
*`stop` will consider the current rule the last rule and will not continue. The default behaviour is `stop`
### Name Field Rewrites
### Name Field Rewrites
The `rewrite` plugin offers the ability to match on the name in the question section of
The `rewrite` plugin offers the ability to match the name in the question section of
a DNS request. The match could be exact, substring, or based on a prefix, suffix, or regular
a DNS request. The match could be exact, a substring match, or based on a prefix, suffix, or regular
expression. If the newly used name is not a legal domain name the plugin returns an error to the
expression. If the newly used name is not a legal domain name, the plugin returns an error to the
client.
client.
The syntax for the name re-writing is as follows:
The syntax for name rewriting is as follows:
```
```
rewrite [continue|stop] name [exact|prefix|suffix|substring|regex] STRING STRING
rewrite [continue|stop] name [exact|prefix|suffix|substring|regex] STRING STRING
```
```
The match type, i.e. `exact`, `substring`, etc., triggers re-write:
The match type, e.g., `exact`, `substring`, etc., triggers rewrite:
***exact** (default): on exact match of the name in the question section of a request
***exact** (default): on an 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
***substring**: on a partial match of the name in the question section of a request
***prefix**: when the name begins with the matching string
***prefix**: when the name begins with the matching string
***suffix**: when the name ends 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
***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.
If the match type is omitted, the `exact` match type is assumed.
The following instruction allows re-writing the name in the query that
The following instruction allows rewriting names in the query that
* If the metadata plugin is enabled, then labels are supported as variables if they are presented within curly brackets.
* If the metadata plugin is enabled, then labels are supported as variables if they are presented within curly brackets.
the variable data will be filled with the value associated with that label. If that label is not provided,
The variable data will be replaced with the value associated with that label. If that label is not provided,
the variable will be silently substitute by an empty string.
the variable will be silently substituted with an empty string.
Examples:
Examples:
...
@@ -289,8 +289,8 @@ Example:
...
@@ -289,8 +289,8 @@ Example:
rewrite edns0 subnet set 24 56
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's source IP address is an IPv4 address, 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.
* If the query's source IP address is an IPv6 address, the first 56 bits in the IP will be the network subnet.
## Full Syntax
## Full Syntax
...
@@ -299,4 +299,4 @@ The full plugin usage syntax is harder to digest...
...
@@ -299,4 +299,4 @@ The full plugin usage syntax is harder to digest...
rewrite [continue|stop] {type|class|edns0|name [exact|prefix|suffix|substring|regex [FROM TO answer name]]} FROM TO
rewrite [continue|stop] {type|class|edns0|name [exact|prefix|suffix|substring|regex [FROM TO answer name]]} FROM TO
~~~
~~~
The syntax above doesn't cover the multiline block option for specifying a name request+response rewrite rule described in the **Response Rewrite** section.
The syntax above doesn't cover the multi-line block option for specifying a name request+response rewrite rule described in the **Response Rewrite** section.