Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Pinging IP Address Range

by neuhru (Novice)
on Mar 22, 2013 at 23:40 UTC ( #1024992=perlquestion: print w/replies, xml ) Need Help??
neuhru has asked for the wisdom of the Perl Monks concerning the following question:

Hello PerlMonks,

What is the best way to ping a range of IP addresses to determine if they are active? Ranges include "172.31", "192.168", and "10.254".

Please help get me started down the path to achieving this. Let me know if any additional information is required.

Thanks in advance,


Replies are listed 'Best First'.
Re: Need Help Determining DHCP IP Address Range
by NetWallah (Canon) on Mar 23, 2013 at 06:13 UTC
    You need to know the MAC address of the switch, or , at least the MAC prefix (The first three octets of a six-octet ethernet address uniquely identifies the hardware vendor - This is called the "Organizationally Unique Identifier" (OUI)) of the manufacturer.

    You can look this up for your vendor at

    If you have access to your DHCP server, you should be able to match this MAC prefix or address with the list of DHCP-distributed addresses, and determine the IP address.

    If you do not have access to DHCP, but are on the same unrouted subnet as the switch, you can ping the entire subnet range, then look at your arp table, then find the mac for the Infiniband switch, and trace back to the IP.

                 "I'm fairly sure if they took porn off the Internet, there'd only be one website left, and it'd be called 'Bring Back the Porn!'"
            -- Dr. Cox, Scrubs

Re: Need Help Determining DHCP IP Address Range
by hdb (Monsignor) on Mar 23, 2013 at 10:52 UTC

    Hmm: This is not really a Perl question...

    You could run some network scanning tool such as nmap. I got the following from

    nmap -O -oX test.xml

    which runs a very aggressive test on all machines and gives you a lot of information such as Vendor, OS, MAC, etc. On my machine you need to run this as root. Unless you own the network, this might be seen as an aggression.

    UPDATE: As always, you can probably do it within Perl as well as there is an Nmap::Scanner module in Perl which might achieve similar feats...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1024992]
Approved by Lotus1
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-11-24 13:37 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (349 votes). Check out past polls.