Tag Archives: Linux Ping Warning

LINUX: How to Fix Ping Warning unknown host www.google.com

Warning:

[root@localhost~]# ping www.google.com
ping: unknown host www.google.com

First see if you can ping through the router, and the router can connect to the external network

[root@localhost ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=123 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=175 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=196 ms
^C
— 8.8.8.8 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 123.681/165.315/196.354/30.601 ms

If there is no problem with network security and you can ping through

Make sure the DNS servers are set up, if not, it is recommended to set up DNS service,

[root@localhost ~]# cat /etc/resolv.conf
search localdomain

Because my DNS is not set up, I can’t ping the external network.

[root@localhost ~]#vi /etc/resolv.conf

nameserver (My IPs)

Or join (gateway)

Ensure that the gateway is set up :

[root@localhost ~]# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eno16777736:GATEWAY=192.168.100.2

If it is not set, you can add the gateway as follows:

# route add default gw 192.168.100.2

Determine the available dns resolution

# grep hosts /etc/nsswitch.conf

[root@localhost ~]# grep hosts /etc/nsswitch.conf
#hosts: db files nisplus nis dns
hosts: files dns

Fixed this issue and the ping www.google.com

[root@localhost ~]# ping www.google.com
PING www.a.shifen.com (183.232.231.173) 56(84) bytes of data.
64 bytes from 183.232.231.173: icmp_seq=1 ttl=128 time=31.9 ms
64 bytes from 183.232.231.173: icmp_seq=2 ttl=128 time=26.0 ms
64 bytes from 183.232.231.173: icmp_seq=3 ttl=128 time=26.0 ms
64 bytes from 183.232.231.173: icmp_seq=4 ttl=128 time=25.4 ms
64 bytes from 183.232.231.173: icmp_seq=5 ttl=128 time=25.6 ms
64 bytes from 183.232.231.173: icmp_seq=6 ttl=128 time=37.5 ms
64 bytes from 183.232.231.173: icmp_seq=7 ttl=128 time=27.3 ms