为什么 dig 到路由器在 DNS 53 端口上?

4pi*_*ie0 0 dns ubuntu-12.10

192.168.1.1 是我的路由器 NetGear。它有 8.8.8.8 和 8.8.4.4 设置为 DNS。从窗口:

nslookup google.com 192.168.1.1  // works OK
Run Code Online (Sandbox Code Playgroud)

来自 ubuntu:

me@ubuntu:/etc/mail# dig @192.168.1.1 google.com +tcp
;; Connection to 192.168.1.1#53(192.168.1.1) for google.com failed: connection refused.
Run Code Online (Sandbox Code Playgroud)

我认为这不应该在端口 53 上进行,对吗?如果是,dig将我的 DNS 查询转换为在错误端口上询问 NetGear的原因是什么?

我无法查询 8.8.8.8:

dig @8.8.8.8 google.com

; <<>> DiG 9.9.2-P2 <<>> @8.8.8.8 google.com
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached
root@ubuntuamd:/etc/mail# dig @8.8.8.8 google.com +tcp
Run Code Online (Sandbox Code Playgroud)

但是可以使用+tcp:

dig @8.8.8.8 google.com +tcp

; <<>> DiG 9.9.2-P2 <<>> @8.8.8.8 google.com +tcp
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59432
;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     88  IN  A   46.28.247.93
google.com.     88  IN  A   46.28.247.119
//etc

;; Query time: 33 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed May  8 00:20:06 2013
;; MSG SIZE  rcvd: 295
Run Code Online (Sandbox Code Playgroud)

最后这个:这里 127.0.1.1(dnsmasq 对吗?)回应:

 dig  google.com

; <<>> DiG 9.9.2-P2 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34747
;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.            IN  A

;; ANSWER SECTION:
google.com.     300 IN  A   208.117.224.29
//etc

;; Query time: 3 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Wed May  8 00:04:44 2013
;; MSG SIZE  rcvd: 284
Run Code Online (Sandbox Code Playgroud)

纳米工具:

me@ubuntu:/etc/mail# nm-tool | tail -n 8   IPv4 Settings:
    Address:         192.168.1.3
    Prefix:          24 (255.255.255.0)
    Gateway:         192.168.1.1

    DNS:             192.168.1.1
Run Code Online (Sandbox Code Playgroud)

Mic*_*ton 6

端口 53 确实是 DNS 服务器侦听请求的端口。

但是,默认情况下它是 UDP 端口 53,而 TCP 端口 53 不经常使用。

默认情况下,您的dignslookup命令使用 UDP,但在您的dig命令中,您指定将 TCP 与 一起使用+tcp,并且由于路由器仅侦听 UDP,因此请求失败。

要解决此问题,请通过+tcpdig命令中删除来使用 UDP 进行查询。