I am trying to right a series of scripts to map out all of our *nix hosts on our intranet, in order to ease administration. One part of that script requires that I ping each address. Problem is, if the subnet doesn't exist, I don't want to ping 255 addresses only to find nothing.
I wrote a perl script to ping the broadcast address (using Net::Ping) but it comes back that the address doesn't exist (even though a command line ping does).
Am I doing something incorrectly here, or does Net::Ping not work for pinging broadcast addresses? I have tried w/ and w/o ICMP, again, to no avail.
For information purposes, here is the script:
#! /usr/local/bin/perl -w use strict; use Net::Ping; my $IPBlk; my $FirstOctets = "10.0"; my $ThirdOctet; for ($ThirdOctet = 1; $ThirdOctet <= 25; $ThirdOctet++) { $IPBlk = "$FirstOctets." . "$ThirdOctet"; my $sbnt = "$IPBlk" . ".0"; my $p = Net::Ping->new(); if ($p->ping("$sbnt") ) { print "host exists\n"; } else { print "Host does not exist\n"; } print "$?\n"; }
Many thanks in advance,
Joe
In reply to Using Net::Ping for broadcast address by birdbrane
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |