Yes, you can restrict access to a website at certain hours using a MikroTik router. This can be achieved by creating rules in the firewall that block traffic to specific IP addresses or domain names during defined times. Here I explain how to do it step by step:
Step 1: Identify the IP Address or Domain Name
First, you need to identify the IP address or domain name of the website you want to restrict access to. Keep in mind that large websites may use multiple IP addresses or change them periodically.
Step 2: Create an Address List
Create a list in the MikroTik firewall for the website or websites you want to restrict access to.
/ip firewall address-list
add address=www.ejemplo.com list="Lista Sitios Restringidos"
Step 3: Create a Script to Enable and Disable the Lock
You will need two scripts: one to enable blocking and one to disable it. This is done to control access based on time.
- Script to enable blocking:
/ip firewall filter
add action=drop chain=forward dst-address-list="Lista Sitios Restringidos" comment="Bloqueo Sitio Ejemplo"
- Script to disable the lock:
You will need to remove the blocking rule. This can be done via the rule ID in the firewall.
/ip firewall filter remove [find comment="Bloqueo Sitio Ejemplo"]
Step 4: Configure the Scheduler
MikroTik RouterOS allows you to configure scheduled tasks (Scheduler) to run scripts at specific times.
- To enable blocking:
/system scheduler
add name="Habilitar Bloqueo Sitio" start-date=jan/01/1970 start-time=00:00:00 interval=1d on-event="NombreScriptHabilitarBloqueo"
- To disable the lock:
/system scheduler
add name="Deshabilitar Bloqueo Sitio" start-date=jan/01/1970 start-time=08:00:00 interval=1d on-event="NombreScriptDeshabilitarBloqueo"
Note: You must adjust the schedules (start-time
) based on the specific hours you want to restrict access. Additionally, it is important to remember that blocking by domain name may not be completely effective if the site uses CDNs or has multiple IP addresses. In those cases, blocking by IP address may be more effective but requires keeping the site's IP list updated.
These steps will allow you to configure your MikroTik router to restrict access to specific websites during the hours you choose. Please note that the exact names of the commands and options may vary slightly depending on the version of RouterOS you are using.
There are no tags for this post.