CoreDNS:查询与响应的灵活操控
1. CoreDNS 操控能力概述
CoreDNS 赋予了用户对请求在插件链中的处理过程以及客户端响应的高度控制权,这使得用户能够根据特定环境和用例来定制 DNS 行为。例如,可使用 template 插件轻松生成特定区域内的标准名称,还能利用 rewrite 插件实现流量的透明重定向。
2. template 插件
template 插件能够仅基于请求来构造答案,常见用例是为 PTR 查询创建答案,而无需在区域文件中逐一定义。
2.1 示例配置
example.com:5300 in-addr.arpa:5300 {
# Match host-a-b-c-d.example.com A requests and return a.b.c.d
template IN A example.com {
match (^|[.])host-(?P<a>[0-9]*)-(?P<b>[0-9]*)-(?P<c>[0-9]*)-(?P<d>[0-9]*)[.]example[.]com[.]$
answer "{
{ .Name }} 60 IN A {
{ .Group.a }}.{
{ .Group.b }}.{
{ .Group.c }}.{
{ .Group.d }}"
fallthrough
超级会员免费看
订阅专栏 解锁全文
2759

被折叠的 条评论
为什么被折叠?



