What is the difference between DROP and REJECT in iptables? Which is better to use from a security perspective?
sobes.tech AI
Answer from AI
In iptables, DROP and REJECT are two ways to block packets, but with different behaviors:
-
DROP — simply silently discards the packet, meaning the packet is discarded without notifying the sender. The sender does not receive any response and may wait for a timeout.
-
REJECT — discards the packet and sends back an ICMP error message (e.g., "port unreachable"), informing the sender that the packet has been rejected.
From a security perspective, DROP is considered more secure because it does not reveal information about the presence or absence of a service on the host. REJECT can help in diagnostics but potentially gives an attacker information about the network status.
Therefore, for public services and when it is necessary to hide the presence of a host, it is better to use DROP, and for internal networks or debugging — REJECT.