Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Scan multiple IP subnets

by Loops (Hermit)
on Jul 22, 2013 at 04:13 UTC ( #1045572=note: print w/ replies, xml ) Need Help??


in reply to Scan multiple IP subnets

As NetWallah suggested, using a CPAN module will be best. Below is an example for using Net::IP. It would replace the @sn_array assignment and the "foreach $host" loop in the original code

use Net::IP; my @sn_array = qw( 172.22.0.0/30 7.3.1.0/24 ); ... for my $net (map {new Net::IP $_} @sn_array) { do { $manager->start and next; my $p = Net::Ping->new("icmp"); my $host = $net->ip; print "pinging $host\n"; if ($p->ping($host)){ open PingFile, ">>", "$pingable" or die $!; flock(PingFile, LOCK_EX); print PingFile "$host\n"; flock(PingFile, LOCK_UN); close(PingFile); } $manager->finish; } while (++$net); }


Comment on Re: Scan multiple IP subnets
Download Code
Re^2: Scan multiple IP subnets
by vlad3848 (Acolyte) on Jul 22, 2013 at 11:45 UTC
    That did it! Thank you!
      Why is it that when I make the changes above, it pings 192.168.1.0 and 192.168.2.0 as actual addresses?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045572]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-09-19 02:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls