Web Design

Categorized | Networking, cli

Find out active IPs in a Linux LAN

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

192.168.1.1 UP
192.168.1.17 UP
192.168.1.24 UP

UPDATE:

Alternatively, you can use netdiscover:

sudo apt-get install netdiscover
netdiscover -r 192.168.1.0/24

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.

Author Profile

T4L ;

Other posts by T4L

Author's web site



Are you satisfied with this blog?
Why not subscribe our RSS Feed? you will always get the latest post.


6 Comments


  1. Hey!! Its most easy with netdiscover

    # netdiscover -r 192.168.0.0/24

    Sometime ping is blocked via firewall

    1
  2. Sephi

    You could also use fping :

    fping -g 192.168.1.0/24

    2

  3. 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.

    3
  4. Pingy

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

    sudo arp-scan -I eth0 -l

    4
  5. 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”
    done

    5
  6. suhass command it will work

    sudo nmap -SP 192.168.1.0/24
    try this command it will work

    6

2 Trackback(s)

  1. 06 06 2010 : HowtoMatrix » Find out active IPs in a Linux LAN
  2. 20 08 2010 : Quickies: search a LAN for active IPs « 0ddn1x: tricks with *nix

Leave A Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>