/ip firewall nat set 4,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 dst-address=[:resolve example.homeip.net]
I have a a bunch of firewall rules that need to update when the IP address changes or when failover occurs.
That rule is supposed to get the current IP of the system then plug the IP into the dts-address of rules 4,10-28. This is so internal devices can reach devices that are port forwarded from the WAN. (IP cameras with the iPad can use the same address from inside or outside the network.)
In place of literally putting the numbers, you can use the “find” command, to grab any matching rules, like:
/ip firewall nat set [/ip firewall nat find where dst-address=$oldIp] dst-address=[:resolve example.homeip.net]
(assuming the rules are actually matched by this criteria)
This has a (negligible!) performance penalty, since all firewall rules need to be verified by “find”, before they are included as part of the “set” command. However, this way is a lot more maintainable, since you can move and add firewall rules around freely, and always know what’s expected to be matched, and what not.