To add schedule to run any specific script at specific scheduled time, Follow the steps Below.
1) First create the script
2) Schedule it to run it at desired time.
SCENARIO # 1 | Allow user JOHN access to internet in Lunch Timings Only . . .
You have created a rule that blocks user John internet access all the time (In this example, we disable user id JOHN, it can also be done via creating firewall rule to block access, but for this example we will use disable strategy), but you want him to use internet from 1:00pm til 2:00pm. You have to create two scripts, first that will disable the “Block user john rule” at 1 pm and the second script that will enable the “Block user john rule” at 2 pm.
Here is the “Block user john rule”
/ppp secret add caller-id="" comment="" disabled=no limit-bytes-in=0 limit-bytes-out=0 local-address=10.10.0.1 name=john password=123 profile=default routes="Testing ID" service=any
Here are the Scripts examples in following screenshots.
Now ADD the following Scheduler to Execute both scripts at desired timing.
# Enable-User-John-Script at 1PM (Interval 1d so it may run every day)
# Disable-User-John-Script at 2PM (Interval 1d so it may run every day)
C.L.I VERSION:
[admin@MikroTik] > /system script export /system script add name=disable-user-john-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ppp secret disable john" add name=enable-user-john-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ppp secret enable john"
[admin@MikroTik] > /system scheduler export /system scheduler add comment="" disabled=no interval=1d name="Enable User JOHN at 1pm" on-event=Enable-user-john-script policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=dec/07/2011 start-time=13:00:00 add comment="" disabled=no interval=1d name="Disable User JOHN at 2pm" on-event=Disable-user-john-script policy=reboot,read,write,policy,test,password,sniff,sensitive start-date=dec/07/2011 start-time=14:00:00
Another example on howto disable Web Proxy Access Rule.
SCENARIO # 2 | Block Access to Facebook, and Allow only in Lunch Timings
You have blocked access to social networking web sites Facebook and you want that users can access it only in Lunch timings, which is from 1:00pm till 2:00pm. I assume you are using Mikrotik web proxy [transparent mode], (If not, you can block the access via ip pool + firewall filter, adjust it accordingly, its only an example)
For example you have created an rule in web.proxy to block Facebook, (BLOCK-FB rule) which blocks Face-book site , example below
/ip proxy access add action=deny comment=fb disabled=no dst-host=www.facebook.com
(Don’t forget the ‘comments’ in rule) and Now you want to Allow access to FB from 1:00 pm till 2:00 pm,
You have to create two Scripts, one that will disable the BLOCK-FB rule,
and second that will enable the BLOCK-FB rule.
Disable-fb-rule Script
/ip proxy access disable [find comment="fb"]
Enable-fb-rule Script
/ip proxy access enable [find comment="fb"]
OR you can Add scripts via following code in TERMINAL.
/system script add name=disable-fb-rule-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ip proxy access disable [find comment=\"fb\"]" add name=enable-fb-rule-script policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/ip proxy access enable [find comment=\"fb\"]"
Now add schedule to Run “disable-fb-rule-script” to run at 1:00 pm Daily,
Add another schedule to Run “enable-fb-rule-script” to run at 2:00 pm Daily,
/system scheduler add comment="" disabled=no interval=1d name="Disable fb rule schedule" on-event="disable-fb-rule-script" start-date=dec/08/2010 start-time=01:00:00 add comment="" disabled=no interval=1d name="Enable fb rule schedule" on-event="enable-fb-rule-script" start-date=dec/08/2010 start-time=02:00:00
SCENARIO # 3 | Reboot RB daily in night
Following script will create a schedule, which will reboot RB daily in night at 1:00am.
/system scheduler add comment="Reboot every 1 day" disabled=no interval=1d name=Reboot1d on-event="/system reboot" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive start-date=Nov/14/2012 start-time=01:00:00
Hi….
Thnx for your help. I m trying to restrict facebook in some IP and allow in some other IP in my network, is it possible? Please help
LikeLike
Comment by Sanjoy — May 2, 2012 @ 5:21 PM
pls sir, pls how can i allow everbody or users to browse from 1pm to 7am in the schedules time. thank u sir
LikeLike
Comment by emmy — November 24, 2012 @ 9:30 PM
Nice one but I have a different requirement just like above but regarding internet access in defined time interval.
Scenario could be like below:
We will have 3 different group : Group-1 includes some customers / Group 2 Includes some and Group-3 includes some.
These 3 different group will have different time interval for internet access lets say gp-1 will have internet access from 6:am to 10am , after that internet block , likewise same for remaining 2 group.
LikeLike
Comment by Shiva Thapa — January 21, 2013 @ 3:22 PM
Well It can be done by various ways. Either by create a FILTER rule that blocks specific IP ranges in specific TIME. Time can be define in the RULE by going to EXTRA tab.
TIME option can be helpful to you, Because if you use TIME tab, then you wont have to configure the SCRIPTS and SCHEDULER.
Cheers
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — January 23, 2013 @ 11:19 AM
Hello
I am setting up a MikroTik Router on x86 machine.
It is all set now and Im runing internet from it. it is getting internet from a PPPoE connection which is giving dynamic ip and so is its dhcp server. Now when my server restarts, it abort its previous connection and starts a new one on which it receives a new ip address hence screwing up the routing settings. What should i do to solve this problem.
Regards
LikeLike
Comment by DragoTech Innovations PK — March 6, 2013 @ 3:24 PM
This is the default behavior of DHCP. Request your ISP to fix your IP so your routing dont get messed, you need static ip if you have particular need.
Why you require fix ip anyway ? for hat service ?
LikeLike
Comment by Syed Jahanzaib / Pinochio~:) — March 6, 2013 @ 7:53 PM
I found a round about.. changed the route to my present PPPoE IP and problem resolved! XD
LikeLike
Comment by DragoTech Innovations PK — March 9, 2013 @ 11:32 AM
Hi I am newbie ,I have to do wifi network at our school,as our requirement ,we need to do modify configuration for student with time schedule like (auto disconnect & auto reconnect ). Goal is student can not access internet in lecture time and can access internet after lecture time on student account ,Please help me Master !!!!
LikeLike
Comment by Thuya — August 27, 2016 @ 11:09 AM
Assalam O Allekum Brother
i m running a pppoe server on RB-433UAH. i want to put connection date in comments and script find date in comments and macth system date than disable user
LikeLike
Comment by Muhammed Azam Ghouri — January 6, 2017 @ 10:17 PM
aoa
bhai mujhe autologin ke script bnwani h plzz banwa dain gain
LikeLike
Comment by hashir Mehmood — November 3, 2017 @ 3:23 AM
can i use this in ppoe acount i want my ppoe client limit at 30days then it will disconnect not remove for me not going to his house to change his username and pass?
LikeLike
Comment by Norodin C. Baer — April 27, 2019 @ 8:00 AM