Situation:
Suppose you want to find all the servers which are Up in Network or in a range of IPs. We may need this information for trouble-shooting purpose like fixing IP conflicts or to get an idea about how many servers are online at a given point of time.
Solution:
# nmap -v -sP
The network info can be given as a whole network (say 10.10.22.0/24) or as a range (say 10.10.22.1-40).
Example:
[root@gtxash01 ~]# nmap -v -sP 10.10.22.1-40 ß Scans servers in the IP range of 10.10.22.1 to 10.10.22.40
DNS resolution of 25 IPs took 5.50s.
Host 10.10.22.1 appears to be up.
Host 10.10.22.2 appears to be up.
Host 10.10.22.3 appears to be down.
Host 10.10.22.4 appears to be down.
Host 10.10.22.5 appears to be down.
Host 10.10.22.6 appears to be down.
Host 10.10.22.7 appears to be down.
Host 10.10.22.8 appears to be down.
Host 10.10.22.9 appears to be down.
Host 10.10.22.10 appears to be down.
Host 10.10.22.11 appears to be down.
Host rwbcat01.tcprod.local (10.10.22.12) appears to be up.
Host 10.10.22.13 appears to be down.
Host rsarash01.tcprod.local (10.10.22.14) appears to be up.
Host rdbash01.tcprod.local (10.10.22.15) appears to be up.
Host 10.10.22.16 appears to be down.
Host 10.10.22.17 appears to be down.
Host 10.10.22.18 appears to be down.
Host 10.10.22.19 appears to be down.
Host xenlashb1.tcprod.net (10.10.22.20) appears to be up.
Host webash04.tcprod.net (10.10.22.21) appears to be up.
Host webash23.tcprod.net (10.10.22.22) appears to be up.
Host xenc1bx-ih.tcprod.net (10.10.22.23) appears to be up.
.
< Output truncated >
< Output truncated >
.
Host gdsash02.tcprod.local (10.10.22.39) appears to be up.
Host gdsash02.tcprod.local (10.10.22.39) appears to be up.
Host 10.10.22.40 appears to be down.
Nmap finished: 40 IP addresses (25 hosts up) scanned in 6.178 seconds
Raw packets sent: 110 (3740B) | Rcvd: 50 (2300B)
[root@gtxash01 ~]# nmap -v -sP 10.10.22.0/24 | grep up # Scans servers in entire 10.10.22.0 network
DNS resolution of 53 IPs took 5.50s.
Host 10.10.22.0 seems to be a subnet broadcast address (returned 1 extra pings).
Host 10.10.22.1 appears to be up.
Host 10.10.22.2 appears to be up.
.
< Output truncated >
.
Host 10.10.22.243 appears to be up.
< Output truncated >
.
Host 10.10.22.243 appears to be up.
Host 10.10.22.244 appears to be up.
Host l2ash.tcprod.local (10.10.22.250) appears to be up.
Host l22ash.tcprod.local (10.10.22.251) appears to be up.
Host 10.10.22.255 seems to be a subnet broadcast address (returned 1 extra pings).
Nmap finished: 256 IP addresses (53 hosts up) scanned in 7.755 seconds
Raw packets sent: 914 (31.076KB) | Rcvd: 108 (4968B)
[root@gtxash01 ~]#