ping/curl无法解析speedport.ip且不发送DNS查询,但dig/host可正常解析的问题求助
ping/curl无法解析speedport.ip且不发送DNS查询,但dig/host可正常解析的问题求助
各位好,我遇到一个很奇怪的DNS解析问题,想请大家帮忙看看:
我的网络拓扑如下:
┌────────────┐ ┌────────────┐ ┌────────────┐ │Notebook │ │ FW/DNS │ │ISP ROUTER │ │ arch linux ├─────►│mapping: ├───►│192.168.2.1 │ │ │ │speedport.ip│ │speedport.ip│ │ │ │192.168.2.1 │ │ │ └────────────┘ └────────────┘ └────────────┘
防火墙(FW)作为我Arch Linux笔记本的DNS服务器,我在FW上配置了一条DNS映射:speedport.ip -> 192.168.2.1
已验证的正常情况
用dig speedport.ip可以正常解析到对应IP,输出结果如下:
# dig speedport.ip ; <<>> DiG 9.18.15 <<>> speedport.ip ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17333 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ;; QUESTION SECTION: ;speedport.ip. IN A ;; ANSWER SECTION: speedport.ip. 3600 IN A 192.168.2.1 ;; Query time: 0 msec ;; SERVER: 192.168.3.2#53(192.168.3.2) (UDP) ;; WHEN: Fri Oct 27 07:53:46 UTC 2023 ;; MSG SIZE rcvd: 57
同时用tcpdump udp port 53抓包,也能看到正常的DNS查询与响应包:
# tcpdump udp port 53 listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes 08:03:43.974915 IP notebook.mydomain.xyz.46555 > fw.mydomain.xyz.domain: 26+ [1au] A? speedport.ip. (53) 08:03:43.975175 IP fw.mydomain.xyz.domain > notebook.mydomain.xyz.46555: 26* 1/0/1 A 192.168.2.1 (57)
异常现象
但当我使用curl或ping访问speedport.ip时,却直接提示无法解析主机,而且tcpdump中完全看不到对应的DNS查询请求:
[root@notebook]# curl http://speedport.ip curl: (6) Could not resolve host: speedport.ip [root@notebook]# ping speedport.ip ping: speedport.ip: Name or service not known
我尝试把speedport.ip 192.168.2.1添加到笔记本的/etc/hosts文件中,此时curl和ping就能正常工作了。
补充系统配置
/etc/nsswitch.conf内容:
# Name Service Switch configuration file. # See nsswitch.conf(5) for details. passwd: files systemd group: files [SUCCESS=merge] systemd shadow: files systemd gshadow: files systemd publickey: files hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns networks: files protocols: files services: files ethers: files rpc: files netgroup: files
/etc/resolv.conf内容:
search mydomain.xyz nameserver 192.168.3.2
resolvectl输出:
Global Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: foreign Current DNS Server: 192.168.3.2 DNS Servers: 192.168.3.2 Fallback DNS Servers: 1.1.1.1#cloudflare-dns.com 9.9.9.9#dns.quad9.net 8.8.8.8#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2620:fe::9#dns.quad9.net 2001:4860:4860::8888#dns.google DNS Domain: mydomain.xyz Link 2 (eth0) Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 192.168.3.2 DNS Servers: 192.168.3.2
现在我很困惑:为什么dig能正常触发DNS查询并得到结果,但curl和ping却完全不发送DNS请求,直接提示无法解析?有没有大佬能帮忙分析下原因?
备注:内容来源于stack exchange,提问作者enthus1ast
相关产品推荐
相关产品推荐

