mirror of
https://github.com/coredns/coredns.git
synced 2025-08-05 13:56:59 +02:00
view: Add IPv6 example match (#7355)
Add an IPv6 source address matching example to the view plugin. Fixes: https://github.com/coredns/coredns/issues/7354 Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
67f3ece737
commit
83afff1fec
@ -1,5 +1,5 @@
|
||||
.\" Generated by Mmark Markdown Processer - mmark.miek.nl
|
||||
.TH "COREDNS-VIEW" 7 "September 2022" "CoreDNS" "CoreDNS Plugins"
|
||||
.TH "COREDNS-VIEW" 7 "June 2025" "CoreDNS" "CoreDNS Plugins"
|
||||
|
||||
.SH "NAME"
|
||||
.PP
|
||||
@ -41,6 +41,7 @@ Implement CIDR based split DNS routing. This will return a different
|
||||
answer for \fB\fCtest.\fR depending on client's IP address. It returns ...
|
||||
* \fB\fCtest. 3600 IN A 1.1.1.1\fR, for queries with a source address in 127.0.0.0/24
|
||||
* \fB\fCtest. 3600 IN A 2.2.2.2\fR, for queries with a source address in 192.168.0.0/16
|
||||
* \fB\fCtest. 3600 IN AAAA 2001:0DB8::1\fR, for queries with a source address in 2001:0DB8::/32
|
||||
* \fB\fCtest. 3600 IN A 3.3.3.3\fR, for all others
|
||||
|
||||
.PP
|
||||
@ -65,6 +66,17 @@ answer for \fB\fCtest.\fR depending on client's IP address. It returns ...
|
||||
}
|
||||
}
|
||||
|
||||
\&. {
|
||||
view v6\_example1 {
|
||||
expr incidr(client\_ip(), '2001:0DB8::/32')
|
||||
}
|
||||
hosts {
|
||||
2001:0DB8::1 test
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
\&. {
|
||||
hosts {
|
||||
3.3.3.3 test
|
||||
@ -120,10 +132,10 @@ Note that the regex pattern is enclosed in single quotes, and backslashes are es
|
||||
|
||||
.SH "EXPRESSIONS"
|
||||
.PP
|
||||
To evaluate expressions, \fIview\fP uses the expr-lang/expr package (https://github.com/expr-lang/expr
|
||||
\[la]https://github.com/expr-lang/expr\[ra]).
|
||||
To evaluate expressions, \fIview\fP uses the expr-lang/expr package ( https://github.com/expr-lang/expr
|
||||
\[la]https://github.com/expr-lang/expr\[ra] ).
|
||||
For example, an expression could look like:
|
||||
\fB\fC(type() == 'A' && name() == 'example.com') || client_ip() == '1.2.3.4'\fR.
|
||||
\fB\fC(type() == 'A' && name() == 'example.com.') || client_ip() == '1.2.3.4'\fR.
|
||||
|
||||
.PP
|
||||
All expressions should be written to evaluate to a boolean value.
|
||||
@ -149,7 +161,7 @@ functions defined below.
|
||||
.IP \(bu 4
|
||||
\fB\fCid() int\fR: query ID
|
||||
.IP \(bu 4
|
||||
\fB\fCname() string\fR: name of the request (the domain name requested)
|
||||
\fB\fCname() string\fR: name of the request (the domain name requested ending with a dot): \fB\fCexample.com.\fR
|
||||
.IP \(bu 4
|
||||
\fB\fCopcode() int\fR: query OPCODE
|
||||
.IP \(bu 4
|
||||
@ -159,7 +171,7 @@ functions defined below.
|
||||
.IP \(bu 4
|
||||
\fB\fCserver_ip() string\fR: server's IP address; for IPv6 addresses these are enclosed in brackets: \fB\fC[::1]\fR
|
||||
.IP \(bu 4
|
||||
\fB\fCserver_port() string\fR : client's port
|
||||
\fB\fCserver_port() string\fR : server's port
|
||||
.IP \(bu 4
|
||||
\fB\fCsize() int\fR: request size in bytes
|
||||
.IP \(bu 4
|
||||
|
@ -31,6 +31,7 @@ Implement CIDR based split DNS routing. This will return a different
|
||||
answer for `test.` depending on client's IP address. It returns ...
|
||||
* `test. 3600 IN A 1.1.1.1`, for queries with a source address in 127.0.0.0/24
|
||||
* `test. 3600 IN A 2.2.2.2`, for queries with a source address in 192.168.0.0/16
|
||||
* `test. 3600 IN AAAA 2001:0DB8::1`, for queries with a source address in 2001:0DB8::/32
|
||||
* `test. 3600 IN A 3.3.3.3`, for all others
|
||||
|
||||
```
|
||||
@ -52,6 +53,17 @@ answer for `test.` depending on client's IP address. It returns ...
|
||||
}
|
||||
}
|
||||
|
||||
. {
|
||||
view v6_example1 {
|
||||
expr incidr(client_ip(), '2001:0DB8::/32')
|
||||
}
|
||||
hosts {
|
||||
2001:0DB8::1 test
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
. {
|
||||
hosts {
|
||||
3.3.3.3 test
|
||||
|
Loading…
Reference in New Issue
Block a user