basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    Firewall outside and inside: DROP on the internet, REJECT on the LAN

    DROP silently discards the packet and leaves the client hanging until timeout, while REJECT sends an immediate refusal (RST or ICMP Administratively Prohibited). Use DROP on external internet interfaces and REJECT inside your own network and between services so misconfigurations fail fast instead of freezing apps for tens of seconds.

    What the client sees

    When a firewall runs DROP, it sends nothing back. The client cannot tell a silent drop apart from an unplugged cable, so it retries SYN with exponential backoff (1 s, 2 s, 4 s, 8 s…): with Linux’s default net.ipv4.tcp_syn_retries = 6, the attempt stalls for roughly two minutes before failing with Connection timed out (TCP: flags and states).

    When a firewall runs REJECT, it replies right away:

    • for TCP (with reject with tcp reset) — a packet with the RST flag, giving the client Connection refused in a millisecond;
    • for other protocols or by default (reject with icmpx type admin-prohibited) — ICMP Type 3 Code 13, giving the client an immediate No route to host or Connection refused.
    Where the rule sits What to pick Why
    VPS external interface, router WAN DROP Avoids spending egress bandwidth answering mass scanners and prevents ICMP reflection abuse
    LAN, VLAN, VPN between servers REJECT Clients and monitoring fail immediately instead of stalling a worker for 20–120 s
    Suspicious or banned external IP DROP In CrowdSec and blocklists, DROP slows brute-force scans and gives bots zero feedback

    In nftables, both actions take a single line at the chain policy or rule level (nftables):

    # External chain — drop silently:
    policy drop;
    
    # Internal network — refuse right away:
    ip saddr 10.0.0.0/24 tcp dport 5432 reject with tcp reset
    ip saddr 10.0.0.0/24 reject with icmpx type admin-prohibited

    How to check

    Compare response time in nc and packet behavior in tcpdump:

    time nc -zv -w 3 203.0.113.10 8080
    # With REJECT — fails in milliseconds:
    # nc: connect to 203.0.113.10 port 8080 (tcp) failed: Connection refused
    # With DROP — waits the full 3 seconds from -w 3:
    # nc: connect to 203.0.113.10 port 8080 (tcp) timed out: Operation now in progress

    In sudo tcpdump -nn 'host 203.0.113.10 and port 8080', DROP shows only repeated Flags [S] packets, while REJECT shows Flags [R.] or ICMP ... admin prohibited straight after the first Flags [S].

    Also in this chapter