Simple Script Help.

I am trying to learn script.

Can someone show me how i would do a simple script. To ping an ip address and if no reply shutdown gateways

0 A S ;;; Cable
0.0.0.0/0 reachable 192.168.0.1 1 ether1
1 S ;;; Telefonica
0.0.0.0/0 reachable 192.168.9.10 2 ether2
2 ADC 192.168.0.0/24 192.168.0.251 0 ether1
3 ADC 192.168.9.0/24 192.168.9.100 0 ether2

I want to setup a ping from both ethers to the modem gateways, if the is no ping it turns off the gateway and turns on the other gatweay

/ip route disable 0 or /ip route disable 1 would be a good starting point how to turn things on and off etc.

I have looked at the Wiki and just trying to get an understanding of what i think would be a basic script.

Can any advise me.

:if ( [/ping xx.xx.xx.xx count=5] < 5 ) do={ 
      /ip route disable [ find gateway="yy.yy.yy.yy" ] ;
}

in “routes” you can specify “check-gateway” which is meant exactly for this purpose

Thank you very much.

I get that part now, how could you get up that the ping would go though a ethernet lan of your choice.

Say i wanted to ping the modems gateway though the ethernet card which it is connected to and not from the other LANs.

How would that work?

rednetwifi -

For getting a ping to go out a specific port you’d need to use policy routing…

Typically you would use mangle to mark the connection, use the connection mark to add a routing mark. Then over in /ip routes you need to add two things… One, a route in a named route table for your intended now marked route, two, over in /ip route rules you need to add a rule to send the datagram that has been marked with your routing mark to the named route table you just created…

Remember the order (the number on the left hand side or mangle / routes / rules / or just about anything in ROS) is important…if something matches the datagram BEFORE the rule you intended it to match then the first one gets excuted - it will never see the second rule…

R/
Thom