Community discussions

MikroTik App
 
cillininfo
just joined
Topic Author
Posts: 16
Joined: Thu Apr 23, 2020 11:09 am

I need a script to determine if the pppoe-out1 state is connected

Wed Apr 07, 2021 5:53 pm

I need a script to determine if the pppoe-out1 state is connected

If not, retest every three seconds

Run if connected

Time delay: 3S

/Int PPPoE client set pppoe-out2 disabled = no
 
ajdmh
just joined
Posts: 5
Joined: Wed Mar 31, 2021 2:45 pm

Re: I need a script to determine if the pppoe-out1 state is connected  [SOLVED]

Thu Apr 08, 2021 7:52 am

:if ([/interface get [/interface  find name=pppoe-out1] running]=yes) do={ 
delay 3000
/interface pppoe-client set pppoe-out2 disabled=no}
The script is written according to your ideas,
However, there is a big problem with your logic:
If pppoe-out1 is in the connected state, then pppoe-out2 will keep repeating the connection and disconnection actions.

Maybe the following is right for you:
:if ([/interface get [/interface  find name=pppoe-out2] disabled]=yes) do={
:if ([/interface get [/interface  find name=pppoe-out1] running]=yes) do={ 
delay 3000
/interface pppoe-client set pppoe-out2 disabled=no}}
Last edited by ajdmh on Thu Apr 08, 2021 10:11 am, edited 5 times in total.
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: I need a script to determine if the pppoe-out1 state is connected

Thu Apr 08, 2021 3:27 pm

Tested and working to determine if the connection is active:
:if (([/interface pppoe-client monitor pppoe-out1 as-value once]->"status") = "connected") do={:put "connected"}


{ 
:local limiter
while (([/interface pppoe-client monitor pppoe-out1 as-value once]->"status") != "connected") do={
/interface set pppout-out1 disable=yes
:set $limiter ($limiter + 1)
:if (($limiter % 5) = 0) do={delay 5m} else={delay 3s}
/interface set pppout-out1 disable=no
}
}
After 5 retries it waits 5 minutes before enabling an try again 5 times. This because ISP do tend to block new connects if you tried a few times and give you a 5 minute cool-down period. After that you can try again a few times.

Explanation of the % :
modulo operation :put (5 % 3);
 
alzerjawy97
just joined
Posts: 2
Joined: Mon Jun 14, 2021 11:40 pm

Re: I need a script to determine if the pppoe-out1 state is connected

Tue Jun 15, 2021 3:31 am

Hello,

I have 10 PPPoE clients, I need a script check all PPPoE client IP address and disable the ones that has IP address from range ( 192.168.5.x) , can please help me .

Regards,

Who is online

Users browsing this forum: No registered users and 29 guests