diff options
Diffstat (limited to 'plugin/rewrite/README.md')
-rw-r--r-- | plugin/rewrite/README.md | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/plugin/rewrite/README.md b/plugin/rewrite/README.md index b432d0ca4..c276fb9b0 100644 --- a/plugin/rewrite/README.md +++ b/plugin/rewrite/README.md @@ -13,7 +13,7 @@ Rewrites are invisible to the client. There are simple rewrites (fast) and compl A simplified/easy to digest syntax for *rewrite* is... ~~~ -rewrite [continue|stop] FIELD FROM TO +rewrite [continue|stop] FIELD [FROM TO|FROM TTL] ~~~ * **FIELD** indicates what part of the request/response is being re-written. @@ -25,9 +25,11 @@ e.g., to rewrite ANY queries to HINFO, use `rewrite type ANY HINFO`. 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. * `edns0` - an EDNS0 option can be appended to the request as described below in the **EDNS0 Options** section. + * `ttl` - the TTL value in the _response_ is rewritten. -* **FROM** is the name or type to match +* **FROM** is the name (exact, suffix, prefix, substring, or regex) or type to match * **TO** is the destination name or type to rewrite 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 will behave as following @@ -177,6 +179,32 @@ follows: rewrite [continue|stop] name regex STRING STRING answer name STRING STRING ``` +### TTL Field Rewrites + +At times, the need for rewriting TTL value could arise. For example, a DNS server +may prevent caching by setting TTL as low as zero (`0`). An administrator +may want to increase the TTL to prevent caching, e.g. to 15 seconds. + +In the below example, the TTL in the answers for `coredns.rocks` domain are +being set to `15`: + +``` + rewrite continue { + ttl regex (.*)\.coredns\.rocks 15 + } +``` + +By the same token, an administrator may use this feature to force caching by +setting TTL value really low. + + +The syntax for the TTL rewrite rule is as follows. The meaning of +`exact|prefix|suffix|substring|regex` is the same as with the name rewrite rules. + +``` +rewrite [continue|stop] ttl [exact|prefix|suffix|substring|regex] STRING SECONDS +``` + ## EDNS0 Options Using FIELD edns0, you can set, append, or replace specific EDNS0 options on the request. |