据我所知,这个问题与 PowerDNS 无关。服务器在最新版本的 Amazon Linux 上pdns-static-3.0.1-1.i386.rpm
运行两个软件包。pdns-recursor-3.3-1.i386.rpm
亚马逊 ec2 负载均衡器被分配了一个包含多个主机的 CNAME。以下是实际行为的示例。请注意主机如何始终保持相同的顺序。
[root@localhost ~]# host cache.domain.com
cache.domain.com is an alias for xxxxx.us-east-1.elb.amazonaws.com.
xxxxx.us-east-1.elb.amazonaws.com has address aaa.aaa.aaa.aaa
xxxxx.us-east-1.elb.amazonaws.com has address bbb.bbb.bbb.bbb
[root@localhost ~]# host cache.domain.com
cache.domain.com is an alias for xxxxx.us-east-1.elb.amazonaws.com.
xxxxx.us-east-1.elb.amazonaws.com has address aaa.aaa.aaa.aaa
xxxxx.us-east-1.elb.amazonaws.com has address bbb.bbb.bbb.bbb
[root@localhost ~]# host cache.domain.com
cache.domain.com is an alias for xxxxx.us-east-1.elb.amazonaws.com.
xxxxx.us-east-1.elb.amazonaws.com has address aaa.aaa.aaa.aaa
xxxxx.us-east-1.elb.amazonaws.com has address bbb.bbb.bbb.bbb
预期行为是主机循环
[root@localhost ~]# host cache.domain.com
cache.domain.com is an alias for xxxxx.us-east-1.elb.amazonaws.com.
xxxxx.us-east-1.elb.amazonaws.com has address aaa.aaa.aaa.aaa
xxxxx.us-east-1.elb.amazonaws.com has address bbb.bbb.bbb.bbb
[root@localhost ~]# host cache.domain.com
cache.domain.com is an alias for xxxxx.us-east-1.elb.amazonaws.com.
xxxxx.us-east-1.elb.amazonaws.com has address bbb.bbb.bbb.bbb
xxxxx.us-east-1.elb.amazonaws.com has address aaa.aaa.aaa.aaa
[root@localhost ~]# host cache.domain.com
cache.domain.com is an alias for xxxxx.us-east-1.elb.amazonaws.com.
xxxxx.us-east-1.elb.amazonaws.com has address aaa.aaa.aaa.aaa
xxxxx.us-east-1.elb.amazonaws.com has address bbb.bbb.bbb.bbb
地址最终会交换,但似乎在 30 分钟缓存计时器上更改记录的 TTL 似乎不会影响任何内容。解析器似乎有响应的缓存。这对我的应用程序产生了不利影响,因为所有负载仅被发送到负载平衡器之一(可用区),因此如果我在两个区域中有服务器,那么一次只有一个区域处于负载状态。
你知道我如何解决这个问题,以便每次解析主机时地址的顺序都是交替的。
数字输出
; DiG 9.7.6-P1-RedHat-9.7.6-1.P1.18.amzn1 cache.domain.com ;; 全局选项:+cmd ;; 得到答案: ;; 标题操作码:QUERY,状态:NOERROR,ID:54610 ;; 标志:qr rd ra;查询:1,答案:3,权限:0,附加:0 ;; 问题部分: 缓存.domain.com。在一个 ;; 答案部分: 缓存.domain.com。100 CNAME xxxxx.us-east-1.elb.amazonaws.com。 xxxxx.us-east-1.elb.amazonaws.com。3 输入 aaa.aaa.aaa.aaa xxxxx.us-east-1.elb.amazonaws.com。3 在一个 bbb.bbb.bbb.bbb ;; 查询时间:0 毫秒 ;; 服务器:ccc.ccc.ccc.ccc#53(ccc.ccc.ccc.ccc) ;; 时间:2012 年 7 月 2 日星期一 15:09:27 ;; MSG SIZE 收件人:130
递归配置
允许-来自=0.0.0.0/0 不要查询= 本地地址=127.0.0.1 local-port=530 # 端口应该改成530因为和dns服务器运行在同一个端口不好 安静=是 setgid=pdns setuid=pdns 禁用-packetcache= packetcache-ttl=0 forward-zones=domain.local=LOCALIP,domain.cloud=LOCALIP #将我们关心的两个区域转发回本地dns服务器 forward-zones-recurse=amazonaws.com=172.16.0.23,compute-1.internal=172.16.0.23 # 将亚马逊域的查询转发到亚马逊的解析器
解决方案
将以下行添加到 recursor.conf
disable-packetcache=
packetcache-ttl=0
将以下行添加到 pdns.conf
recursive-cache-ttl=0