2019-08-30 15:58:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								. \" Generated by Mmark Markdown Processer - mmark.miek.nl  
						 
					
						
							
								
									
										
										
										
											2020-09-14 09:43:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.TH  "COREDNS-TEMPLATE"  7  "September 2020"  "CoreDNS"  "CoreDNS Plugins" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "NAME" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fI template\fP  - allows for dynamic responses based on the incoming query. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "DESCRIPTION" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The \fI template\fP  plugin allows you to dynamically respond to queries by just writing a (Go) template.
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "SYNTAX" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								template CLASS TYPE [ZONE...] {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    match REGEX...
							 
						 
					
						
							
								
									
										
										
										
											2019-02-27 20:32:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    answer RR
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    additional RR
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    authority RR
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    rcode CODE
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    fallthrough [ZONE...]
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB CLASS\fP  the query class (usually IN or ANY). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB TYPE\fP  the query type (A, PTR, ... can be ANY to match all types). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB ZONE\fP  the zone scope(s) for this template. Defaults to the server zones. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB REGEX\fP  Go regexp 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://golang.org/pkg/regexp/\[ ra] that are matched against the incoming question name. Specifying no regex matches everything (default: \fB \fC .*\fR ). First matching regex wins. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC answer|additional|authority\fR  \fB RR\fP  A RFC 1035 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://tools.ietf.org/html/rfc1035#section-5\[ ra] style resource record fragment 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								built by a Go template
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://golang.org/pkg/text/template/\[ ra] that contains the reply. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC rcode\fR  \fB CODE\fP  A response code (\fB \fC NXDOMAIN, SERVFAIL, ...\fR ). The default is \fB \fC SUCCESS\fR . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC fallthrough\fR  Continue with the next plugin if the zone matched but no regex matched. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								If specific zones are listed (for example \fB \fC in-addr.arpa\fR  and \fB \fC ip6.arpa\fR ), then only queries for
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								those zones will be subject to fallthrough.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								At least one \fB \fC answer\fR  or \fB \fC rcode\fR  directive is needed (e.g. \fB \fC rcode NXDOMAIN\fR ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Also see
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]#also-see\[ ra] contains an additional reading list. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "TEMPLATES" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Each resource record is a full-featured Go template
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://golang.org/pkg/text/template/\[ ra] with the following predefined data 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Zone\fR  the matched zone string (e.g. \fB \fC example.\fR ). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Name\fR  the query name, as a string (lowercased). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Class\fR  the query class (usually \fB \fC IN\fR ). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Type\fR  the RR type requested (e.g. \fB \fC PTR\fR ). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Match\fR  an array of all matches. \fB \fC index .Match 0\fR  refers to the whole match. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Group\fR  a map of the named capture groups. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Message\fR  the complete incoming DNS message. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Question\fR  the matched question section. 
						 
					
						
							
								
									
										
										
										
											2019-07-03 19:38:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-10 08:38:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								\fB \fC .Remote\fR  client’  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-03 19:38:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC .Meta\fR  a function that takes a metadata name and returns the value, if the 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								metadata plugin is enabled. For example, \fB \fC .Meta "kubernetes/client-namespace"\fR 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The output of the template must be a RFC 1035
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://tools.ietf.org/html/rfc1035\[ ra] style resource record (commonly referred to as a "zone file"). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB WARNING\fP  there is a syntactical problem with Go templates and CoreDNS config files. Expressions 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 like \fB \fC {{$var}}\fR  will be interpreted as a reference to an environment variable by CoreDNS (and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 Caddy) while \fB \fC {{ $var }}\fR  will work. See Bugs
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]#bugs\[ ra] and corefile(5). 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "METRICS" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-10 07:45:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								If monitoring is enabled (via the \fI prometheus\fP  plugin) then the following metrics are exported:
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC coredns_template_matches_total{server, regex}\fR  the total number of matched requests by regex. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC coredns_template_template_failures_total{server, regex,section,template}\fR  the number of times the Go templating failed. Regex, section and template label values can be used to map the error back to the config file. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\fB \fC coredns_template_rr_failures_total{server, regex,section,template}\fR  the number of times the templated resource record was invalid and could not be parsed. Regex, section and template label values can be used to map the error back to the config file. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Both failure cases indicate a problem with the template configuration. The \fB \fC server\fR  label indicates
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								the server incrementing the metric, see the \fI metrics\fP  plugin for details.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "EXAMPLES" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "RESOLVE EVERYTHING TO NXDOMAIN" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The most simplistic template is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template ANY ANY {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      rcode NXDOMAIN
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  1 \.  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								This template uses the default zone (\fB \fC .\fR  or all queries)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  2 \.  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								All queries will be answered (no \fB \fC fallthrough\fR )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  3 \.  4 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The answer is always NXDOMAIN
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "RESOLVE .INVALID AS NXDOMAIN" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The \fB \fC .invalid\fR  domain is a reserved TLD (see RFC 2606 Reserved Top Level DNS Names
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://tools.ietf.org/html/rfc2606#section-2\[ ra]) to indicate invalid domains. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template ANY ANY invalid {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      rcode NXDOMAIN
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      authority "invalid. 60 {{ .Class }} SOA ns.invalid. hostmaster.invalid. (1 60 60 60 60)"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  1 \.  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								A query to .invalid will result in NXDOMAIN (rcode)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  2 \.  4 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-25 21:59:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								A dummy SOA record is sent to hand out a TTL of 60s for caching purposes
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.IP  3 \.  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Querying \fB \fC .invalid\fR  in the \fB \fC CH\fR  class will also cause a NXDOMAIN/SOA response
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  4 \.  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The default regex is \fB \fC .*\fR 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "BLOCK INVALID SEARCH DOMAIN COMPLETIONS" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Imagine you run \fB \fC example.com\fR  with a datacenter \fB \fC dc1.example.com\fR . The datacenter domain
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								is part of the DNS search domain.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								However \fB \fC something.example.com.dc1.example.com\fR  would indicate a fully qualified
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								domain name (\fB \fC something.example.com\fR ) that inadvertently has the default domain or search
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								path (\fB \fC dc1.example.com\fR ) added.
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN ANY example.com.dc1.example.com {
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      rcode NXDOMAIN
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      authority "{{ .Zone }} 60 IN SOA ns.example.com hostmaster.example.com (1 60 60 60 60)"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								A more verbose regex based equivalent would be
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN ANY example.com {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      match "example\\ .com\\ .(dc1\\ .example\\ .com\\ .)$"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      rcode NXDOMAIN
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      authority "{{ index .Match 1 }} 60 IN SOA ns.{{ index .Match 1 }} hostmaster.{{ index .Match 1 }} (1 60 60 60 60)"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The regex-based version can do more complex matching/templating while zone-based templating is easier to read and use.
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "RESOLVE A/PTR FOR .EXAMPLE" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    # ip\- a\- b\- c\- d.example A a.b.c.d
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN A example {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      match (^|[.])ip\- (?P<a>[0\- 9]*)\- (?P<b>[0\- 9]*)\- (?P<c>[0\- 9]*)\- (?P<d>[0\- 9]*)[.]example[.]$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN A {{ .Group.a }}.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    # d.c.b.a.in\- addr.arpa PTR ip\- a\- b\- c\- d.example
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    template IN PTR in\- addr.arpa {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      match ^(?P<d>[0\- 9]*)[.](?P<c>[0\- 9]*)[.](?P<b>[0\- 9]*)[.](?P<a>[0\- 9]*)[.]in\- addr[.]arpa[.]$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN PTR ip\- {{ .Group.a }}\- {{ .Group.b }}\- {{ .Group.c }}\- {{ .Group.d }}.example."
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								An IPv4 address consists of 4 bytes, \fB \fC a.b.c.d\fR . Named groups make it less error-prone to reverse the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								IP address in the PTR case. Try to use named groups to explain what your regex and template are doing.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Note that the A record is actually a wildcard: any subdomain of the IP address will resolve to the IP address.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Having templates to map certain PTR/A pairs is a common pattern.
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Fallthrough is needed for mixed domains where only some responses are templated.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "RESOLVE MULTIPLE IP PATTERNS" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN A example {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      match "^ip\- (?P<a>10)\- (?P<b>[0\- 9]*)\- (?P<c>[0\- 9]*)\- (?P<d>[0\- 9]*)[.]dc[.]example[.]$"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      match "^(?P<a>[0\- 9]*)[.](?P<b>[0\- 9]*)[.](?P<c>[0\- 9]*)[.](?P<d>[0\- 9]*)[.]ext[.]example[.]$"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN A {{ .Group.a}}.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Named capture groups can be used to template one response for multiple patterns.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "RESOLVE A AND MX RECORDS FOR IP TEMPLATES IN .EXAMPLE" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN A example {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      match ^ip\- 10\- (?P<b>[0\- 9]*)\- (?P<c>[0\- 9]*)\- (?P<d>[0\- 9]*)[.]example[.]$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN MX example {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      match ^ip\- 10\- (?P<b>[0\- 9]*)\- (?P<c>[0\- 9]*)\- (?P<d>[0\- 9]*)[.]example[.]$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN MX 10 {{ .Name }}"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SS  "ADDING AUTHORITATIVE NAMESERVERS TO THE RESPONSE" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.RS 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.nf 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\& . { 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    forward . 8.8.8.8
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN A example {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      match ^ip\- 10\- (?P<b>[0\- 9]*)\- (?P<c>[0\- 9]*)\- (?P<d>[0\- 9]*)[.]example[.]$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      authority  "example. 60 IN NS ns0.example."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      authority  "example. 60 IN NS ns1.example."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      additional "ns0.example. 60 IN A 203.0.113.8"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      additional "ns1.example. 60 IN A 198.51.100.8"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    template IN MX example {
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								      match ^ip\- 10\- (?P<b>[0\- 9]*)\- (?P<c>[0\- 9]*)\- (?P<d>[0\- 9]*)[.]example[.]$
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      answer "{{ .Name }} 60 IN MX 10 {{ .Name }}"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      additional "{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      authority  "example. 60 IN NS ns0.example."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      authority  "example. 60 IN NS ns1.example."
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      additional "ns0.example. 60 IN A 203.0.113.8"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      additional "ns1.example. 60 IN A 198.51.100.8"
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								      fallthrough
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-10 11:45:12 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.fi 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.RE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "ALSO SEE" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Go regexp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://golang.org/pkg/regexp/\[ ra] for details about the regex implementation 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								RE2 syntax reference
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://github.com/google/re2/wiki/Syntax\[ ra] for details about the regex syntax 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								RFC 1034
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://tools.ietf.org/html/rfc1034#section-3.6.1\[ ra] and RFC 1035 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://tools.ietf.org/html/rfc1035#section-5\[ ra] for the resource record format 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								.IP  \(bu  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Go template
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://golang.org/pkg/text/template/\[ ra] for the template language reference 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-24 12:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.SH  "BUGS" 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-06 08:42:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								.PP 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								CoreDNS supports caddyfile environment variables
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://caddyserver.com/docs/caddyfile#env\[ ra] 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								with notion of \fB \fC {$ENV_VAR}\fR . This parser feature will break Go template variables
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								\[ la]https://golang.org/pkg/text/template/#hdr-Variables\[ ra] notations like\fB \fC {{$variable}}\fR . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								The equivalent notation \fB \fC {{ $variable }}\fR  will work.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Try to avoid Go template variables in the context of this plugin.