Intermediate · Scanning with nmap · topic 12 of 35 · 16 min
Ports, services and what scanning does
Explanation
Ports: numbered doors
When one computer talks to another, it does not just reach "the machine"; it reaches a specific service through a numbered door called a port. A web server listens on port 80 (HTTP) or 443 (HTTPS). SSH (remote login) listens on 22. Email, databases and other services each have their usual ports. There are 65,535 ports.
| Port | Service | Note |
|---|---|---|
| 22 | SSH | Secure remote login |
| 80 | HTTP | Web, unencrypted |
| 443 | HTTPS | Web, encrypted with TLS |
| 3306 | MySQL | A database |
| 3389 | RDP | Windows remote desktop |
| 25 / 587 | SMTP | Sending email |
What a scan actually asks
Scanning is sending small messages to a range of ports and noting the replies. A port can be open (a service is listening), closed (nothing listening but the host replied), or filtered (a firewall blocked the reply, so you cannot tell). The pattern of open ports is like a list of the doors into a building.
Why versions matter
Knowing a port is open is useful; knowing the exact software and version behind it is far more useful. "Port 21 open" is a start; "vsftpd 2.3.4" tells a tester to look up whether that version has known issues. That is why service and version detection, covered next, is such an important step.
Detection and defence (preview)
Scanning is noisy: it creates many connections in a short time, which firewalls, IDS and SIEM can flag. Defenders reduce exposure by closing unused ports, putting services behind a firewall, and alerting on scan-like traffic. A tester should expect their scans to be noticed on a well-run network.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Ports, services and what scanning does · 1/7
A port is a numbered door where a service listens.
Prefer a video by a teacher? Find free videos on “computer ports explained open closed filtered beginners” on YouTube ↗
In real life: Mapping a lab box
A learner scans the Metasploitable VM in her lab and sees ports 21, 22, 23, 80 and 3306 open. Each is a door: FTP, SSH, Telnet, web and MySQL. She now knows where to look. She also notes that a real server should not expose Telnet (port 23) at all, because it is unencrypted — a defensive observation she records alongside the finding.
Practice (0/3 done)
A port is…
Which port is normally HTTPS?
Write service_for(port) that returns the common service name for a few ports: 22 -> "SSH", 80 -> "HTTP", 443 -> "HTTPS", 3306 -> "MySQL". For any other port return "unknown".
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- nmap scan typesScanning with nmap · same module
- Service, version and OS detection, and NSEScanning with nmap · same module
- Ports and protocolsCyber Security: from zero to SOC analyst · Networking for security
- Enumeration: digging into servicesEnumeration and vulnerability assessment
- Linux networking for DevOpsDevOps: Git, Docker, Kubernetes and CI/CD · Linux for DevOps
- firewalld: zones, services and portsLinux and Red Hat (RHCSA to RHCE) · Software and networking
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
An "open" port means…
Answer: A service is listening there
Open means a service is listening and accepting connections.
"Filtered" in a scan usually means…
Answer: A firewall blocked the reply, so you cannot tell
Filtered means something (often a firewall) stopped the reply.
Why does the service version matter?
Answer: It tells you whether that exact software has known issues
A specific version lets a tester check for known weaknesses.
A defender can reduce scan exposure by…
Answer: Closing unused ports and using a firewall
Fewer open ports and a firewall shrink the attack surface.
Which port range does your computer usually pick its source port from?Related
Answer: 49152–65535
Clients use dynamic (ephemeral) ports, 49152–65535 in the IANA range.
From Ports and protocols
Enumeration is noisier than scanning because it…Related
Answer: Sends many requests and produces many 404s
The volume of requests and error responses stands out in logs.
A SYN scan (-sS) is often preferred because it is…Related
Answer: Faster and does not complete the handshake
It sends only the first handshake step; faster and slightly quieter, but still detectable.
From nmap scan types
A matching defence is to…Related
Answer: Hide/patch versions and disable unused services
Reveal less, patch, and reduce the attack surface.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 2 more topics in “Scanning with nmap” before its exam: nmap scan types, Service, version and OS detection, and NSE.
- Module 4 exam: scanning with nmap · 12 questions · 20 min, without help. 3 topics of this module still to finish first.
- Then the next module, Enumeration and vulnerability assessment. 35 topics left in the course before the final exam.