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 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: UP UP UP UP
.. UP

See previous article: Simple Linux and UNIX system monitoring with ping command and scripts.

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.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

43 comments… add one
  • Matias Nov 11, 2012 @ 9:22

    In linux, this would be faster
    echo 192.168.1.{1..254}|xargs -n1 -P0 ping -c1|grep “bytes from”

  • Anders Larsson May 17, 2013 @ 18:48

    One second

    for ip in 192.168.0.{1..254}; do
    ping -c 1 -W 1 $ip | grep “64 bytes” &

    • LeFeRiSoN Oct 16, 2013 @ 23:43

      0,5 Second whit first Post ;)

      for ip in $(seq 1 254)
              do ping -c 1 "192.168.0.$ip">/dev/null
                 [ $? -eq 0 ] && echo "192.168.1.$ip UP" || echo "192.168.1.$ip DOWN..."
  • john doe Mar 27, 2014 @ 23:45

    nmap -sn ip/subnet
    like if subnet mask is, and your ip is
    then: nmap -sn

    Research subnets.

  • sunil Sep 25, 2014 @ 13:22

    how to check which are all systems connected in lan

  • Santosh Jan 26, 2015 @ 17:00

    Really awesome. Alternative easy to use is nmap.

  • Six Mar 28, 2015 @ 19:32

    I think the first example should be updated to make use of Bash’s brace expansion, for which this is a textbook use case… Following is an outline of various network browsing/scanning utilities and their associated time.


  • Six Mar 28, 2015 @ 19:34

    One of the examples was cut off… should have been

    # manual ping scan
    # real	0m1.077s
    echo 192.168.1.{1..254} | \
    xargs -n1 -P0 ping -c1 -W1 | \
    grep -oP '(?<=bytes from ).*(?=:)' | \
    sort -V

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.