NMAP, which stands for “Network Mapper”, is an open-source tool used for network discovery and security auditing. It was designed to scan large networks, but it also works fine against single hosts. NMAP uses raw IP packets to determine what hosts are available on the network, what services those hosts are offering, what operating systems they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics.
The -p option in NMAP is used to specify the ports on a targeted system that NMAP will scan. Basically, it enables you to choose which ports you want to examine rather than letting NMAP scan its default selection of ports.
So, if you want to scan ports 20 – 30 on a certain host, your command would look like this:
`nmap -p 20-30 [host]`
Here, “20-30” specifies the range of ports you’re interested in, and [host] should be replaced with the IP address or domain name of the system you’re trying to explore.
But that’s not to say the -p option is limited to scanning a range of ports. By using this option, you can also:
1. Scan a single port: `nmap -p 22 [host]`
2. Scan multiple disparate ports: `nmap -p 21,22,80,443 [host]`
3. Scan all ports: `nmap p [host]`
Scanning all 65535 ports can be useful if you suspect non-standard ports are in use.
The -p option can also be used in combination with other options like -sV for service detection, -O for OS detection, or -A for both, among many others to customize what kind of information is gathered and how the scan operates.
The information on how NMAP and its -p option works are found in the official documentation of NMAP and in online resources like “NMAP Network Scanning” by Gordon Lyon and various blogs that explain the usage and intricacies of NMAP.
Source:
- Lyon, G. F.. (2009). Nmap Network Scanning. Insecure, https://nmap.org/book/man-port-specification.html
- Nmap.org. (2000). Nmap Documentation, https://nmap.org/docs.html
- TechRepublic. (2017). How to use Nmap to scan networks, https://www.techrepublic.com/article/how-to-use-nmap-to-scan-networks/.