Block Websites

To create Layer 7 Protocols (L7P) in the firewall and use them to block specific websites, follow the steps below.

Step 1: Access Layer 7 Protocols in Firewall Settings

  1. Navigate to IP > Firewall in your settings menu.
  2. Open the Layer 7 Protocols tab.

Step 2: Create and Configure an L7P Script

  1. Click the + (blue icon) to open the New Firewall Layer 7 Protocol window.

  2. In the Name field, enter a unique name for your script. Like Block Websites

  3. In the Regexp (Regular Expression) field, input the pattern for the website you wish to block.

    • For example, to block access to Facebook, enter the following regular expression:
      /.*youtube|ibomma|udemy|nyaa.si|utorrent|instagram|torrentgalaxy|yts.mx|telegram|movierulz.*/gm
      
  4. Click Apply and OK to save your L7 Protocol.

Step 3: Apply the Layer 7 Protocol in Firewall Filter Rules

To activate the Layer 7 Protocols you have created:

  1. Open the Filter Rules tab in the firewall menu.
  2. Use the newly created Layer 7 Protocol rule within your filter rules to block the specified websites.

Example

With these steps, you can effectively create and implement custom Layer 7 Protocol rules to restrict access to designated websites through the firewall.

create_fw_rule

Now that the L7P script has been created, you can proceed to create filter rules to apply this script. Follow these steps:

  1. Go to IP > Firewall in the settings menu, then select the Filter Rules tab.
  2. To create a new filter rule, click the + icon.
  3. In the General tab, set the Chain to Forward.

general

  1. Advanced Tab: Go to the Advanced tab, and in the Layer 7 Protocols field, enter the name of the previously created L7P script.

advanced

  1. Action Tab: In the Action tab, select Drop as the action, then click OK.

action

This will prevent access to Facebook or any other specified website on your PC.

Note: All users attempting to access the URL defined in the L7P script (in the Advanced tab) will be forwarded (Chain: Forward) and have their actions blocked (Action: Drop).

This is the method we are following to block a website in MikroTik. Another methods also exists!