Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 234Security · Network

How to find open ports on your servers with Nmap

Do you know every port your servers expose? A forgotten database port, a test web server, an admin panel on 8443 — attackers scan for them every day. Scanning your own networks with Nmap shows what is really open and which service and version answers, so you can close what should not be there. This how-to scans a subnet, finds services and versions, compares results over time, and stays within the rules.

  • 5 Lessen
  • 3 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

234.1

The quick answer

nmap -sn 10.10.0.0/24
nmap -Pn --top-ports 1000 -sV 10.10.0.21
nmap -sS -p- -T4 10.10.0.21 -oA scans/db01-$(date +%F)

234.2

Step by step

  1. Permission first — scan only systems you own or have written permission to test. Tell the network/security team; some IDS will alert.
  2. Which hosts are up (line 1) — a ping scan, no ports. Cloud hosts often block ping: use -Pn (treat all as up) for them.
  3. Common ports with versions (line 2) — -sV asks each open port what runs there (5432/tcp open postgresql PostgreSQL DB 16.x).
  4. All 65,535 TCP ports (line 3) — -sS (SYN scan, needs root) is fast; -oA saves normal, XML and grepable output for later comparison.
  5. UDP — slower, but DNS, SNMP and NTP live there: nmap -sU --top-ports 50 10.10.0.21 (root).
  6. Read the states — open (a service answers), closed (host answers, no service), filtered (firewall drops; no answer). From outside, everything except your public services should be filtered.
  7. Scan from two places — inside the network (what a hacked machine sees) and from the internet (what the world sees). The difference is your firewall.
  8. Compare over time — run the same scan weekly and diff:
ndiff scans/db01-2026-11-13.xml scans/db01-2026-11-20.xml

A new open port is a change someone must explain.

  1. TLS and more — scripts check certificates and ciphers: nmap --script ssl-enum-ciphers,ssl-cert -p 443 www.example.com.

Commando's in deze les

234.3

Check that it worked

The scan lists each host with its open ports and services; after closing an unwanted port (firewall or service stop) the next scan shows it filtered or closed; ndiff shows the change.

234.4

Common problems

ProblemCauseFix
Host seems downPing blocked.Add -Pn.
Scan takes hoursAll ports on many hosts with slow timing.Top ports first; -T4; scan in parts.
All ports filteredA firewall drops everything from your source.Scan from inside, or allow your scanner's IP.
-sS refusedNeeds root.Run with sudo, or use -sT (connect scan).
Version shows tcpwrappedService closes the connection at once.Normal for some protected services; check on the host with ss -ltnp.
Security team alarmUnannounced scan.Announce scans; use a fixed scanner IP and time.

Commando's in deze les

234.5

Go further

1What is the difference between closed and filtered in Nmap?

Closed means the host answered but no service listens; filtered means no answer came back, usually because a firewall dropped the probe.

2Why scan from inside and from outside?

Inside shows what an attacker on a hacked machine sees; outside shows what the whole internet sees.

Alle commando's in dit hoofdstuk