Cyberlium
Cyberlium
Cyberlium on Android·Google Play Store

Learn cybersecurity with hands-on labs and AI mentor support on your phone.

Networking8 min read·Updated: 2026-10-16

Network Security Fundamentals: How Nmap and Port Scanning Work

A technical breakdown of TCP handshakes, SYN stealth scans, service banner grabbing, and defensive port hardening.

C
Cyberlium Editorial Team
Peer-Reviewed Technical Publication

1. The Anatomy of Network Ports and Sockets

An IP address routes traffic to a specific host machine, but a port number tells the operating system which particular service should process that incoming packet.

Ports range from 0 to 65535: Well-known ports (0–1023) host critical infrastructure services like HTTP (80), HTTPS (443), and SSH (22); Registered ports (1024–49151) host applications; and Dynamic/Ephemeral ports (49152–65535) are assigned by operating systems for outbound client sessions.

2. The TCP 3-Way Handshake vs SYN Scanning

A legitimate TCP connection completes a 3-way handshake: Client sends SYN -> Server responds with SYN-ACK -> Client confirms with ACK.

Nmap's default privileged scan is the TCP SYN Scan ('nmap -sS'). Instead of completing the handshake, Nmap sends a RST (Reset) packet the instant it receives SYN-ACK from the server. Because the connection is never fully established, older logging daemons frequently failed to record the event.

bashTerminal / Code
# Standard Nmap scan: TCP SYN scan (-sS), service version (-sV), default scripts (-sC)
sudo nmap -sS -sV -sC -p 1-1000 192.168.1.100

3. Interpreting Port States in Nmap

Open: An application actively accepts incoming TCP connections on this port.

Closed: The port is accessible (it receives and responds to probes), but no application is listening. The target returns an RST packet.

Filtered: Nmap cannot determine if the port is open because a firewall, router ACL, or host-based iptables rule dropped the probe packet before it reached the socket.

4. Hardening Your Attack Surface

Every open port is a potential door for exploitation. Defensive administrators practice aggressive port hygiene: bind internal services strictly to localhost (127.0.0.1) rather than all interfaces (0.0.0.0).

Deploy host-based firewalls (such as UFW on Ubuntu or firewalld on RHEL) to drop unsolicited incoming connections by default.

Ready to test these concepts hands-on?

Explore our free interactive browser-based labs and CTF challenges.