Community discussions

MikroTik App
 
Freman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 76
Joined: Thu Jul 01, 2004 8:49 am

Script for "On Boot"?

Wed Feb 07, 2007 2:26 am

G'day folks.

We're having an ongoing problem with our Mikrotik devices. While I give Mikrotik credit for trying to fix it, it's still an on-going issue for us.

Essentially we have 200 customers hanging off our AC's (PPPoE Server) and are using dynamic routing throughout our network. The problem arises when the users all try to connect simultaneously before all the routes are up (The AC can't contact the radius server)

I need to write a script that on-boot disables the PPPoE interface, then once it can ping the radius server it re-enables it.

I can't seem to find any easy way to write a boot script...

Anyone got any ideas?
 
Freman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 76
Joined: Thu Jul 01, 2004 8:49 am

Wed Feb 07, 2007 2:48 am

So far the best I've come up with is to run this every second

:if ([ :typeof $booted ] = nil ) do={
/interface pppoe-server server set 1 disabled=yes
:global booted 1
}

Then use network with a ping interval of 1 minute pinging our radius
on up
/interface pppoe-server server set 1 disabled=no
 
cmit
Forum Guru
Forum Guru
Posts: 1547
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Wed Feb 07, 2007 10:45 am

For the system scheduler (which can be used to run scripts) there's the parameter-value "startup" for the "start-time" parameter.

This let's you execute a script directly after booting. There you could disable your PPPoE server.
Instead of running a scripts every minute or so to watch if the RADIUS server is reachable, you could instead use the netwatch feature to execute a script to enable the PPPoE server when the RADIUS server is "up" again...

Best regards,
Christian Meis
 
Freman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 76
Joined: Thu Jul 01, 2004 8:49 am

Mon Feb 12, 2007 1:34 pm

I suppose the next question quickly becomes "how to make it work"

0 name="Booting" on-event=/interface pppoe-server server set 0 disabled=yes start-time=startup interval=0s
run-count=1

It doesn't actually work, the server stays enabled...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Mon Feb 12, 2007 3:12 pm

do /interface pppoe-server server print and on next line disable it like you did

check if it works

in netwatch set script just enable server
 
cmit
Forum Guru
Forum Guru
Posts: 1547
Joined: Fri May 28, 2004 12:49 pm
Location: Germany

Tue Feb 13, 2007 1:26 pm

I suppose the next question quickly becomes "how to make it work"

0 name="Booting" on-event=/interface pppoe-server server set 0 disabled=yes start-time=startup interval=0s
run-count=1

It doesn't actually work, the server stays enabled...
You cannot use the item numbers from a "print" in a script (like the 0 you are using to reference the pppoe-server).
You have to use the "find" command.

And you can use the "find" command of this forum to find examples for the usage of RouterOS's "find" command ;)

Best regards,
Christian Meis
 
Freman
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 76
Joined: Thu Jul 01, 2004 8:49 am

Fri Feb 23, 2007 5:41 am

Done (Was done a while ago, but I forgot to come back and show it off)
/system scheduler add name=PPPoEDown on-event={:foreach i in=[/interface pppoe-server server find] do={/interface pppoe-server server disable $i}} start-time=startup
/tool netwatch add host=[:resolve your.radius.server.com] up-script={:foreach i in=[/interface pppoe-server server find] do={/interface pppoe-server server enable $i}}
Now if we could only work out why the PPPoE on these things seems to be locking up in the first place - When this happens it takes an extra long amount of time to shut down for the reboot.