4

I am using Cent OS 6.4 and it is in a official lab.

ping google.com gives the below output and hangs:

[root@LAB1 ~]# ping google.com  
PING google.com (74.125.236.195) 56(84) bytes of data.

ping 8.8.8.8 also yields the same result. I am able to access internet from browser(Mozilla). Is there a problem with the network settings or configuration?

Below is the output from traceroute - n 8.8.8.8

[root@LAB1 ~]# traceroute -n 8.8.8.8 traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 *^Z

Below is the output from route -n if it helps

[root@LAB1 ~]# route -n  
Kernel IP routing table  
Destination Gateway Genmask Flags Metric Ref Use Iface  
192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0  
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0  

The main reason for me to try the above ping is to resolve an yum update command that fails to resolve the mirror sites...

As I am new to networking, I am not able to identify the issue. Any help here is much appreciated...

1
  • 2
    Try pinging your default gateway. If you can reach that then your PC/configuration is probably fine and something further on is blocking ICMP echo requests. – Hennes Nov 14 '13 at 6:49
4

Many corporate firewalls block ICMP - which is the protocol is used by ping utility.

Better solution for this is to try TCP connection to google.com:80.

Easiest way to check for basic internet connectivity in shell script is utility nc (it should be easily available on most Linux systems):

nc -w 3 -z google.com 80
echo $?

This means check if port 80 on google.com is open, and timeout after 3 seconds. If connection was successful, it will print 0, and if it failed, it will print 1.


If you want to check internet connectivity without checking DNS (which could be broken in itself), you can use Google's preferred DNS server 8.8.8.8, but the only port that it has open is 53 (aka domain):

nc -w 3 -z 8.8.8.8 53
echo $?

However, port 53 can be also blocked by your corporate firewall (not common, but possible). Ports 80 and 443, on other hand, are almost never firewalled.

4
  • Thanks mvp, but unfortunately, i dont have nc available here. But I understand that they have blocked ICMP which is why ping is not working. I have accepted your answer. But still I am stuck with the "yum update" not working. I will post a separate question for that. – Siva Nov 15 '13 at 15:21
  • In other words, you don't actually have Internet access. You have access to some subset of the Internet that apparently doesn't include ping. – David Schwartz Mar 18 '16 at 20:33
  • @DavidSchwartz: ping is never guaranteed. E.g. try ping microsoft.com - it will never work, as Microsoft blocks ICMP. – mvp Mar 18 '16 at 20:48
  • @mvp Not sure how that's relevant, but yeah. – David Schwartz Mar 18 '16 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.