Community discussions

MikroTik App
 
baxenko
just joined
Topic Author
Posts: 5
Joined: Tue Sep 20, 2016 6:08 pm

netwatch for two IPs

Mon May 23, 2022 4:08 pm

Hello. Unfortunately netwatch in Mikrotik can only ping one IP address. Therefore, I ask for help to write a script that will allow you to ping two IP addresses. If at least one of them is available, then disable the IP, if both are not available, then enable the IP.

I tried to do it but it doesn't work.
:local ipone "10.10.1.254";
:local iptwo "10.10.1.8";
:local pingsofone [ping $ipone count=3];
:local pingsoftwo [ping $iptwo count=3];
if (($pingsofone<1)&&($pingsoftwo<1)) do={/ip address enable [find comment="rezerv"];};
if (($pingsofone>1)||($pingsoftwo>1)) do={/ip address disable [find comment="rezerv"]}
Last edited by baxenko on Mon May 23, 2022 7:53 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: netwatch for two IPs  [SOLVED]

Mon May 23, 2022 4:50 pm

if (($pingsofone<1)&&($pingsoftwo<1)
) ???

"if if" ?

ip address enabled [find comment=rezerv]
enabled ???

ip address disabled [find comment=rezerv]
disabled ???


You can not create script putting random words at random randomness...



{

:local ipone 10.10.1.254
:local iptwo 10.10.1.8
:local pingsofone [ping $ipone count=3]
:local pingsoftwo [ping $iptwo count=3]
:if ( ($pingsofone < 1) and ($pingsoftwo < 1) ) do={ 
    /ip address  enable [find where comment="rezerv"]
}
:if ( ($pingsofone > 1) or  ($pingsoftwo > 1) ) do={
    /ip address disable [find where comment="rezerv"]
}

}
 
baxenko
just joined
Topic Author
Posts: 5
Joined: Tue Sep 20, 2016 6:08 pm

Re: netwatch for two IPs

Mon May 23, 2022 7:52 pm

there was a copy error
:local ipone "10.10.1.254";
:local iptwo "10.10.1.8";
:local pingsofone [ping $ipone count=3];
:local pingsoftwo [ping $iptwo count=3];
if (($pingsofone<1)&&($pingsoftwo<1)) do={/ip address enable [find comment="rezerv"];};
if (($pingsofone>1)||($pingsoftwo>1)) do={/ip address disable [find comment="rezerv"]}
ty, Slava Ukraine!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: netwatch for two IPs

Mon May 23, 2022 10:01 pm

ty, Slava Ukraine!
😢🩸

Who is online

Users browsing this forum: No registered users and 18 guests