Script to change pptp remote server ip

Hello. How can I do script, that will be change IP address on pptp-client settings (“Connect to”)
For example I have pptp-client “pptp-out1” on Mikrotik. It connects to server with IP 231.231.231.1 and 231.231.231.2
If IP 231.231.231.1 become unavailable then script changes this IP to 231.231.231.2 and connect to 231.231.231.2
Then when IP 231.231.231.1 comes online Mikrotik change it back in ppptp-client.

I make search for similair script and I think it will be something like that:


:if (/ping 231.231.231.1 interface=vlan1 interval=1 count=0) do={
:log warning “Set pptp IP to backup ISP”;
/interface pptp-client set pptp-out1 connect-to=231.231.231.2
}

:if (/ping 231.231.231.1 interface=vlan1 interval=1 count=3) do={
:log warning “Set pptp IP to main ISP”;
/interface pptp-client set pptp-out1 connect-to=231.231.231.1
}

and run it every 1 minute


Thanks!

Simply do 2 connection and use one at time with route check=ping distance=1 and 2