Thor2923
asked on
I need a script or tool to PING live IPs in a block of 254 addresses
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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
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
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...
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):
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.
Open in new window
Steve