The br-lan interface ipv6 address changes dynamically. It runs a service with port 3306 on it. The traffic incoming from the wan interface uses port 13306 forwarding 3306 to access this service. On the old version of fw3 ip6tables, the requirements can be achieved by adding the following settings in /etc/firewall.user:
Try adding the following rules to the /etc/config/firewall file on the new version of fw4 nft. It seems to work properly, but adding option dest_ip '::2a51:70/-96' after qualifying the target address suffix. Section @redirect[1] must not use non-contiguous masks in 'dest_ip', it seems that suffix matching is not supported
/etc/config/firewall
config redirect
option dest 'lan'
option target 'DNAT'
option family 'ipv6'
option src 'wan'
option src_dport '13306'
option dest_port '3306'
option reflection '0'
# option dest_ip '::2a51:70/-96'
option proto 'tcp'
So how to implement this requirement on the new version of fw4 nft, and how to dynamically update the br-lan address after the change?
The problem seems to be the fw4 redirect rule. The destination address suffix matching (negative mask) is not supported. option dest_ip '::2a51:70/-96'option dest_ip '::2a51:70/::ffff:ffff' Both prompts: "Section @redirect[1] must not use non-contiguous masks in 'dest_ip'"
Add to /etc/nftables.d/10-custom-filter-chains.nft file to achieve requirements
The problem of changing option dest_ip to option src_dip can also be solved. So many similar options are too easy to confuse. I hope the official document can describe the differences in the relevant options in detail.
Maybe not applicable for your situation but this is how I solved the IPv6 "port forwarding" , I use quotes because ti is not a port forwarding but a port opening !
For IPv6 where your br-lan or other clients have a GUA address there is no need to port forward. You just simply open a port and use a negative netmask to overcome changing prefixes.
An example, for my WireGuard and OpenVPN server I have added a static IPv6 address:
config host
option dns '1'
option name 'EA8500'
option ip '192.168.0.6'
option leasetime '6h'
option duid '00030001c056274533db'
option hostid '06' #IPv6 hostid: prefix::6
list mac 'C0:56:27:45:33:DB'
This will get my server an IPv6 address as prefix::6
Then I open up the necessary port on my firewall
config rule
option name 'wg-server6-6'
list proto 'udp'
option src 'wan'
option dest 'lan'
option dest_port '55443'
option target 'ACCEPT'
option family 'ipv6'
list dest_ip '::6/-64' #<<< negative netmask
Yes that is the same for me, my PD changes after a reboot but with the negative netmask the prefix is left out of the equation so it works regardless what prefix is delegated.