Page 1 of 1

pppoe status script

Posted: Mon Dec 31, 2018 6:36 am
by qudama
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

Re: pppoe status script  [SOLVED]

Posted: Mon Dec 31, 2018 3:31 pm
by Frostbyte
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]

Re: pppoe status script

Posted: Mon Dec 31, 2018 10:13 pm
by qudama
this is not helping because i have more than 80 pppoe-out1-80
so any one disconect will be disconnect all

Re: pppoe status script

Posted: Mon Dec 31, 2018 10:17 pm
by ivicask
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.

Re: pppoe status script

Posted: Tue Jan 01, 2019 11:24 pm
by qudama
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

Re: pppoe status script

Posted: Wed Jan 02, 2019 10:49 am
by Frostbyte
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]

Re: pppoe status script

Posted: Wed Jan 02, 2019 2:11 pm
by qudama
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]

Re: pppoe status script

Posted: Thu Jan 03, 2019 12:58 pm
by nichky
useful :)

Thanks