nmap is a network exploration tool and security/port scanner.
We can list all open ports using nmap for a given IP/Host.
Use following command to list all open ports:
$ sudo nmap -v -sS 192.168.1.1
Use following command to scan specific ports:
$ nmap -sS -O -p80,8080 192.168.1.1
To can specific range of ports(scan from port 80 to 100):
$ sudo nmap -sS -O -p80-100 192.168.1.1
We can use nmap command to ping all IP’s in subnet.
If you don’t have nmap installed in your machine install nmap with following command:
$ apt-get install nmap
Use following command to ping all IP’s in a subnet:
$ nmap -n -sP 192.168.2.0/26
Starting Nmap 5.21 ( http://nmap.org ) at 2014-06-30 17:04 PDT
Nmap scan report for 192.168.2.1
Host is up (0.00073s latency).
Nmap scan report for 192.168.2.2
Host is up (0.0011s latency).
Nmap scan report for 192.168.2.4
Host is up (0.0010s latency).
Nmap done: 64 IP addresses (3 hosts up) scanned in 0.62 seconds
In above output we can see all reachable IP’s.