Port Scanning Techniques By Using Nmap (original) (raw)

Last Updated : 23 Jul, 2025

Nmap is a security auditing tool used in the security field to actively enumerate a target system/network. It is one of the most extensively used tools by network administrators and conversely attackers for reconnaissance (enumeration), the first step in the 5 phases of hacking. Nmap is used to actively probe the target network for active hosts(host discovery), port scanning, OS detection, version details, and active services running on the hosts that are up. For this, Nmap uses the technique of sending packets and analyzing the responses. To learn more about please refer to the article Nmap.

Port Scanning is one of the features of Nmap wherein the tool detects the status of the ports on active hosts in a network. The status of the ports can be open, filtered, or closed. Type Nmap in the command line to run Nmap. Add necessary switches according to the scanning type to initiate a specific scan technique.

Example: nmap -sS 192.168.0.1-192.168.0.52

This command runs Nmap in TCP SYN scan type (-sS) and scans the given IP address range for active hosts and services.

Please refer to the article Port Scanning to learn more about it.

Types of Port Status:

Different Port Scanning Techniques in Nmap:

The following are the extensively used scanning techniques in Nmap:

1. TCP Connect Scan (-sT): TCP Connect scan uses the concept of a full three-way handshake to discover whether a given port is open, filtered, or closed according to the response it receives. Nmap sends a TCP request packet to each and every port specified and determines the status of the port by the response it receives. RFC 793 says,

If the connection does not exist (CLOSED) then a reset is sent in response to any incoming segment except another reset. In particular, SYNs addressed to a non-existent connection are rejected by this means.

Port Scanning by Nmap

2. TCP SYN Scan (-sS): SYN scans are often called "Half-open" or "Stealth" scans. SYN scan works the same way as TCP Connect scan with closed and filtered ports i.e receives a RST packet for closed port and no response for filtered ports. The only difference is in the way they handle the open ports. SYN scan sends a response packet to the server with its RESET FLAG set(but not ACK which is usually the default in the actual three-way handshake) after receiving SYN/ACK from the target server. This is to avoid the server from continuously making requests to establish a connection and thereby reduce the scan time.

This scan type is referred to as a stealth scan due to the following advantages:

3. UDP Scan (-sU): UDP unlike TCP, doesn't perform a handshake to establish a connection before sending data packets to the target port but rather sends the packets hoping that the packets would be received by the target port. That is why UDP connections are often called "stateless". This type of connection is more efficient when speed dwarfs quality, like in video sharing. As there will be no acknowledgment from the target port whether it has received the packet, UDP scans become more difficult and very much slower.

The below scan techniques are very less likely to be used in real-time but it's worth learning the principle behind them. They are said to be even stealthier than the "SYN stealth" scan.

For the below scan types, when a packet is sent to an "open" port, there won't be any response from the target port which is very similar to the UDP scan. When the below scan types don't get a response, they would mark the port as being open/filtered. As per RFC 793, for malformed packets, the closed ports on the server are mandated to respond with an RST TCP packet and no response at all for open ports.