Forward a port to an internal host (DNAT)

Destination NAT for incoming traffic to a backend. Add an accept rule in the forward chain too

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

tool
nftables12 commands
tags
nftablesnetworkcloudfirewall

More nftables commands

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

    Slows down SSH brute force. Packets over the limit go on to the chain policy

  • nft monitor ruleset

    Prints add and delete events as they happen. Useful for debugging dynamic rules

  • nft list ruleset > /etc/nftables.conf && nft -f /etc/nftables.conf

    nft -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 @ft

    Moves established flows to the fast path. Add flags offload for hardware offload on the NIC

  • nft add chain inet filter input '{ type filter hook input priority 0 ; policy drop ; }'

    Base chain that denies everything by default. Note: add accept rules first, or you will lock yourself out

all 12 nftables commands