Monday, October 5, 2015

Blocking Sites With MikroTik At Certain Hours

This time who does not familiar with Facebook ?? Networking sites are used by people to make friends, chat, and so on. But it turns out the site is also a barrier for companies to conduct business activities. Why?? One reason is to make employees facebook's busy, so forget about the tasks anyway. No exception to the office where I work are victims facebook fever that affects employees. One day I was asked by superiors to block the Facebook site that could not be accessed by the employees in the office during working hours, while outside working hours is allowed to access the site.


Since I use MikroTik as a router, then I will share tips MikroTik blocking style. Here are the steps. Hope it is useful....
Firstly, that time runs in the router according to a local location, then we need to set the clock in MikroTik referring to the NTP Server. If we have a NTP server itself, then we just steer MikroTik to the NTP server, but if we do not have the NTP Server, then do not worry as much NTP servers outside that we can use as a reference. Some of them are owned NTP Server LIPI (Indonesian Institute of Sciences) with the URL: ntp.kim.lipi.go.id (203.160.128.6) and the NTP Pool Project with one URL: 0.id.pool.ntp.org (202 169 .224.16). To mensettingnya in MikroTik, type the following command:

/ system ntp client sets of primary-secondary-ntp = 203.160.128.6 ntp = 202.169.224.16 \ mode = unicast enabled = yes;

Second, create a rule in the firewall filters. In this case I want to block the Facebook site that uses the HTTP port (80), so that in addition to the port is still permitted. The goal is that users can still receive update facebook status via email. To mensettingnya type the following command:

/ ip firewall filter add chain = forward src-address = 0.0.0.0 / 0 protocol = tcp \ dst-port = 80 content = "facebook" action = drop comment = "Block Access Facebook";

Third, create a script to activate the firewall during working hours and turn it off at recess and outside working hours. Here I create 3 script, the script to activate (enable) firewall, a script to turn off (disable) the firewall as well as a script to be executed on holidays (Saturday-Sunday) and weekday. Here's the script:
Script to turn off (disable) the firewall:

/ system script add name = "fb-allow" policy = write, read, policy, test, sniff source = {/ ip firewall filter set [/ ip firewall filter find content = "facebook"] disabled = yes}

Script to activate (enable) the firewall:
/ system script add name = "fb-deny" policy = write, read, policy, test, sniff source = {/ ip firewall filter set [/ ip firewall filter find content = "facebook"] disabled = no}

Script to disable the firewall on holidays and enable on weekdays:
/ system script add name = "fb-holiday" policy = write, read, policy, test, sniff source = {if ([/ system scheduler get [/ system scheduler find on-event = "fb-deny"] disabled] = true) do [/ system scheduler sets [/ system scheduler find on-event = "fb-deny"] disabled = no] else [/ system scheduler sets [/ system scheduler find on-event = "fb-deny"] disabled = yes]}

Fourth, make a schedule to determine when the firewall is activated or deactivated. Here I make 6 scheduler based on working hours and working day, ie 08:00, 12:00, 13:00, 17:00, Saturday-Sunday, and Monday. Here's the script:
Schedule to activate (enable) the firewall during office hours (08:00):
/ system scheduler add name = "fb-08: 00" start-date = jan / 01/1970 start-time = 08: 00: 00 interval = 1d on-event = "fb-deny"

Schedule to turn off (disable) firewall at break (12:00):
/ system scheduler add name = "fb-12: 00" start-date = jan / 01/1970 start-time = 12: 00: 00 interval = 1d on-event = "fb-allow"

Schedule to reactivate (enable) firewall during office hours (13:00):
/ system scheduler add name = "fb-13: 00" start-date = jan / 01/1970 start-time = 13: 00: 00 interval = 1d on-event = "fb-deny"

Schedule to turn off (disable) the firewall outside working hours up (> 17:00):
/ system scheduler add name = "fb-17: 00" start-date = jan / 01/1970 start-time = 17: 00: 00 interval = 1d on-event = "fb-allow"

Schedule to turn off (disable) firewall on holidays (Saturday-Sunday):
/ system scheduler add name = "fb-Saturday-Sunday" start-date = aug / 01/2009 start-time = 00: 00: 00 interval = 7d on-event = "fb-holiday"

Make sure that the date defined in the parameter "start-date" scheduler is Saturday. And the parameter "interval" rated 7d.

Schedule to reactivate (enable) firewall on weekdays (Monday):
/ system scheduler add name = "fb-Monday" start-date = aug / 03/2009 start-time = 00: 00: 00 interval = 7d on-event = "fb-holiday"

Make sure that the date defined in the parameter "start-date" scheduler is Monday. And the parameter "interval" rated 7d.
Next
This is the most recent post.
Previous
Older Post

Powered by Blogger.