主机命令按顺序运行时返回两个不同的 IP 地址

主机命令按顺序运行时返回两个不同的 IP 地址

这是一个有趣的问题:

~ $ host gitlab.myorg.com
gitlab.myorg.com is an alias for aln7git01.myorg.com.
aln7git01.myorg.com has address 172.30.9.197

~ $ host gitlab.myorg.com
gitlab.myorg.com has address 172.30.8.24
gitlab.myorg.com is an alias for aln7git01.myorg.com.

我相继几秒运行了这两个命令。

aln7git01.myorg.com 的命令host也具有相同的行为。以下digaln7git01.myorg.com

~ $ dig A aln7git01.myorg.com

; <<>> DiG 9.8.3-P1 <<>> A aln7git01.myorg.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5438
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;aln7git01.myorg.com. IN    A

;; ANSWER SECTION: 
aln7git01.myorg.com. 3596 IN A  172.30.8.24

;; AUTHORITY SECTION:
myorg.com.  129 IN  NS  mtd-ns1.myorg.com.
myorg.com.  129 IN  NS  mtd-ns2.myorg.com.

;; ADDITIONAL SECTION:
mtd-ns1.myorg.com.  86400   IN  A   207.18.164.29
mtd-ns2.myorg.com.  86400   IN  A   207.18.164.30

;; Query time: 48 msec
;; SERVER: 64.102.6.247#53(64.102.6.247)
;; WHEN: Tue Jun  9 05:27:45 2015
;; MSG SIZE  rcvd: 148

~ $ dig A aln7git01.mtd.myorg.com

; <<>> DiG 9.8.3-P1 <<>> A aln7git01.mtd.myorg.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61048
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION
;aln7git01.mtd.myorg.com. IN    A

;; ANSWER SECTION:
aln7git01.mtd.myorg.com. 2727 IN A  172.30.9.197

;; AUTHORITY SECTION
mtd.myorg.com.  86400   IN  NS  mtd-ns1.myorg.com.
mtd.myorg.com.  86400   IN  NS  mtd-ns2.myorg.com.

;; ADDITIONAL SECTION:
mtd-ns1.myorg.com.  86400   IN  A   207.18.164.29
mtd-ns2.myorg.com.  86400   IN  A   207.18.164.30

;; Query time: 46 msec
;; SERVER: 64.102.6.247#53(64.102.6.247)
;; WHEN: Tue Jun  9 05:27:45 2015
;; MSG SIZE  rcvd: 148

设置如下:

1) A bind server with a zone file for myorg.com
2) Two A records with 172.30.8.24 for gitlab and aln7git01
3) Two name servers for myorg.com on two other hosts

答案1

您的问题部分在于您的调试方法。

您正在使用仅请求 -records 的命令行选项运行dig命令。当您得到奇怪的结果时,您需要使用无选项或选项,这样您就不会限制输出:AAany

 dig any gitlab.myorg.com.

我的假设是,这样做会显示你有两个 DNS 记录,A gitlab.myorg.com 的记录CNAME

这将导致循环效应,一个请求获取 A 记录,下一个请求获取 CNAME 记录。解决方案是从您的区域中删除不正确的条目。

相关内容