Menu

Finding All Hosts On the LAN From Linux / Windows Workstation

Q. How do I find out if all host computers on the LAN are alive or dead from a Linux or Windows XP computer? My network subnet range is 192.168.1.0/24 and I’m using dual boot Debian Linux / XP SP2 computer.

A.You can use normal ping command and shell script loop statement to print the list of all LAN computers from a shell prompt.

Linux / UNIX one liner to ping all hosts on the LAN

Type the following command, enter:
$ for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done
Output:
192.168.1.1 UP
192.168.1.1 UP
192.168.1.2 UP
192.168.1.5 UP
......
...
..
192.168.1.254 UP

A Note About Windows Workstation


If you are using Windows 2000 / XP / Vista, try something as follows at DOS / NT command prompt (Start > Run > CMD > Enter key):
c:> for /L %I in (1,1,254) DO ping -w 30 -n1 192.168.1.%I | find "Reply"
Read cmd.exe help page and batch scripting documentation for more information.

for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; 
    [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ;
done
But for a great tool, Nmap. Great for mapping networks.
Install nmap,
sudo apt-get install nmap
then
nmap -sP 192.168.1.*
This does a simple ping scan in the entire subnet to see which all host's are online

Không có nhận xét nào :

Đăng nhận xét