Port Scanning Techniques
SYN, connect, UDP.
Port Scanning Techniques is a free Ethical Hacking Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ethical Hacking Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Scan Ports?
Open ports reveal the services a host is running, which is your map of the attack surface. Port scanning determines which TCP and UDP ports are open, closed, or filtered.
Nmap offers several scan techniques, each with trade-offs in speed, stealth, and the privileges required.
Port States
Nmap reports each port in one of these states:
- open: a service is actively accepting connections.
- closed: reachable but no service listening.
- filtered: a firewall is blocking probes, so Nmap cannot tell.
- open|filtered and closed|filtered: ambiguous results.
The TCP Three-Way Handshake
Understanding scans requires the TCP handshake:
- Client sends SYN.
- Server replies SYN-ACK if the port is open.
- Client sends ACK to complete the connection.
A closed port replies with RST. Scan types differ in how far through this handshake they go.
SYN Scan
The SYN scan (-sS) is the default when run as root. It sends a SYN, sees the SYN-ACK (open) or RST (closed), then sends RST to never complete the handshake.
This 'half-open' scan is fast and relatively stealthy because the full connection is never established. It requires raw socket privileges.
sudo nmap -sS 192.168.1.10Connect Scan
The connect scan (-sT) completes the full three-way handshake using the OS networking API. It needs no special privileges, so it is the fallback for unprivileged users.
Because it fully connects, it is louder and more likely to be logged by the target's services.
nmap -sT 192.168.1.10UDP Scan
The UDP scan (-sU) finds services like DNS, SNMP, and DHCP that use UDP. UDP is connectionless, so scanning is slow and tricky:
- No response often means open|filtered.
- An ICMP port-unreachable means closed.
UDP services are frequently overlooked, so they can hide valuable findings.
sudo nmap -sU --top-ports 50 192.168.1.10Stealth Scans
Several scans send unusual flag combinations to slip past simple firewalls and avoid SYN logging:
- FIN (
-sF): only the FIN flag. - NULL (
-sN): no flags set. - Xmas (
-sX): FIN, PSH, and URG set, 'lit up like a Christmas tree'.
These rely on RFC behavior and often work only on certain stacks.
sudo nmap -sX 192.168.1.10Choosing Ports
Control which ports are scanned to balance speed and coverage:
-p 80,443specific ports.-p 1-1000a range.-p-all 65535 ports.--top-ports 100the most common ports.-Ffast scan of the top 100.
nmap -p- 192.168.1.10
nmap --top-ports 100 192.168.1.10Timing Templates
The -T flag sets timing from 0 (paranoid) to 5 (insane):
- -T0/-T1: very slow, for evading IDS.
- -T3: the balanced default.
- -T4: faster, common on reliable networks.
- -T5: aggressive, may miss results.
Faster scans are louder and risk inaccuracy.
nmap -sS -T4 -p- 192.168.1.10Firewall Evasion Basics
Nmap offers options to test firewall and IDS resilience:
-ffragments packets.-Duses decoy source addresses.--source-portspoofs a trusted source port like 53.
Use these only in authorized tests to evaluate detection capabilities.
Combining Into a Practical Scan
Real scans blend these options. A common thorough TCP scan picks the scan type, all ports, faster timing, and saves output.
Start broad to find open ports, then run focused follow-up scans (version detection, scripts) only on the ports that are actually open. This two-phase approach is faster and quieter than doing everything at once.
sudo nmap -sS -p- -T4 -oA tcp_all 192.168.1.10
# Then deep-scan only the open ports foundQuick Check
Match the scan to its behavior.
Recap
You learned port scanning techniques:
- Port states: open, closed, filtered and ambiguous variants.
- SYN scan (-sS) is the stealthy default; connect (-sT) needs no privileges but is louder.
- UDP (-sU) is slow but uncovers overlooked services.
- FIN/NULL/Xmas scans evade simple firewalls.
- Control ports with
-p, speed with-T, and test evasion with -f/-D.
Next: service and OS detection.
Frequently asked questions
Is the “Port Scanning Techniques” lesson free?
Yes — the full text of “Port Scanning Techniques” is free to read here on the web, and the Ethical Hacking Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ethical Hacking Academy course, upgrade to CoddyKit PRO.
What will I learn in “Port Scanning Techniques”?
SYN, connect, UDP. You practise Ethical Hacking Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Ethical Hacking Academy?
No prior experience is required. Ethical Hacking Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Port Scanning Techniques” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Ethical Hacking Academy lesson?
Yes. Every Ethical Hacking Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Host Discovery
- Port Scanning Techniques
- Service and OS Detection
- The Nmap Scripting Engine