如何绕过缓存服务器,直接从 Linux 和 Mac OS X 命令行查询权威 DNS 名称服务器?
当想要立即验证权威服务器上新创建的 DNS 主机名,而不想等待缓存的 DNS 服务器“更新”/过期 TTL 时,这很有用。
答案1
使用dig
,您可以自动执行此操作。
$ dig +trace www.google.com
; <<>> DiG 9.8.3-P1 <<>> +trace www.google.com
;; global options: +cmd
. 376983 IN NS c.root-servers.net.
. 376983 IN NS d.root-servers.net.
. 376983 IN NS l.root-servers.net.
. 376983 IN NS j.root-servers.net.
. 376983 IN NS f.root-servers.net.
. 376983 IN NS b.root-servers.net.
. 376983 IN NS i.root-servers.net.
. 376983 IN NS g.root-servers.net.
. 376983 IN NS a.root-servers.net.
. 376983 IN NS e.root-servers.net.
. 376983 IN NS k.root-servers.net.
. 376983 IN NS m.root-servers.net.
. 376983 IN NS h.root-servers.net.
;; Received 512 bytes from 172.16.0.1#53(172.16.0.1) in 2424 ms
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
;; Received 504 bytes from 192.36.148.17#53(192.36.148.17) in 4357 ms
google.com. 172800 IN NS ns2.google.com.
google.com. 172800 IN NS ns1.google.com.
google.com. 172800 IN NS ns3.google.com.
google.com. 172800 IN NS ns4.google.com.
;; Received 168 bytes from 192.33.14.30#53(192.33.14.30) in 503 ms
www.google.com. 300 IN A 173.194.127.240
www.google.com. 300 IN A 173.194.127.244
www.google.com. 300 IN A 173.194.127.242
www.google.com. 300 IN A 173.194.127.241
www.google.com. 300 IN A 173.194.127.243
;; Received 112 bytes from 216.239.32.10#53(216.239.32.10) in 164 ms
答案2
$ host -t ns <domain>
提供权威的服务器名称。然后运行:
$ host <hostname> <authoritative_DNS_name>
查看来自 authority_DNS_name 服务器的 DNS 转换。
以下是 Mac OS X 的示例。相同的命令也适用于 Ubuntu 12.04.2 LTS。
desktop5-macos Jan 04 13:54:29 ~$ host -t ns google.com
google.com name server ns3.google.com.
google.com name server ns1.google.com.
google.com name server ns2.google.com.
google.com name server ns4.google.com.
desktop5-macos Jan 04 13:54:31 ~$ host google.com ns1.google.com
Using domain server:
Name: ns1.google.com
Address: 216.239.32.10#53
Aliases:
google.com has address 74.125.225.3
google.com has address 74.125.225.2
google.com has address 74.125.225.5
google.com has address 74.125.225.0
google.com has address 74.125.225.4
google.com has address 74.125.225.9
google.com has address 74.125.225.6
google.com has address 74.125.225.8
google.com has address 74.125.225.7
google.com has address 74.125.225.1
google.com has address 74.125.225.14
google.com has IPv6 address 2607:f8b0:4009:806::1005
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.
desktop5-macos Jan 04 13:54:35 ~$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.7.4
BuildVersion: 11E53
desktop5-macos Jan 04 13:54:38 ~$