Solved

I need a script or tool to PING live IPs in a block of 254 addresses

Posted on 2013-02-03
5
563 Views
Last Modified: 2013-02-19
I have a block of 254 IPs and want to set up some statics, but the DHCP in the switch is randomly changing them. I want to find them quickly and lock them in for good. Does anyone have a tool or script?
0
Comment
Question by:Thor2923
5 Comments
 
LVL 9

Accepted Solution

by:
Aeriden earned 500 total points
ID: 38849299
Most DHCP servers will list the assigned IP addresses.

The problem with testing live IPs is that a host could be off and yet an IP could still be assigned.  Also, newer version of Windows, by default, block ping requests.  So looking up what has been assigned is ideal.

It is also ideal to update the DHCP Server to block certain blocks of IPs (for your static block).

However, if you would still like to ping, here are some useful tools:

SolarWinds Ping Sweek
http://www.solarwinds.com/engineers-toolset.aspx

OpUtils
http://www.manageengine.com/products/oputils/diagnostic-tools.html

SnapFiles Network Scanner
http://www.snapfiles.com/Freeware/network/fwscanner.html
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38849519
Aside from such tools, look in the ARP table of the switch, or from a PC on the same subnet, e.g.

ARP -A

You can PING all hosts quickly then look at the arp table as they go along too with something like this batch file (save it as .cmd):

@echo off
set subnet=192.168.1
set wait=50

for /l %%a in (1,1,254) do (
  title PINGing %subnet%.%%a
  ping -n 1 -w %wait% %subnet%.%%a > NUL 2>&1
  arp -A | find "%subnet%.%%a  " | find /v "Interface"
)

Open in new window


That will run through all IP's 1-254 on the subnet defined, and then take the output of the ARP command as it goes along to get the mac address for each - if you wait until the end of the run of all in a subnet the arp table may not still have all entries.

or slightly more complicated this pings each IP and picks up the hostname from the PING line (if yours shows it here) and then does the ARP to find Mac address and sends output for IP, name, mac address.  Save it as "findmac.cmd" say then you can run as findmac > file.csv from commandline to get a csv file say.

@echo off
setlocal enabledelayedexpansion
set subnet=192.168.1
set wait=40

for /l %%a in (1,1,254) do (
  title PINGing %subnet%.%%a
  set Name=*NotFound*
  for /f "tokens=2 delims=[ " %%N in ('ping -a -n 1 -w %wait% %subnet%.%%a ^| find /i "Pinging"') do set Name=%%N
  for /f "tokens=1-2 delims= " %%X in ('arp -A ^| find "%subnet%.%%a  " ^| find /v "Interface"') do echo %subnet%.%%a,!Name!,%%Y
)

Open in new window


Steve
0
 
LVL 16

Expert Comment

by:Dale Harris
ID: 38849533
This Powershell script completes in a matter of seconds (I think 6 seconds for all 255 IPs)

function Check-Online {
       param(
              $computername
       )
 
       test-connection -count 1 -ComputerName $computername -TimeToLive 5 -asJob |
       Wait-Job |
       Receive-Job |
       Where-Object { $_.StatusCode -eq 0 } |
       Select-Object -ExpandProperty Address
}
 
$ips = 1..255 | ForEach-Object { "10.10.10.$_" }
$online = Check-Online -computername $ips

$online

This code pings an IP segment from 10.10.10.1 to 10.10.10.255 and returns only those IPs that respond.

From Powershell.com
0
 
LVL 16

Expert Comment

by:vivigatt
ID: 38851722
From a linux host, you can send a ping packet to broadcast address and then receive ping echos from live IPs :

ping -b 192.168.1.255  

(if the subnet is 192.168.1.x)

However, Windows hosts do not answer pings sent to broadcast addresses

You may want to try the following utility instead:

http://www.angryip.org/w/Home
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38906489
Always good to know that providing a script (as asked for) to do what was asked by several of us is ignored without comment.  Doesn't hurt to give feedback when you get around to closing a question a fortnight later Thor2923...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBSScript Error IP Array 6 27
Windows Installer (VBSCRIPT) Rename Printer 3 31
cscript to activate Windows and Office? 2 23
Remote start and stop of service 3 12
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question