ehdonhon has asked for the wisdom of the Perl Monks concerning the following question:

I'm having trouble with Net::Ping, I was wondering if I'm doing something wrong, or if it is a bug?

I have an IP that is definately pingable (real address has been masked for privacy):

root@myserver# ping 1.2.3.4 PING 1.2.3.4 (1.2.3.4): 56 data bytes 64 bytes from 1.2.3.4: icmp_seq=0 ttl=255 time=0.547 ms 64 bytes from 1.2.3.4: icmp_seq=1 ttl=255 time=0.435 ms ^C --- 1.2.3.4 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 0.435/0.491/0.547/0.056 ms

But, whenever I test the same IP address in a perl script with Net::Ping, it no longer pings. I've tested this with a couple hundred ips all within the same broadcast block as the server I'm testing from and have found intermittent results. That is, some IPs do ping, and some do not. From what I can tell, adjusting the timeout value does not seem to change anything either.

root@myserver# perl5 use Net::Ping; $p = new Net::Ping( "icmp" ); print "Pong\n" if ( $p->ping( '1.2.3.4', 5 )); root@myserver#

Replies are listed 'Best First'.
(tye)Re: Net::Ping doesn't seem to work.
by tye (Sage) on Jul 09, 2001 at 20:59 UTC

    See Net::Ping, the mini series for lots of information on this.

    In this case, I think you are using UDP pings (which lots of machines don't respond to) and the "ping" command is using ICMP pings which nearly all machines respond to.

            - tye (but my friends call me "Tye")