~kris/dots

srice

ref: a4bfa48cdda924f7a77a81e8d8e93e326a01b8a0 srice/doc/networking/host-hardening/nftables.md -rw-r--r-- 1.6 KiB
a4bfa48c — Kris Yotam mksh: reliable history hook via HISTFILE growth + binary record parse 2 months ago

#nftables

Replaces iptables. Use for all new Linux deployments.

#Default Deny Configuration

table inet filter {
    chain input {
        type filter hook input priority 0; policy drop;
        ct state established,related accept
        iif lo accept
        # specific allow rules here
    }
    chain forward {
        type filter hook forward priority 0; policy drop;
    }
    chain output {
        type filter hook output priority 0; policy drop;
        ct state established,related accept
        # explicit egress rules here
    }
}

Egress filtering on output is critical and almost universally neglected. Malware, data exfil, and C2 all depend on unrestricted outbound access. Whitelist only ports/destinations your system actually needs.

#Key Concepts

  • Stateful inspection: ct state established,related
  • Sets and maps: efficient matching against large lists
  • Deep packet inspection: Layer 7 content inspection
  • Geo-IP blocking: via sets with IP ranges
  • Rate limiting: per-address connection limits
  • Connection tracking: ct state tracking

#References