Data Codes through Eyeglasses

To block access to both facebook.com and youtube.com on a MikroTik router running RouterOS 7, you can create Layer 7 Protocol Matchers for both websites and then use firewall rules to block traffic to these domains. Here are the steps:

  1. Open the Winbox utility or log in to your MikroTik router via SSH or the web interface.
  2. Go to the “IP” menu and select “Firewall.”
  3. Click on the “Layer 7 Protocols” tab on the left side.
  4. Click the “+” button to create a new Layer 7 Protocol Matcher for Facebook. Give it a name (e.g., “block-facebook”) and use the following regular expression to match Facebook URLs:
.*facebook\.com.*
  1. Click “OK” to save the Facebook Layer 7 Protocol Matcher.
  2. Create another Layer 7 Protocol Matcher for YouTube. Click the “+” button, give it a name (e.g., “block-youtube”), and use the following regular expression to match YouTube URLs:
.*youtube\.com.*
  1. Click “OK” to save the YouTube Layer 7 Protocol Matcher.
  2. Now, go back to the “IP” menu and select “Firewall.”
  3. Click on the “Filter Rules” tab on the left side.
  4. Click the “+” button to create a new firewall rule to block Facebook.
  5. Set the “Chain” to “forward” if you want to block access for devices on your local network, or “input” to block access for the router itself.
  6. In the “Src. Address” field, you can specify the source IP address or range for which you want to block Facebook. If you want to block Facebook for all devices, leave this field blank.
  7. In the “Layer7 Protocol” field, select the Facebook Layer 7 Protocol Matcher you created earlier (e.g., “block-facebook”).
  8. Set the “Action” to “drop” or “reject” depending on whether you want to silently drop the traffic or reject it with an ICMP message.
  9. Click “OK” to save the firewall rule for blocking Facebook.
  10. Create another firewall rule to block YouTube following the same steps as above, but select the “block-youtube” Layer 7 Protocol Matcher and set the action to “drop” or “reject.”

Now, your MikroTik router should block access to both facebook.com and youtube.com based on the Layer 7 Protocol Matchers and firewall rules you’ve created. Remember to test the rules to ensure they work as expected. Again, keep in mind that determined users can bypass this by using a VPN or a proxy, so it’s not foolproof.