Is there a command line based way to send pings to each computer in a subnet? Like
for (int i = 1;i < 254; i++)
ping(192.168.1.i)
to enforce arp resolution?
Is there a command line based way to send pings to each computer in a subnet? Like
for (int i = 1;i < 254; i++)
ping(192.168.1.i)
to enforce arp resolution?
Broadcast ping:
$ ping 192.168.1.255
PING 192.168.1.255 (192.168.1.255): 56 data bytes
64 bytes from 192.168.1.154: icmp_seq=0 ttl=64 time=0.104 ms
64 bytes from 192.168.1.51: icmp_seq=0 ttl=64 time=2.058 ms (DUP!)
64 bytes from 192.168.1.151: icmp_seq=0 ttl=64 time=2.135 ms (DUP!)
...
(Add a -b
option on Linux)
en bash:
#!/bin/sh
COUNTER=1
while [ $COUNTER -lt 254 ]
do
ping 192.168.1.$COUNTER -c 1
COUNTER=$(( $COUNTER + 1 ))
done
Under linux, I think ping -b 192.168.1.255 will work (192.168.1.255 is the broadcast address for 192.168.1.*) however IIRC that doesn't work under windows.
The command line utility nmap can do this too:
nmap -sP 192.168.1.*
(IIRC)
Not all machines have nmap
available, but it's a wonderful tool for any network discovery, and certainly better than iterating through independent ping
commands.
$ nmap -n -sP 10.0.0.0/24 Starting Nmap 4.20 ( http://insecure.org ) at 2009-02-02 07:41 CST Host 10.0.0.1 appears to be up. Host 10.0.0.10 appears to be up. Host 10.0.0.104 appears to be up. Host 10.0.0.124 appears to be up. Host 10.0.0.125 appears to be up. Host 10.0.0.129 appears to be up. Nmap finished: 256 IP addresses (6 hosts up) scanned in 2.365 seconds