- 論壇徽章:
- 0
|
- #!/usr/bin/perl
- ################################
- # this script is using to scan the lan 's ip.
- # this can show how much ip is in using.
- # auth by redpig315,^_^
- ###############################
- use strict;
- use warnings;
- open(Fh,">iptable");
- print Fh "iplist\n";
- close(Fh);
- open(Fh,">>iptable");
- my $iphead="192.168.250.";
- my $i=1;
- my $count=0;
- while($i++<255){
- my $ip =$iphead.$i;
- my $node=$ip;
- my $state=!system("ping -c 1 -w 1 -q $node 1>/dev/null 2>&1");
- if(!$state){
- print "$node is offline\n";
- }else{
- $count++;
- print "$node is online\n";
- print Fh "$node\n";
- }
- $ip=$iphead;
- }
- close(Fh);
- print "total $count 's ip online\n";
- my $offip=255-$count;
- print "total $offip 's ip offline\n";
復制代碼 通過修改iphead的值,填入要掃描的局域網(wǎng)ip,對本網(wǎng)段的ip進行可用性統(tǒng)計,結(jié)果記錄在iptable中,并顯示可用ip數(shù)。 |
|