Dns
為什麼 DNS 伺服器只為自己解析 DNS 查詢?
我自己的 DNS 伺服器有問題,它執行 dnsmasq。
這是
/etc/dnsmasq.conf
(只有未註釋的行):# If you don't want dnsmasq to read /etc/resolv.conf or any other # file, getting its servers from this file instead (see below), then # uncomment this. no-resolv # Add other name servers here, with domain specs if they are for # non-public domains. #server=/localnet/192.168.0.1 server=151.100.4.2 server=151.100.4.13
當我嘗試從伺服器解析查詢時,一切正常:
$ nslookup google.com Server: 127.0.0.1 Address: 127.0.0.1#53 Non-authorative answer: Name: google.com Address: 142.250.184.78 Name: google.com Address: 2a00:1450:4002:405::200e
但是,當我從網路中的另一台主機嘗試時
ping google.com
,DNS 不會回複查詢,即使它收到了查詢。這是tcpdump
DNS 伺服器上的輸出:$ sudo tcpdump -n host 100.100.2.100 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 11:35:43.517755 IP 100.100.2.100.54996 > 100.100.1.2.53: 12795+ A? google.com. (28) 11:35:43.517844 IP 100.100.2.100.54996 > 100.100.1.2.53: 51213+ AAAA? google.com. (28) 11:35:48.522750 IP 100.100.2.100.54996 > 100.100.1.2.53: 12795+ A? google.com. (28) 11:35:48.522818 IP 100.100.2.100.54996 > 100.100.1.2.53: 51213+ AAAA? google.com. (28) ^C 4 packets captured 4 packets received by filter 0 packets dropped by kernel
另一台主機能夠訪問網路:果然,它 ping 8.8.8.8 或任何其他 IP。問題僅在於名稱解析。
我上網尋找有同樣問題的人,但我沒有找到任何東西。我真的不知道如何嘗試解決這個問題,因為 DNS 似乎工作並且它接收查詢,它只是不回复它們。
因為
dnsmasq
可能只在地址 127.0.0.1 上回答查詢(僅限同一台電腦)。閱讀:-i,–interface=
以 root 身份檢查
netstat -4panu
以查找 dnsmasq 正在偵聽的埠/iinterfaces。