How to implement network forwarding in openwrt 22.03.5?

I implemented it through iptables in openwrt 21. How can I implement it through nftables in openwrt 22?

iptables -t nat -A PREROUTING -i tun0 -p tcp -j DNAT --to 192.168.100.234:1080
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

You can use nftables-translate to convert any rule:

You could also use OpenWrt's UCI syntax and then there's no need to translate rules:

config zone                                       
        option name 'tun0'                   
        option forward 'DROP'                   
        option output 'ACCEPT'                 
        option input 'DROP'                  
        option mtu_fix '1'                      
        option network 'tun0'
        option masq '1'

config redirect                                 
        option target 'DNAT'                                            
        option src 'tun0'                        
        option src_dport '1080'                
        option dest_port '1080'                
        option dest_ip '192.168.100.234'         
        option reflection '0'
        list proto 'tcp'                       
        list proto 'udp' 

EDIT: SRC must be specified as tun0 - as OP's rule.

1 Like