OpenWrt 22.03 - migrate 1:1 nat from iptables to nftables

Hi there,
I am running my OpenWrt Router as an OpenVPN Client in a VPN site-to-site setup. After Upgrading to newest OpenWrt 22.03 I have to migrate my firewall coustom rules to nftables. Can you help me finding the nft-file for this:

  • /usr/sbin/iptables -t nat -I PREROUTING -i tun+ -d 10.2.1.0/24 -j NETMAP --to 192.168.1.0/24
  • /usr/sbin/iptables -t nat -I POSTROUTING -o tun+ -s 192.168.1.0/24 -j NETMAP --to 10.2.1.0/24

What should the nft-file look like?

table ip nat {
	chain prerouting {
		type filter hook prerouting priority 0; policy accept;
		ip saddr 10.2.1.0/24 dnat 192.168.1.0/24
	}

	chain postrouting {
		type filter hook postrouting priority 100; policy accept;
		ip saddr 192.168.1.0/24 snat 10.2.1.0/24
	}
}
1 Like