How to ping all the ip in LAN using Terminal?

You can install an application called nmap.

sudo apt-get install nmap

Then you can check your entire network for all connected IP addresses by typing in the following:

nmap -sP 192.168.1.1/24

The above command will scan all IP addresses starting at 192.168.1.1 through 192.168.1.254 and show you all IPs that responded.

You can scan other IP address ranges like 192.168.0.1 - 192.168.1.254 by typing in the following:

nmap -sP 192.168.0.1/23

A typical scan might return something like the following:

terrance@terrance-ubuntu:~$ nmap -sP 10.0.0.1/24

Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-24 00:20 MST
Nmap scan report for Linksys03773 (10.0.0.1)
Host is up (0.00078s latency).
Nmap scan report for terrance-ubuntu (10.0.0.100)
Host is up (0.00020s latency).
Nmap scan report for android (10.0.0.148)
Host is up (0.099s latency).
Nmap scan report for PC (10.0.0.149)
Host is up (0.0014s latency).
Nmap scan report for 10.0.0.150
Host is up (0.0016s latency).
Nmap scan report for 10.0.0.165
Host is up (0.011s latency).
Nmap scan report for 10.0.0.169
Host is up (0.010s latency).
Nmap scan report for 10.0.0.179
Host is up (0.014s latency).
Nmap scan report for android (10.0.0.181)
Host is up (0.093s latency).
Nmap scan report for android (10.0.0.188)
Host is up (0.043s latency).
Nmap scan report for android (10.0.0.196)
Host is up (0.014s latency).
Nmap scan report for 10.0.0.253
Host is up (0.0013s latency).
Nmap done: 256 IP addresses (12 hosts up) scanned in 4.46 seconds

I hope this helps!


fping is another command to ping all ip in LAN.

fping -a -r 0 -g 192.168.9.0/24

192.168.9.48
192.168.9.71
192.168.9.72
192.168.9.73
192.168.9.75
192.168.9.79
192.168.9.81
192.168.9.82
ICMP Redirect from 192.168.9.4 for ICMP Echo sent to 192.168.9.83
192.168.9.84
192.168.9.85
192.168.9.87
192.168.9.88
192.168.9.90
192.168.9.92
192.168.9.104
192.168.9.106
192.168.9.108
192.168.9.109
192.168.9.116
192.168.9.117
ICMP Host Unreachable from 192.168.9.214 for ICMP Echo sent to 192.168.9.1
192.168.9.120
ICMP Host Unreachable from 192.168.9.214 for ICMP Echo sent to 192.168.9.2

-a Show systems that are alive.

-r n Retry limit (default 3). This is the number of times an attempt at pinging a target will be made, not including the first try.

-g addr/mask Generate a target list from a supplied IP netmask, or a starting and ending IP. Specify the netmask or start/end in the targets portion of the command line. If a network with netmask is given, the network and broadcast addresses will be excluded.

To scan range of IP addresses from 192.168.0.1 to 192.168.0.9 just run:

sudo fping -s -g 192.168.0.1 192.168.0.9 -r 1

That will output:

192.168.0.1 is alive
192.168.0.7 is alive
192.168.0.2 is unreachable
192.168.0.3 is unreachable
192.168.0.4 is unreachable
192.168.0.5 is unreachable
192.168.0.6 is unreachable
192.168.0.8 is unreachable
192.168.0.9 is unreachable

9 targets
2 alive
7 unreachable
0 unknown addresses

14 timeouts (waiting for response)
16 ICMP Echos sent
2 ICMP Echo Replies received
0 other ICMP received

0.05 ms (min round trip time)
0.44 ms (avg round trip time)
0.84 ms (max round trip time)
2.183 sec (elapsed real time)

Here is the ubuntu manual to use fping with different options.


There are 2 ways:

  • Use nmap to scan entire local subnets in only one command. For example: nmap -sP 192.168.0.1/24
  • Use arp-scan, it sends ARP packets to hosts on the local network and displays any responses that are received. By default, it's not installed. So install it by the command sudo apt-get install arp-scan.

Once it's accomplished. Launch this command to scan entire local network on the specified interface (For example, your network interface is named eth0):

sudo arp-scan --interface=eth0 --localnet

or give a specific subnet:

sudo arp-scan --interface=eth0 192.168.0.1/24