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#

In reply to Net::Ping doesn't seem to work. by ehdonhon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.