SPUG: I must be missing something with Net::Ping

Mark Yocom myocom at microsoft.com
Mon Oct 8 19:53:03 CDT 2001


Maybe it's just me, but when I do 'perldoc Net::Ping', it says that the
default protocol is UDP, not ICMP.

Do you get the same results if you explicitly set the protocol used?

my $p = Net::Ping->new('icmp');

> -----Original Message-----
> From: Alyssa Harding [mailto:alyssa at atuin.net] 
> Sent: Monday, October 08, 2001 5:07 PM
> To: SPUG
> Subject: SPUG: I must be missing something with Net::Ping
> 
> 
> Hi List,
> 
> Maybe someone else can look at this and tell me I'm missing something 
> simple.  
> 
> I've got a script which runs on a server outside the firewall 
> and pings 
> certain servers.  i'm using Net::Ping to do the pinging but 
> I'm coming 
> up with wierd results.
> 
> use Net::Ping;
> 
> my $isp = '<ip address of isp router>';
> my $outside='www.yahoo.com';
> 
> my $p = Net::Ping->new();  # by default uses icmp protocol
> 
> if($p->ping($isp)) {
>   print "isp reached\n";
> } else {
>   print "isp not reached\n";
> }
> 
> if( $p->ping($outside)) {
>   print "outside reached\n";
> } else {
>   print "outside not reached\n";
> }
> 
> $p->close();
> 
> When I run the script I get the following output:
> isp reached
> outside not reached
> 
> In other words, I can ping our ISP's router but I can't ping 
> yahoo.com.
> So I tried on the command line (HPUX v10.20 seems to have the 
> same ping 
> as my Red Hat 7.1 box with different option flags - they are 
> functionally the same though):
> ping <isp's router>
> and got a response just fine - good.  I expected that. So I tried:
> ping www.yahoo.com
> and got a response just fine - hmmmm.  
> 
> Why won't the script do what the command line does when they are both 
> using the same protocol to do the same thing?  Traceroute shows the 
> first hop being to the ISP's router and then about 18 more 
> hops and #20 
> is yahoo.
> 
> Any ideas?
> 
> A.
> --
> Alyssa Harding
> ----------------------------------------------------------------
> "Why's it called Ming?" said the Archchancellor, on cue.
> The Bursar tapped the pot. It went *ming*.
>         -- Discworld archeology revealed
>            (Terry Pratchett, Moving Pictures)
>  
> 
> 
> 
> 
> 
> 
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
> - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your 
> Email-address
>  For daily traffic, use spug-list for LIST ;  for weekly, 
> spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page: 
http://zipcon.net/spug/



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/





More information about the spug-list mailing list