CENTOS 7-可以 ping 通 IP,但不能 ping 通相关主机名

CENTOS 7-可以 ping 通 IP,但不能 ping 通相关主机名

到目前为止,我搜索并尝试了论坛中的所有建议,但仍然有这个问题。我的小型 Linux 机器和我的 Imac OSX 都位于同一个家用路由器后面。我可以从 OSX 机器终端 ping 我的域名 pa0esh.com,但不能从 Linux 机器终端 ping 通。但两台机器上的浏览器都可以显示我的主页。现在,如果我用谷歌尝试这个,它适用于 ping 和主机名。

测试结果如下:

root@adsb:~# ping 5.2.72.156
PING 5.2.72.156 (5.2.72.156) 56(84) bytes of data.
64 bytes from 5.2.72.156: icmp_seq=2 ttl=55 time=17.0 ms
64 bytes from 5.2.72.156: icmp_seq=3 ttl=55 time=14.6 ms
64 bytes from 5.2.72.156: icmp_seq=4 ttl=55 time=11.5 ms
64 bytes from 5.2.72.156: icmp_seq=5 ttl=55 time=18.1 ms
^C
--- 5.2.72.156 ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4026ms
rtt min/avg/max/mdev = 11.533/15.352/18.166/2.537 ms
root@adsb:~# ping www.pa0esh.com
PING www.pa0esh.com(friendlygolf.nl (2a04:52c0:101:198::250)) 56 data bytes
^C
--- www.pa0esh.com ping statistics ---
20 packets transmitted, 0 received, 100% packet loss, time 19437ms

root@adsb:~# dig www.pa0esh.com

; <<>> DiG 9.10.3-P4-Debian <<>> www.pa0esh.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23470
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
www.pa0esh.com.     300 IN  A   5.2.72.156

;; Query time: 39 msec
;; SERVER: 89.101.251.228#53(89.101.251.228)
;; WHEN: Wed Mar 31 14:35:50 CEST 2021
;; MSG SIZE  rcvd: 59

root@adsb:~# 

这是我的 resolv.com


root@adsb:~# cat /etc/resolv.conf
# Generated by NetworkManager
search home
nameserver 89.101.251.228       // ziggo dns server
nameserver 89.101.251.229       // ziggo dns server
nameserver 2001:b88:1002::10    // ziggo dns server
root@adsb:~# 

这是我的 nsswitch.conf

root@adsb:~# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal dns myhostname
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis
root@adsb:~# 

最后是 ipconfig -a 的输出。我使用以太网 enp3s0,但 wifi wlp1s0:有同样的问题

root@adsb:~# ifconfig -a
enp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:01:80:79:c9:25  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.178.106  netmask 255.255.255.0  broadcast 192.168.178.255
        inet6 fe80::201:80ff:fe79:c924  prefixlen 64  scopeid 0x20<link>
        inet6 2001:1c06:18cc:c100:3443:20dd:9eb:be93  prefixlen 64  scopeid 0x0<global>
        inet6 2001:1c06:18cc:c100:cc20:2a73:b930:894d  prefixlen 64  scopeid 0x0<global>
        inet6 2001:1c06:18cc:c100:201:80ff:fe79:c924  prefixlen 64  scopeid 0x0<global>
        ether 00:01:80:79:c9:24  txqueuelen 1000  (Ethernet)
        RX packets 57446  bytes 6316205 (6.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47443  bytes 6693494 (6.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 134611  bytes 39659391 (37.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 134611  bytes 39659391 (37.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.178.160  netmask 255.255.255.0  broadcast 192.168.178.255
        inet6 2001:1c06:18cc:c100:c612:f2c5:560a:6f26  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::bf89:67f7:29d0:2f0b  prefixlen 64  scopeid 0x20<link>
        ether 70:1a:04:fd:f8:d3  txqueuelen 1000  (Ethernet)
        RX packets 19957  bytes 2716508 (2.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 310  bytes 44166 (43.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@adsb:~# 

这里发生了什么事?

感谢任何能给我指明正确方向的人......

答案1

如果你这样做$ host pa0esh.com,你会看到有一个 IPv4 地址和一个 IPv6 地址。使用 dig 你可以执行以下操作$ ANY

$ dig  www.pa0esh.com ANY

; <<>> DiG 9.16.6-Ubuntu <<>> www.pa0esh.com ANY
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51046
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.pa0esh.com.                        IN      ANY

;; ANSWER SECTION:
www.pa0esh.com.         300     IN      AAAA    2a04:52c0:101:198::250
www.pa0esh.com.         300     IN      A       5.2.72.156

;; Query time: 131 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: wo mrt 31 15:06:00 CEST 2021
;; MSG SIZE  rcvd: 87

ping命令将默认使用 IPv6 地址。您可以使用以下标志检查 IPv4 是否正常工作-4

ping -4 www.pa0esh.com
PING  (5.2.72.156) 56(84) bytes of data.
64 bytes from friendlygolf.nl (5.2.72.156): icmp_seq=1 ttl=56 time=6.46 ms
64 bytes from friendlygolf.nl (5.2.72.156): icmp_seq=2 ttl=56 time=6.35 ms
64 bytes from friendlygolf.nl (5.2.72.156): icmp_seq=3 ttl=56 time=6.95 ms
^C
---  ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 6.354/6.587/6.951/0.260 ms

相关内容