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: nmap --packet-trace prints every packet Nmap sends and receives

Nmap
~/tips/tip-nmap-packet-trace

nmap --packet-trace -p 22,80 192.0.2.10

Prints a summary line for each packet Nmap sends or receives during a scan.

A port that Nmap calls filtered tells me very little. I’d rather see what actually went over the wire, and Nmap has a switch for exactly that.

nmap --packet-trace -p 22,80 192.0.2.10

The manual says --packet-trace makes Nmap print a summary of every packet it sends or receives. Instead of only the final port table, you get the probes and the answers, one line each. That helps when a result looks odd. The port table says filtered when packet filtering stops Nmap from telling whether a port is open, and the trace lets you see whether anything came back at all.

It pairs well with --reason, which adds the reason Nmap gave each port its state:

nmap --packet-trace --reason -p 22 192.0.2.10

Now the trace shows the traffic and the table shows the verdict, so you can compare them directly.

The caveat is volume. A default scan covers 1,000 TCP ports, and a trace of that is a lot of lines. The manual itself suggests limiting the ports, for example with -p20-30, to avoid thousands of lines. I’d also scan one host at a time with this switch. Two narrower variants exist for when you only care about one part of a scan: --version-trace for version detection and --script-trace for scripts.

As always with Nmap, point it at machines you own or have permission to scan. The trace does not make that any less true.

Further reading: Nmap reference guide: output options, Nmap reference guide: port scanning basics

More Nmap tips 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 nmap -oX before.xml 192.0.2.10 All Nmap tips (12) All topics

Link