How to do NAT loopback with a dynamic WAN address

I run a application closed source server that returns my WAN IP to connect to to my client. Every 24h I have to update my Firewall rule which does forward requests from my LAN to my WAN IP after it did change.
How can I write my firewall forward in a way that it always takes the IP from my WAN address so I don't have to update manually?
Current settings

1 Like

Thanks for the Answer but I'm not sure how restarting the firewall will help?
I would need to restart at a IP change, they disconnect me after 24 hours or if they do maintainance at time x and from that the 24 hours will start. Also I'm not sure how to get the IP to update anything in the first place.

cat << "EOF" > /etc/udhcpc.user
case "${1}" in
(bound|renew) /etc/init.d/firewall restart ;;
1 Like

Thank you
now i only need to know how to update that firewall rule with the new IP. I have done this via luci until now, so I'm not sure how to do this in a script.
What currently is generated by luci

config redirect
option target 'DNAT'
option name 'nat loopback'
option src 'lan'
option src_dport '50000-50010'
option dest_ip 'my servers internal ip'
option dest_port '50000-50010'
option dest 'appname'
option src_dip 'my external ip'

uci set firewall.@redirect[0].src_dip="wan"
uci set firewall.@redirect[0].reflection_src="external"
uci commit firewall
/etc/init.d/firewall restart

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.