Masquerade outgoing traffic (SNAT)
Source NAT for outgoing traffic to the interface IP. Needs an existing postrouting chain of type nat
nft add rule ip nat postrouting oifname \"eth0\" masquerade
- tool
- nftables12 commands
More nftables commands
-
nft add rule ip nat prerouting iif \"eth0\" tcp dport 443 dnat to 10.0.0.5:8443Destination NAT for incoming traffic to a backend. Add an accept rule in the forward chain too
-
nft add rule inet filter input tcp dport 22 ct state new limit rate 10/minute acceptSlows down SSH brute force. Packets over the limit go on to the chain policy
-
nft monitor rulesetPrints add and delete events as they happen. Useful for debugging dynamic rules
-
nft list ruleset > /etc/nftables.conf && nft -f /etc/nftables.confnft -f applies the whole file atomically. If something fails, nothing is applied, so there is no half-applied state
-
nft add flowtable inet filter ft '{ hook ingress priority 0 ; devices = { eth0, eth1 } ; }' && nft add rule inet filter forward ct state established flow add @ftMoves established flows to the fast path. Add flags offload for hardware offload on the NIC