Finding Active Computers in Local Network from Linux

Searching for Linux command that can list all IP addresses of devices connected to the network?

Use nmap or ping commands to determine alive hosts in your local network.

[nmap] Scan Network for Alive Computers

Scan for active hosts on a network using nmap command:

# Standard ICMP ping
$ nmap -sn 192.168.1.0/24

Sample output:

Starting Nmap 6.00 ( http://nmap.org ) at 2013-06-14 00:52 EEST
Nmap scan report for 192.168.1.1
Host is up (0.0031s latency).
Nmap scan report for 192.168.1.101
Host is up (0.00097s latency).
Nmap scan report for 192.168.1.102
Host is up (0.065s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 2.98 seconds

[ping] Find Active Hosts in LAN

Use the following script to find out what computers in your local network respond to ping:

$ echo 192.168.1.{1..254}|xargs -n1 -P0 ping -c1|grep "bytes from"

Sample output:

64 bytes from 192.168.1.101: icmp_req=1 ttl=64 time=0.042 ms
64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=37.4 ms
64 bytes from 192.168.1.102: icmp_req=1 ttl=64 time=208 ms

Discover Computers Behind a Firewall

Some hosts may have a firewall, and will not respond to standard ICMP pings.

If a firewall is blocking standard ICMP pings, try the following host discovery methods:

# TCP SYN Ping
$ nmap -sn -PS 192.168.1.0/24

# TCP ACK Ping
$ nmap -sn -PA 192.168.1.0/24

# UDP Ping
$ nmap -sn -PU 192.168.1.0/24

# IP Protocol Ping
$ nmap -sn -PO 192.168.1.0/24

# ARP Ping
$ nmap -sn -PR 192.168.1.0/24

Last three commands should be executed with root credentials.

  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

What Is My Router’s IP Address (Default Gateway)

A router is a device that communicates between the Internet (or public network) and the devices...

CIDR Notation – Explained & Examples

CIDR (Classless Inter-Domain Routing) notation is a compact method for specifying IP addresses...

Disable IPv6 on Linux – Ubuntu, Debian, CentOS

To disable IPv6 on Linux it is required to modify Linux kernel parameters. IPv6 can be temporary...

169.254.0.0/16 – Disable ZEROCONF Route

You may notice that in your routing table you have a route 169.254.0.0/16. It is so called...

What is my Public IP address?

Use one of the following commands to check your public IP address from the Linux command line....