I have set up a DNAT UDP port forward from a L2TP VPN tunnel to the LAN zone.
config redirect '29'
option src_dport '51820'
option dest_ip '192.168.21.2'
option name 'WireGuard'
option target 'DNAT'
option priority '1'
option dest 'lan'
option enabled '1'
list proto 'udp'
option src 'vpn'
The problem is the return packets go down the WAN interface and not the VPN interface
root@remote:~# tcpdump -i any port 51820
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
12:28:12.551954 l2tp-VPN In IP 31.94.72.223.45647 > 40.71.52.25.in-addr.arpa.51820: UDP, length 148
12:28:12.552140 br-lan Out IP 31.94.72.223.45647 > gateway-pro.lan.51820: UDP, length 148
12:28:12.552170 eth0 Out IP 31.94.72.223.45647 > gateway-pro.lan.51820: UDP, length 148
12:28:12.553929 eth0 In IP gateway-pro.lan.51820 > 31.94.72.223.45647: UDP, length 92
12:28:12.553929 br-lan In IP gateway-pro.lan.51820 > 31.94.72.223.45647: UDP, length 92
12:28:12.554900 rmnet_data0 Out IP 40.71.52.25.in-addr.arpa.51820 > 31.94.72.223.45647: UDP, length 92
Probably because the default route is via the WAN and return packets will use the default route.
So make a return route back via the VPN interface.
If it all comes from one IP address (the VPNs adddress) you can just use that otherwise you have to use Policy Based routing to make a table and rules.
The problem seems to be that it looks like the routing rules are applied and the source IP at this point is a LAN ip. Then the DNAT changes the src ip and the interface is already chosen.
Sorry I made a mistake I corrected to but it does not make a difference. The problem is I am struggling to identify the packets for the VPN since it looks like the src ip is rewritten after the routing decision is made.
config rule
# for ip destination
option src '25.52.71.40/32'
# for interface
#option in 'vpn'
option lookup '1'
Closing this thread because the firmware on the device is not from the official OpenWrt project. The OP will need to ask the maintainers/providers of the firmware that is running on that device.