How to Block Website in MikroTik Using Layer 7 Protocols

How to Block Website in MikroTik

How to Block any Website in MikroTik Using Layer 7 Protocols. MikroTik is an internet firewall which operating system based on the Linux kernel. there is two type of MikroTik:

  1. MikroTik Router OS
  2. MikroTik RouterBoard

There is two  way to block the website in MikroTik:

  1. Using Proxy Server
  2. Layer 7 Protocol

Today I will show you How to Block Any Website in MikroTik Using Layer 7 Protocols.

Method 1: I will block website facebook Using Winbox Connect MikroTik:

  1. Open Winbox and connect to your MikroTik using MAC Address
  2. In the box go to IP => Firewall => Layer 7 Protocols Click on + and insert Name: Block Any Website. Or You can insert any name you want. Regexp: you just insert this regular expression  ^(.*)(facebook)(.*)$
    Note: if you want to block more website you just add |(website name) you website name must without protocols and extension. Example: https://www.facebook.com so you just insert facebook only.
    Example: ^(.*)(facebook)|(youtube)|(cnn)|(.*)$
    after you already add regular expression click OK.
  3. Go to IP => Firewall => Filter Rules and then Click + and Chain Select forward
  4. Click on Advanced Tab => Layer 7 Protocols:  Please Select Block Any Website
  5. Go to Action Tab => Action: Select drop and click OK to finish Rules Setup.

Method 2: I will block website facebook Using Command Line in MikroTik:

  1. Login to Winbox New Terminal and Copy  Script 2 and 3 and paste in Terminal
  2. /ip firewall layer7-protocol add name=” Block Any Website” regexp=” ^(.*)(facebook)(.*)\$”
  3. /ip firewall filter add chain=forward action=drop layer7-protocol=”Block Any Website”

Note: regexp=”^(.*)(facebook)(.*)$” this regular expression is block only one website. if need to block more website you just add

|(youtube)

Example: regexp=”^(.*)(facebook)|(youtube)|(yahoo)|(cnn)(.*)\$”

Relate Article: How to Limit Bandwidth Website in Mikrotik Using Layer 7 Protocols

Sharing to friend!