Where tcpdump sits on the packet path
tcpdump listens on an interface via an AF_PACKET raw socket right at the NIC driver boundary, while the firewall (nftables, iptables, ufw) runs deeper inside netfilter hooks (full stack diagram in Linux network stack):
Inbound traffic:
NIC / veth ──► [AF_PACKET: tcpdump sees it HERE] ──► prerouting ──► input / forward (drop!) ──► app
Outbound traffic:
app ──► output (drop!) ──► postrouting (SNAT) ──► [AF_PACKET: tcpdump sees it HERE] ──► NIC / veth
Two rules follow directly when reading any capture:
| Direction | What happens to a firewall drop |
What tcpdump shows |
|---|---|---|
Inbound (input / forward) |
Firewall drops the packet after capture | Inbound SYN appears, no SYN-ACK or RST reply |
Outbound (output) |
Firewall drops the packet before capture | Complete silence, even though the process is sending packets |
The same diagram explains NAT. On the external eth0, an inbound frame appears before DNAT (showing the host’s external IP, not the Docker container IP), while an outbound frame appears after SNAT (already carrying the rewritten external source address).
Checking whether the firewall is dropping traffic
When a capture shows repeated inbound Flags [S] with no reply, check nftables counters before restarting the application:
# List all rules and packet counters (look for counter packets > 0 next to drop):
sudo nft list ruleset
# For containers with published ports, inspect the forward chain specifically:
sudo nft list chain inet filter forward 2>/dev/null || sudo nft list ruleset | grep -n -C 5 'hook forward'
If a drop rule counter ticks up in step with connection attempts, the firewall is dropping the packets and they never reach the application socket.
If it doesn’t work
Inbound SYN packets from a client appear in tcpdump -nn -i eth0, yet the app never sees them and the client times out
- Cause
AF_PACKETcaptured the frame on ingress at the NIC, and adroprule innftablesorufwdiscarded it right after.- Fix
- Check rules and
dropcounters in theinputandforwardchains:sudo nft list ruleset.
A script on the server sends outbound requests and times out, while tcpdump -nn -i eth0 shows nothing
- Cause
- On the outbound path, the
outputhook runs beforeAF_PACKET: the firewall dropped the packet or routing failed before it reached the NIC driver. - Fix
- Check the
outputchain insudo nft list rulesetand verify routing withip route get <IP>.
How to check
Capture on eth0 for a port blocked by a drop rule in input, then connect from another machine with nc -zv -w 2 <IP> <port>: tcpdump logs incoming Flags [S] with no reply, and the drop rule counter in sudo nft list ruleset increases by the exact number of those SYN packets.