
我有一個運行 Arch 的 Rasberry Pi,我遇到了一些奇怪的解決行為。長話短說,dig
可以nslookup
解析主機名,,,,curl
不能。如果我新增一個主機,那麼該主機的一切正常。wget
pacman
/etc/hosts
以下是一些故障排除的輸出:
resolv.conf
存在並且可讀:$ ls -l /etc/resolv.conf -rw-r--r-- 1 root root 19 Apr 28 10:45 /etc/resolv.conf
我有一個名稱伺服器:
$ cat /etc/resolv.conf nameserver 8.8.8.8
nslookup
作品:$ nslookup google.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: google.com Address: 92.87.11.30 Name: google.com Address: 92.87.11.54 Name: google.com Address: 92.87.11.49 Name: google.com Address: 92.87.11.45 ...
dig
作品:$ dig google.com ; <<>> DiG 9.11.0-P3 <<>> google.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20686 ;; 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. 299 IN A 92.87.175.49 google.com. 299 IN A 92.87.175.50 google.com. 299 IN A 92.87.175.48 google.com. 299 IN A 92.87.175.44 google.com. 299 IN A 92.87.175.42 google.com. 299 IN A 92.87.175.41 google.com. 299 IN A 92.87.175.51 google.com. 299 IN A 92.87.175.36 google.com. 299 IN A 92.87.175.39 google.com. 299 IN A 92.87.175.45 google.com. 299 IN A 92.87.175.37 google.com. 299 IN A 92.87.175.40 google.com. 299 IN A 92.87.175.38 google.com. 299 IN A 92.87.175.47 google.com. 299 IN A 92.87.175.43 google.com. 299 IN A 92.87.175.46 ;; Query time: 40 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Fri Apr 28 11:37:32 EEST 2017 ;; MSG SIZE rcvd: 295
我可以使用
ping
其中一個 IP:$ ping 92.87.175.49 PING 92.87.175.49 (92.87.175.49) 56(84) bytes of data. 64 bytes from 92.87.175.49: icmp_seq=1 ttl=54 time=3.75 ms 64 bytes from 92.87.175.49: icmp_seq=2 ttl=54 time=3.71 ms --- 92.87.175.49 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 3.711/3.734/3.758/0.065 ms
wget
失敗:$ wget https://google.com --2017-04-28 11:39:31-- https://google.com/ Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt' Resolving google.com... failed: Name or service not known. wget: unable to resolve host address 'google.com'
curl
失敗:$ curl https://google.com curl: (6) Could not resolve host: google.com
我錯過了什麼?
編輯:
$ cat /etc/hosts
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
# End of file
$ cat /etc/nsswitch.conf
# Begin /etc/nsswitch.conf
passwd: compat mymachines systemd
group: compat mymachines systemd
shadow: compat
publickey: files
hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname
networks: files
protocols: files
services: files
ethers: files
rpc: files
netgroup: files
# End /etc/nsswitch.conf
看來是跟有什麼關係systemd-resolvd
。如果我停止它或resolve [!UNAVAIL=return]
從 中刪除/etc/nsswitch.conf
,則解析對每個應用程式都可以正常工作,如果我再次啟動它或/etc/nsswitch.conf
按原樣保留,則解析僅適用於nslookup
& dig
。
答案1
archlinuxarm 更新後我遇到了類似的問題:某些網站可以工作,但大多數網站不可用,而且 pacman 無法更新。就我而言,問題是系統解析器上的 dnssec。可以透過從控制台運行來檢測它:
resolvectl 查詢 archlinuxarm.org(或任何其他不可用的站點)
答案是:... DNSSEC 驗證失敗:無效
就我而言,幫助將 DNSSEC=false 新增至 /etc/systemd/resolved.conf 並重新啟動