firewall configuration in Mikrotik

good day, to all

please I need your help, in the situation that I found myself into, and I need your assistance please???

automatically enables Firewall Rules in Mikrotik if it cannot ping a partilucar IP??

Example: if IP address 192.168.0.1 goes down, the script needs to then disable 2 NAT rules and then enable 2 others ??

i really need help and I’m grateful.

Step 1: Trigger
You can use “Scheduler” or “Netwatch” to trigger Scripts.

Step 2: Script A (IP-Online)
The quick and easy way is to use “comment” to find the correct NAT-Rules
After Creating the needed NAT-Rules simply add a unique string to you comments.
In the following exemple the comment must contain “abcdef” or “123456”

/ip firewall nat set [find where comment~"abcdef"] disabled=yes
/ip firewall nat set [find where comment~"123456"] disabled=no

Step 3: Script B (IP-Offline)
For Script B you just have to do the reverse

/ip firewall nat set [find where comment~"abcdef"] disabled=no
/ip firewall nat set [find where comment~"123456"] disabled=yes

Right, but I prefer this syntax:

/ip firewall nat disable [find where comment~"abcdef"]
/ip firewall nat enable [find where comment~"123456"]

# or better

/ip firewall nat
disable [find where comment~"abcdef"]
enable [find where comment~"123456"]

As always, thank you @rextended !