Find out active IPs in a Linux LAN

By | June 4, 2010

If you are on a LAN and wish to find out which computers in it currently have access to that certain LAN, you can use the following command:

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

This will ping each computer on the 192.168.1.x subnet one time, with a one second interval between pings. The output should be something like UP UP UP


Alternatively, you can use netdiscover:

sudo apt-get install netdiscover
netdiscover -r

This will scan all the computers in that particular address range and present the active ones in a table that also provides a MAC address and a MAC Vendor line. Thanks go out to angelblade for this information.

8 thoughts on “Find out active IPs in a Linux LAN

  1. angelblade

    Hey!! Its most easy with netdiscover

    # netdiscover -r

    Sometime ping is blocked via firewall

  2. Pingback: HowtoMatrix » Find out active IPs in a Linux LAN

  3. Marius

    I think is much easyer if you use nmap.
    nmap -sP -n $ip
    Like this you can see all the hosts even they have firewall.

  4. Pingy

    How about this one (replace eth0 with your NIC):

    sudo arp-scan -I eth0 -l

  5. Pingback: Quickies: search a LAN for active IPs « 0ddn1x: tricks with *nix

  6. Ken Jackson

    A minor variation:
    -w1 makes it only wait 1 second.

    for ip in $(seq 1 254); do
    ping -c1 -w1 192.168.1.$ip>/dev/null && echo “192.168.1.$ip is UP”

  7. suhass command it will work

    sudo nmap -SP
    try this command it will work


Leave a Reply

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