Load the saved nftables configuration using the nft command:
nft -f /etc/nftables.conf
Filter for SSH Traffic (Example)
Rules
Host A:
nft add table ip FILTER
nft add chain ip FILTER INPUT { type filter hook input priority 0 \; policy accept \;}
nft add chain ip FILTER OUTPUT { type filter hook output priority 0 \; policy accept \;}
Host B:
nft add table ip FILTER
nft add chain ip FILTER INPUT { type filter hook input priority 0 \; policy accept \;}
nft add chain ip FILTER OUTPUT { type filter hook output priority 0 \; policy accept \;}
Host A:
nft add rule ip FILTER OUTPUT tcp dport 22 ct state { new, established } accept
nft add rule ip FILTER INPUT tcp sport 22 ct state { new, established } accept
Host B:
nft add rule ip FILTER INPUT tcp dport 22 ct state { new, established } accept
nft add rule ip FILTER OUTPUT tcp sport 22 ct state { new, established } accept
Host A:
nft add rule ip FILTER INPUT tcp dport 22 ct state { new, established } accept
nft add rule ip FILTER OUTPUT tcp sport 22 ct state { new, established } accept
Host B:
nft add rule ip FILTER OUTPUT tcp dport 22 ct state { new, established } accept
nft add rule ip FILTER INPUT tcp sport 22 ct state { new, established } accept
Host A:
nft add chain ip FILTER INPUT { \; policy drop \;}
nft add chain ip FILTER OUTPUT { \; policy drop \;}
Host B:
nft add chain ip FILTER INPUT { \; policy drop \;}
nft add chain ip FILTER OUTPUT { \; policy drop \;}
NAT, PAT, and NAT Port Forwarding (Examples)
Enable IP Forwarding:
Iecho 1 > /proc/sys/net/ipv4/ip_forward
nft add table ip NAT
nft add chain ip NAT PREROUTING { type nat hook prerouting priority 0 \; }
nft add chain ip NAT POSTROUTING { type nat hook postrouting priority 0 \; }
1-to-1 NAT (for the servers if you have extra IP's)
nft add rule ip NAT POSTROUTING oif eth0 ip saddr 10.0.0.10 snat to 100.1.1.10
nft add rule ip NAT POSTROUTING oif eth0 ip saddr 10.0.0.11 snat to 100.1.1.11
nft add rule ip NAT POSTROUTING oif eth0 ip saddr 10.0.0.12 snat to 100.1.1.12
PAT (for the clients)
nft add rule ip NAT POSTROUTING oif eth0 masquerade
Port Forward (for the servers if you don't have extra IP's)
nft add rule ip NAT PREROUTING iif eth0 tcp dport 80 dnat to 10.0.0.10:80
nft add rule ip NAT PREROUTING iif eth0 tcp dport 21 dnat to 10.0.0.11:21
nft add rule ip NAT PREROUTING iif eth0 tcp dport 23 dnat to 10.0.0.12:23