- Create a table named nat with the ip address family:
- Add the prerouting and postrouting chains to the table:
nft -- add chain ip nat prerouting { type nat hook prerouting priority -100 \; }
nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; }
- Add a rule to the prerouting chain that redirects incoming packets on port 443 to the same port on 192.0.2.1:
nft add rule ip nat prerouting tcp dport 443 dnat to 192.0.2.1
- Add a rule to the postrouting chain to masquerade outgoing traffic:
nft add rule ip nat postrouting masquerade
- Enable packet forwarding:
echo 1 > /proc/sys/net/ipv4/ip_forward
Using freeze to relocate a Debian-installed
nft
binary to GoNix: