Compared
DROP vs REJECT
DROP throws the packet away and says nothing, so the client waits until it times out. REJECT throws it away and answers at once, with an ICMP error or a TCP reset, so the client fails immediately with connection refused.
Side by side
| DROP | REJECT | |
|---|---|---|
| The sender gets | Nothing | ICMP port unreachable by default; a TCP reset with --reject-with tcp-reset |
| The client sees | Connection timed out, after waiting | Connection refused, at once |
| nmap reports | filtered | closed when the answer is a TCP reset; filtered when it is an ICMP error |
| Gives away | Little: silence only hints at a firewall | An ICMP error carries the address of the device that sent it |
| For real users | Every mistake costs a timeout | A mistake fails fast |
| iptables | -j DROP | -j REJECT, or -j REJECT --reject-with tcp-reset |
Each one explained
- Drop or reject
- Two ways to refuse a packet: silence, or an explicit answer.
- Firewall
- Rules deciding, packet by packet, what may reach or cross a device.
- TCP reset
- A TCP packet that aborts a connection; the answer to a SYN for a port with no listener.
- ICMP
- The network's messages about packets: echo for ping, unreachable, time exceeded, too big.
See the difference on real machines
Each lab is a small network of real Linux machines in your browser.
- Firewall rules: keep the street out and let the staff in
- What's listening? Tell a refused port from a blocked one, and find who holds it
Open Firewall rules: keep the street out and let the staff in