Community discussions

MikroTik App
 
qudama
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Mon Feb 24, 2014 2:26 am

pppoe status script

Mon Dec 31, 2018 6:36 am

Hello,
i need a script can do this:

if pppoe-out1 status is connected do no thing
else
disable pppoe-out1

delay 30s
re enable it



thnaks
 
Frostbyte
Frequent Visitor
Frequent Visitor
Posts: 92
Joined: Mon Dec 25, 2017 1:42 am

Re: pppoe status script  [SOLVED]

Mon Dec 31, 2018 3:31 pm

You can try leveraging the on up/down built-in script functionality of the PPP profiles.

Go to PPP -> Profiles (tab) -> Double click your PPPoE profile -> Scripts (tab) and populate the "on down" field.

An example reset script which might fit your purposes, could go like this:
/interface set disabled=yes [find name=pppoe-out1]
delay 30
/interface set disabled=no [find name=pppoe-out1]
 
qudama
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Mon Feb 24, 2014 2:26 am

Re: pppoe status script

Mon Dec 31, 2018 10:13 pm

this is not helping because i have more than 80 pppoe-out1-80
so any one disconect will be disconnect all
 
ivicask
Member
Member
Posts: 422
Joined: Tue Jul 07, 2015 2:40 pm
Location: Croatia, Zagreb

Re: pppoe status script

Mon Dec 31, 2018 10:17 pm

this is not helping because i have more than 80 pppoe-out1-80
so any one disconect will be disconnect all
Create several profiles for each pppoe with matching pppoe name inside, u can easy automate it to add via command line..

Or someone with a bit scripting knowlage could make u script which loops and checks for down pppoe* interfaces and disables and enables them.
 
qudama
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Mon Feb 24, 2014 2:26 am

Re: pppoe status script

Tue Jan 01, 2019 11:24 pm

Thank you very much guys i could do it like this


in profile :
on up :
delay 2
/system script run "pppoe-out1-script"
on down :
/system script run "pppoe-out1-script"
in script :
pppoe-out1-script :
##### Script Settings #####
:local WanName "pppoe-out1"
#####################
:local WanStat
/interface pppoe-client monitor $WanName once do={ :set WanStat $status}
:if ($WanStat = "terminating... - failed to authenticate ourselves to peer") do={/system script run "pppoe-out1";}

in script :
pppoe-out1 :
/interface set disabled=yes [find name=pppoe-out1]
delay 20
/interface set disabled=no [find name=pppoe-out1]


its works fine :)
this is only one user and you can duplicated as much as you want thanks
 
Frostbyte
Frequent Visitor
Frequent Visitor
Posts: 92
Joined: Mon Dec 25, 2017 1:42 am

Re: pppoe status script

Wed Jan 02, 2019 10:49 am

this is not helping because i have more than 80 pppoe-out1-80
so any one disconect will be disconnect all
Pardon me but you didn't initially mention that you had multiples to deal with.

Thank you very much guys i could do it like this


in profile :
on up :
delay 2
/system script run "pppoe-out1-script"
on down :
/system script run "pppoe-out1-script"
in script :
pppoe-out1-script :
##### Script Settings #####
:local WanName "pppoe-out1"
#####################
:local WanStat
/interface pppoe-client monitor $WanName once do={ :set WanStat $status}
:if ($WanStat = "terminating... - failed to authenticate ourselves to peer") do={/system script run "pppoe-out1";}

in script :
pppoe-out1 :
/interface set disabled=yes [find name=pppoe-out1]
delay 20
/interface set disabled=no [find name=pppoe-out1]


its works fine :)
this is only one user and you can duplicated as much as you want thanks
If you read the documentation I supplied, you'll find that the on-up and on-down scripts expose a set of client-specific local variables:
  • user
  • local-address
  • remote-address
  • caller-id
  • called-id
  • interface

You can try this as your on-down script and omit everything else:
/interface set disabled=yes [find name=$interface]
delay 20
/interface set disabled=no [find name=$interface]
 
qudama
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 57
Joined: Mon Feb 24, 2014 2:26 am

Re: pppoe status script

Wed Jan 02, 2019 2:11 pm

thank you very much,
i tried i found the delay and re enable the pppoe-out 1 is not works may be the version issue i did this


on-down
/interface set disabled=yes [find name=pppoe-out1] 
delay 20 
/interface set disabled=no [find name=pppoe-out1]
 
User avatar
nichky
Forum Guru
Forum Guru
Posts: 1275
Joined: Tue Jun 23, 2015 2:35 pm

Re: pppoe status script

Thu Jan 03, 2019 12:58 pm

useful :)

Thanks

Who is online

Users browsing this forum: No registered users and 22 guests