List ruleset with rule handles

-a prints '# handle N' per rule; you need the handle to delete a single rule

nft -a list ruleset

tool
nftables12 commands
tags
nftablestroubleshootingnetwork

More nftables commands

  • nft delete rule inet filter input handle 7

    Surgical removal without flushing; get the handle from nft -a list ruleset

  • nft add rule inet filter input tcp dport 22 counter accept comment \"ssh\"

    Inline counter tracks packets/bytes; reset with nft reset counters inet filter

  • nft add rule ip nat postrouting oifname \"eth0\" masquerade

    Source-NAT egress to the iface IP; needs a nat-type postrouting chain to exist

  • nft add rule ip nat prerouting iif \"eth0\" tcp dport 443 dnat to 10.0.0.5:8443

    Destination-NAT inbound to a backend; pair with a forward-chain accept rule

  • nft add rule inet filter input tcp dport 22 ct state new limit rate 10/minute accept

    Throttle SSH brute-force; over-limit packets fall through to the chain policy

all 12 nftables commands