Validate Network Segmentation with Nmap
An asset-discovery scan asks which systems and services exist. A segmentation check asks whether a specific source zone can reach only the destination ports its policy permits. Compare results from approved test points against a written access matrix, then correlate unexpected results with firewall logs.
Define Source, Destination, and Allowed Ports
ScopeBefore scanning, list the exact source test host, destination host, protocol, and expected result for each path. Use RFC documentation addresses in notes only; replace the example target in commands with an approved lab or organization address before running them.
Source zone Destination Ports ExpectedApp-Test App-Server TCP 443 AllowedUser-Test App-Server TCP 443 DeniedUser-Test App-Server TCP 22 DeniedExample target 192.0.2.25 Documentation-only; do not scan❯ Illustrative Output (Results Vary)
Approved by: [network owner]Window: [date/time]Escalation contact: [name/team]Check the Scanner Before Sending Probes
PreflightRun Nmap from a host actually located in the source zone being tested. Confirm the scanner IP and route with the network owner, check Nmap is installed, and create a protected results directory. A test from the wrong VLAN does not validate the intended firewall path.
nmap --versionip addressip routeumask 077# Reserve a new private directory; do not overwrite an earlier scan's evidence.mkdir -m 700 results || { echo 'Results directory already exists; choose a fresh path.' >&2; exit 1; }❯ Illustrative Output (Results Vary)
Scanner address and source zone match the approved test plan.Run a Limited TCP Connect Scan
Controlled ScanReplace the documentation-only target with the exact approved host. This command disables DNS lookups and host discovery, uses a TCP connect scan, limits probes to ports 22 and 443, and saves normal, XML, and grepable output. It does not run vulnerability scripts or scan a subnet.
TARGET='192.0.2.25' # Replace only with the approved test host.nmap -n -Pn -sT -p 22,443 --reason -oA results/app-from-user-test "$TARGET"❯ Illustrative Output (Results Vary)
PORT STATE SERVICE REASON22/tcp filtered ssh no-response443/tcp filtered https no-responseExample only; the target and path determine actual results.Compare Results with the Written Policy
Compare PathsRun the same limited scan from each authorized source test point, using a distinct output basename for each one. Here, run the second command from the approved App-Test host after setting TARGET to the approved App-Server address. Compare each observed state with the matrix. open means a TCP connection was accepted, closed means the host responded but no application was listening, and filtered means Nmap could not determine the state because probes were filtered or unanswered.
nmap -n -Pn -sT -p 22,443 --reason -oA results/app-from-app-test "$TARGET"grep -E '22/tcp|443/tcp' results/app-from-user-test.nmapgrep -E '22/tcp|443/tcp' results/app-from-app-test.nmap❯ Illustrative Output (Results Vary)
App-Test -> TCP 443: open (expected allowed)User-Test -> TCP 443: filtered (expected denied)User-Test -> TCP 22: filtered (expected denied)Correlate Scan Results with Firewall Logs
EvidenceA filtered result alone does not prove a firewall rule blocked the traffic; packet loss, routing, host firewalls, and scanner placement can produce similar observations. Compare Nmap timestamps with firewall logs and service health checks. Escalate unexpected open ports or unexpected outages to the owners before changing policy.
Nmap XML: results/app-from-user-test.xmlNmap normal output: results/app-from-user-test.nmapChange ticket: [approved test or incident reference]Firewall log correlation: [timestamp and rule]❯ Illustrative Output (Results Vary)
Result: pass / fail / inconclusive for each source-destination-port tupleFollow-up: owner and ticket for every unexpected result