Отправьте пинг каждому IP в подсети - PullRequest
44 голосов
/ 02 февраля 2009

Есть ли способ командной строки для отправки пингов на каждый компьютер в подсети? Как

for(int i = 1; i < 254; i++)
    ping(192.168.1.i);

для обеспечения разрешения arp?

Ответы [ 14 ]

1 голос
/ 21 января 2018

Я опоздал, но вот небольшой сценарий, который я сделал для этой цели и который я запускаю в Windows PowerShell Вы должны быть в состоянии скопировать и вставить его в ISE. Затем он запустит команду arp, сохранит результаты в файл .txt и откроет его в блокноте.

# Declare Variables
$MyIpAddress
$MyIpAddressLast

# Declare Variable And Get User Inputs
$IpFirstThree=Read-Host 'What is the first three octects of you IP addresses please include the last period?'
$IpStart=Read-Host 'Which IP Address do you want to start with? Include NO periods.'
$IpEnd=Read-Host 'Which IP Address do you want to end with? Include NO periods.'
$SaveMyFilePath=Read-Host 'Enter the file path and name you want for the text file results.'
$PingTries=Read-Host 'Enter the number of times you want to try pinging each address.'

#Run from start ip and ping
#Run the arp -a and output the results to a text file
#Then launch notepad and open the results file
Foreach($MyIpAddressLast in $IpStart..$IpEnd)
{$MyIpAddress=$IpFirstThree+$MyIpAddressLast
    Test-Connection -computername $MyIpAddress -Count $PingTries}
arp -a | Out-File $SaveMyFilePath
notepad.exe $SaveMyFilePath
1 голос
/ 02 февраля 2009

Проверьте, есть ли в этом блоге то, что вам нужно.

0 голосов
/ 21 октября 2015
for i in $(seq 1 254); do ping -c1 192.168.11.$i; done
0 голосов
/ 07 апреля 2013
#!/bin/sh

COUNTER=$1

while [ $COUNTER -lt 254 ]
do
 echo $COUNTER
 ping -c 1 192.168.1.$COUNTER | grep 'ms'
 COUNTER=$(( $COUNTER + 1 ))
done

#specify start number like this: ./ping.sh 1
#then run another few instances to cover more ground
#aka one at 1, another at 100, another at 200
#this just finds addresses quicker. will only print ttl info when an address resolves
...