惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
T
Tenable Blog
Webroot Blog
Webroot Blog
L
Lohrmann on Cybersecurity
S
Securelist
S
Schneier on Security
NISL@THU
NISL@THU
Know Your Adversary
Know Your Adversary
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 热门话题
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Privacy International News Feed
H
Hacker News: Front Page
N
Netflix TechBlog - Medium
M
MIT News - Artificial intelligence
博客园 - Franky
PCI Perspectives
PCI Perspectives
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Azure Blog
Microsoft Azure Blog
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
P
Proofpoint News Feed
S
Security Affairs
WordPress大学
WordPress大学
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
小众软件
小众软件
F
Full Disclosure
博客园 - 叶小钗
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
The Blog of Author Tim Ferriss
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
Security Latest
Security Latest
P
Proofpoint News Feed
月光博客
月光博客
T
Tailwind CSS Blog
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google Online Security Blog
Google Online Security Blog
T
Threat Research - Cisco Blogs
Help Net Security
Help Net Security
Project Zero
Project Zero

plugin on CoreDNS: DNS and Service Discovery

kubernetes log proxyproto rewrite forward clouddns errors grpc_server https https3 template docker auto geoip multisocket nomad dnstap import ready etcd header loadbalance bind grpc file prometheus quic timeouts kubeforward JSON gslb autopath dnssec root tls fanout k8s_cache bufsize k8s_external reload gathersrv meship meshname multicluster acl cache recursor health trace tsig k8s_event redis route53 dns64 transfer finalize kubenodes ebpf rrl secondary mysql warnlist loop minimal sign azure git local any cancel debug erratic metadata nsid pprof alternate k8s_dns_chaos records k8s_gateway hosts netbox mdns wgsd alias chaos whoami lighthouse ens idetcd gravwell amazondns kubernetai redisc unbound on dump pdsql ipin demo example
view
2025-10-13 · via plugin on CoreDNS: DNS and Service Discovery

Description

view defines an expression that must evaluate to true for a DNS request to be routed to the server block. This enables advanced server block routing functions such as split dns.

Syntax

view NAME {
  expr EXPRESSION
}
  • view NAME - The name of the view used by metrics and exported as metadata for requests that match the view’s expression
  • expr EXPRESSION - CoreDNS will only route incoming queries to the enclosing server block if the EXPRESSION evaluates to true. See the Expressions section for available variables and functions. If multiple instances of view are defined, all EXPRESSION must evaluate to true for CoreDNS will only route incoming queries to the enclosing server block.

For expression syntax and examples, see the Expressions and Examples sections.

Examples

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
. {
  view example1 {
    expr incidr(client_ip(), '127.0.0.0/24')
  }
  hosts {
    1.1.1.1 test
  }
}

. {
  view example2 {
    expr incidr(client_ip(), '192.168.0.0/16')
  }
  hosts {
    2.2.2.2 test
  }
}

. {
  view v6_example1 {
    expr incidr(client_ip(), '2001:0DB8::/32')
  }
  hosts {
    2001:0DB8::1 test
  }
}

}

. {
  hosts {
    3.3.3.3 test
  }
}

Send all A and AAAA requests to 10.0.0.6, and all other requests to 10.0.0.1.

. {
  view example {
    expr type() in ['A', 'AAAA']
  }
  forward . 10.0.0.6
}

. {
  forward . 10.0.0.1
}

Send all requests for abc.*.example.com (where * can be any number of labels), to 10.0.0.2, and all other requests to 10.0.0.1. Note that the regex pattern is enclosed in single quotes, and backslashes are escaped with backslashes.

. {
  view example {
    expr name() matches '^abc\\..*\\.example\\.com\\.$'
  }
  forward . 10.0.0.2
}

. {
  forward . 10.0.0.1
}

Expressions

To evaluate expressions, view uses the expr-lang/expr package ( https://github.com/expr-lang/expr ). For example, an expression could look like: (type() == 'A' && name() == 'example.com.') || client_ip() == '1.2.3.4'.

All expressions should be written to evaluate to a boolean value.

See https://github.com/expr-lang/expr/blob/master/docs/language-definition.md as a detailed reference for valid syntax.

Available Expression Functions

In the context of the view plugin, expressions can reference DNS query information by using utility functions defined below.

DNS Query Functions

  • bufsize() int: the EDNS0 buffer size advertised in the query
  • class() string: class of the request (IN, CH, …)
  • client_ip() string: client’s IP address, for IPv6 addresses these are enclosed in brackets: [::1]
  • do() bool: the EDNS0 DO (DNSSEC OK) bit set in the query
  • id() int: query ID
  • name() string: name of the request (the domain name requested ending with a dot): example.com.
  • opcode() int: query OPCODE
  • port() string: client’s port
  • proto() string: protocol used (tcp or udp)
  • server_ip() string: server’s IP address; for IPv6 addresses these are enclosed in brackets: [::1]
  • server_port() string : server’s port
  • size() int: request size in bytes
  • type() string: type of the request (A, AAAA, TXT, …)

Utility Functions

  • incidr(ip string, cidr string) bool: returns true if ip is within cidr
  • metadata(label string) - returns the value for the metadata matching label

The view plugin will publish the following metadata, if the metadata plugin is also enabled:

  • view/name: the name of the view handling the current request