有没有基于命令行的方式来向子网中的每台计算机发送ping?类似于
for(int i = 1; i < 254; i++)
ping(192.168.1.i);
如何强制进行ARP解析?
有没有基于命令行的方式来向子网中的每台计算机发送ping?类似于
for(int i = 1; i < 254; i++)
ping(192.168.1.i);
如何强制进行ARP解析?
我来晚了,但是我为此目的制作了一个小脚本,在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
#!/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
这个脚本在OpenWRT中运行良好。
在一个新文件中放置以下代码,
#!/bin/sh
echo "Online IPs" > out.txt
COUNTER=1
while [ $COUNTER -lt 255 ]
do
ping $1.$COUNTER -c 1 -w 400 | grep "time" >> out.txt &
COUNTER=$(( $COUNTER + 1 ))
done
killall ping
设置执行权限并启动
root@r1:/# nping 192.168.1
然后在out.txt文件中查看所有连接的主机
for i in $(seq 1 254); do ping -c1 192.168.11.$i; done
for i in $(seq 1 254); do ping -c1 -t 1 192.168.11.$i; done
。该命令用于对IP地址范围内的设备进行ping测试,范围为192.168.11.1到192.168.11.254。 - user285594