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'