By Ashishh Jha, Head of Cyber Security Services, Bluefire Redteam — 12+ years in offensive security
Remote Internal Pentest Series · 2 of 6
nmap -e <iface> -S <ip> looks like the right command for a source-bound segmentation test. It isn’t. Here’s how it silently lies, and the one-line fix that saves your report.
On a multi-homed test host, nmap -e <iface> -S <ip> uses raw packet injection that bypasses the Linux kernel’s policy routing, so packets leave with a source IP the kernel never approved and the firewall drops them — producing false “blocked” results. The reliable method is source-bound sockets (nc -s), which honor kernel routing, verified every time with tcpdump.
TL;DR — On a multi-homed test host, nmap -e <iface> -S <ip> uses raw packet injection and bypasses the kernel’s policy routing. Packets leave the named interface with a source IP the kernel never approved — and the firewall often drops them, or the return path is broken. You get false “blocked” results everywhere. Source-bound sockets via nc -s honor the kernel. Verify with tcpdump every time.
Three years ago we would have told you this is a solved problem. It isn’t — it bites experienced operators often enough that it cost us two days of methodology correction on a recent engagement, and it’s almost certainly invalidating segmentation sections in reports being delivered this week.
The setup
You have a jumpbox with interfaces on multiple in-scope VLANs — call them VLAN 500 (user, 192.168.1.230) and VLAN 42 (management, 10.16.42.230, hypothetically present as a sub-interface for admin). You want to answer: “From a user on VLAN 500, can I reach a service in VLAN 42?”
You reach for the obvious:
sudo nmap -Pn -e eth3 -S 192.168.1.230 -p 22,80,443 10.16.42.50
The output comes back clean — filtered, closed, blocked. You note it in the report as a PASS for segmentation. Ship it.
It’s wrong.
Why it’s wrong
The -e and -S flags in nmap enable raw socket mode. Nmap crafts the TCP packet itself — with the source IP you specified — and injects it directly out the named interface. It bypasses the Linux kernel’s routing table entirely. The packet leaves eth3, but the kernel never populated an ARP entry for the destination gateway because the kernel never routed anything to 10.16.42.50 from source 192.168.1.230.
Three failure modes follow:
- The packet leaves with the wrong L2 destination MAC (because nmap’s ARP cache doesn’t know the VLAN 500 gateway’s MAC, so it uses a default or stale entry).
- Even if the outbound makes it to the firewall, the return path tries to reach 192.168.1.230 — which is on the jumpbox, but on a different interface. Linux’s reverse path filter (
rp_filter=1) drops it. - You see nothing back and conclude “blocked by firewall.” The firewall never saw the packet, or rejected it as spoofed. Your conclusion is wrong on both counts.
The really evil part: this mode produces plausible output. “Filtered” is the exact result you’d expect from a correctly-blocking firewall. You will not notice the error unless you packet-capture both directions and compare to a known-live same-segment baseline.
The fix
Use source-bound sockets. nc -s binds the TCP socket to a source IP via the kernel’s socket API, which triggers the policy routing lookup (assuming you set the policy routing up — see internal pentest infrastructure), uses the correct outbound interface and gateway MAC, and lets the kernel handle the return path cleanly.
# The right way:
nc -s 192.168.1.230 -w3 -zv 10.16.42.50 22
# Connection to 10.16.42.50 22 port [tcp/ssh] succeeded!
# Now the firewall truly saw a packet sourced from a VLAN 500
# host, routed it per policy, and the service responded.
# THIS is a valid segmentation test result.
For a sweep across multiple destinations, wrap it in a shell loop. For a full matrix, scripting against ip -br addr to pull your available source IPs is a 20-line bash job.
Validate every time
The habit that will save you is packet-capture validation on the first test of each new jumpbox-to-segment pairing. In one terminal:
sudo tcpdump -eni eth3 -c 4 'host 10.16.42.50 and port 22'
In another, fire the nc. You should see:
- An outbound SYN from 192.168.1.230 with destination MAC equal to the VLAN 500 gateway’s MAC.
- An inbound SYN-ACK from 10.16.42.50 with source MAC equal to the VLAN 500 gateway’s MAC — because the return packet was routed back by the gateway, not L2-forwarded from the destination host.
Then ip neigh show <gateway-ip> confirms that gateway MAC. Side-by-side screenshot in your evidence folder. This is the forensic proof that the firewall genuinely routed the traffic — not a jumpbox interface shortcut, not a raw socket faking it, not a routing loop.
Classic misread. If your tcpdump shows SYN leaving but no reply, don’t conclude “firewall silent-drop” until you’ve checked the reverse-path filter on both ends and run the test from a known-good source (e.g., same-segment baseline). The correct conclusion from “SYN out, no reply, baseline works” is “firewall actively dropped.” The correct conclusion from “SYN out, no reply, baseline also silent” is “your setup is broken.” This is exactly how a firewall drift finding stays hidden when the method is wrong.
Takeaway for buyers. Ask your pentester how they validate the direction of a segmentation test. If they say “we ran nmap with -S”, your report’s segmentation section may be unreliable. If they volunteer “we source-bind and verify with tcpdump”, they know what they’re doing. Our internal network penetration testing uses source-bound, packet-capture-validated segmentation testing on every engagement.
FAQ - Segmentation Testing
- Does nmap -S work for segmentation testing?Not reliably on a multi-homed host. The -e/-S raw-socket mode bypasses kernel policy routing, so packets leave with an unapproved source IP and are dropped, producing false "blocked" results.
- What is the correct way to test network segmentation?Use source-bound sockets (
nc -s <source-ip>), which trigger the kernel's policy-routing lookup and use the correct interface and gateway, then verify direction with tcpdump. - Why does nmap -S return "filtered" when the firewall never saw the packet?Because raw injection with an unrouted source can fail at L2 or be reverse-path-filtered, and nmap reports "filtered" — the same output a real block produces. Only packet capture tells them apart.
- How do you validate a segmentation test is real?Run tcpdump on the source interface: a valid test shows the SYN leaving with the segment gateway's MAC and the SYN-ACK returning via that gateway.
Want this run against your network, remotely, with proof? Get a scoped internal network penetration testing quote in 5 hours. Grab the Internal Network Pentest Checklist first.
Remote Internal Pentest Series — how Bluefire Redteam runs a modern internal engagement:
- Internal Pentest Infrastructure
- The nmap Segmentation Trap (you are here)
- Firewall Drift
- Wireless Architecture Testing
- Non-Destructive Proof
- Engagement Rhythm