1820540 Members
3254 Online
109626 Solutions
New Discussion юеВ

Re: Ping Error codes.

 
brian_31
Super Advisor

Ping Error codes.

Hi Team:

I tried to ping a host A which is currently down and IP address of that host can be resolved. Ping returns error code 2.

Then I pinged to a unknown host and IP address of that host cannot be resolved. Ping returns the same error 2 code for this scenario too.

What does this mean?

If anyone could tell the ping error codes and respective definitions that will be very helpful.

Thanks & Regards
Brian.

11 REPLIES 11
James R. Ferguson
Acclaimed Contributor

Re: Ping Error codes.

Hi Brian:

Directly from the 'ping' man pages:

1 On failure such as unknown host, illegal packet size, etc.

2 On a unreachable host or network.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: Ping Error codes.

...and, of course, 0 = success ...

...JRF...
brian_31
Super Advisor

Re: Ping Error codes.

Hi:

Why am i getting error code 2 when i was able to ping the first time?

Regards
Brian.
Sridhar Bhaskarla
Honored Contributor

Re: Ping Error codes.

Hi Brian,

I have not seen ping resulting error code 2. Can you paste your exact error?.

May be your system is running out of some resources like swap space etc., Do a dmesg and look for the errors.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
brian_31
Super Advisor

Re: Ping Error codes.

Hi:

Also Pl. explain why we have /etc/ping and /usr/sbin/ping and i think the /etc/ping has a sticky bit set????

Thanks & Regards
Brian.
James R. Ferguson
Acclaimed Contributor

Re: Ping Error codes.

Hi (again) Brian:

'/etc/ping' is a transition link to '/usr/sbin/ping' for backwards compatability. The 'setuid' bit is set on /usr/sbin/ping.

Regards!

...JRF...
brian_31
Super Advisor

Re: Ping Error codes.

Hi Sridhar:

1.I tried to ping a host A which is currently down and IP address of that host can be resolved. Ping returns error code 2.

2.Then I pinged to a unknown host and IP address of that host cannot be resolved. Ping returns the same error 2 code for this scenario too.

Thanks
Brian.

Sridhar Bhaskarla
Honored Contributor

Re: Ping Error codes.

Brian,

How are you getting the error code?. Are you trying to get it by doing a "echo $?" or it is giving out an error?.

Are you trying as a superuser or a normal user?.

Did you look at your dmesg output?

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Jeff Schussele
Honored Contributor

Re: Ping Error codes.

Hi Brian,

Seems to me that if a host is down - that would certainly qualify as unreachable - hence code 2.
Just because hostname can be resolved has no impact - pings are by IP - specifically by the ICMP protocol.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
brian_31
Super Advisor

Re: Ping Error codes.

Hi Sridhar:

ping xxx.xyz.abc.com -n1;echo$?

for both the cases.

Thanks
Brian.
Sridhar Bhaskarla
Honored Contributor

Re: Ping Error codes.

ping exit codes have been changed on 11.0 from 10.20 and I believe yours is 10.20.

On 10.20, following are the codes as per the man page and I can verify them on my 10.20 system.

0 Success
1 On failure such as unknown host, illegal packet size, etc.
2 On a unreachable host or network.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try