brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: the nmap reason column says why a port is open, closed or filtered

Nmap
~/tips/tip-nmap-reason-flag-port-state

sudo nmap --reason -p 22,443,5432 192.0.2.10

See which reply, or missing reply, led nmap to each port state.

When a port shows as filtered and you expected it to be open, the state alone doesn’t help much. Ask nmap what it based that on:

sudo nmap --reason -p 22,443,5432 192.0.2.10

An extra REASON column appears. syn-ack means the target accepted the connection attempt, so something is listening. reset means the host answered and refused: it is reachable, but nothing listens on that port. no-response means silence, which usually points at a firewall that drops packets.

I find that this difference saves me from looking in the wrong place. A refused port sends me to the service itself (is it running, and on which address?), while silence sends me to firewall rules along the way.

The host line gets a reason as well, so you can see what made nmap decide the machine is up.

With sudo, nmap uses a SYN scan and the reasons are detailed. Without it, nmap falls back to ordinary connect calls and learns less about each reply. Also remember that the answer reflects the path from the machine you scan from. The same server can give a different reason from inside your network than from outside. Only scan machines you own or have permission to test.

Further reading: Nmap output options, Nmap port scanning techniques

More Nmap tips nmap --packet-trace -p 22,80 192.0.2.10 nmap -p 22,80,443 -oG scan.gnmap 192.0.2.0/24 nmap -sV 192.0.2.10 sudo nmap -sU -p 53,67,123,161 192.0.2.10 nmap -sL 192.0.2.0/28 All Nmap tips (12) All topics

Link