How to Block Facebook and YouTube on MikroTik (RouterOS v7)
Block Facebook, YouTube or any HTTPS website on a MikroTik router with the TLS host matcher and a QUIC rule, only for the users you choose.
Problem
You need to block Facebook, YouTube or another website for some users, for example in an office or a school lab. Blocking IP addresses or using Layer 7 rules does not work well, because these sites use HTTPS and change IP addresses constantly.
Symptoms
- Blocking a website's IP address stops working after a few hours.
- Layer 7 rules do not block HTTPS sites and push CPU usage up.
Likely causes
Modern websites use HTTPS (TLS) and QUIC (HTTP/3 on UDP port 443) and are served from large CDNs. The router cannot see the full URL, but it can see the server name (SNI) in the TLS handshake. RouterOS matches this with tls-host.
Prerequisites
- RouterOS v6.41 or later (v7 recommended).
- The users you want to block, for example
192.168.88.0/24. - A backup:
/export file=before-block.
Solution (WinBox / CLI)
1. Put the users in an address list (or use your whole LAN):
/ip firewall address-list add list=blocked-users address=192.168.88.0/242. Keep these users out of FastTrack. The server name is sent after the TCP connection is established. If the connection is already fasttracked, the firewall never sees it:
/ip firewall filter set [find action=fasttrack-connection] src-address-list=!blocked-users dst-address-list=!blocked-users3. Block the server names. Use place-before=0 so the rules sit at the top of the forward chain:
/ip firewall filter
add chain=forward src-address-list=blocked-users protocol=tcp dst-port=443 tls-host=facebook.com action=reject reject-with=tcp-reset comment="Block social" place-before=0
add chain=forward src-address-list=blocked-users protocol=tcp dst-port=443 tls-host=*.facebook.com action=reject reject-with=tcp-reset comment="Block social" place-before=0
add chain=forward src-address-list=blocked-users protocol=tcp dst-port=443 tls-host=*.fbcdn.net action=reject reject-with=tcp-reset comment="Block social" place-before=0
add chain=forward src-address-list=blocked-users protocol=tcp dst-port=443 tls-host=youtube.com action=reject reject-with=tcp-reset comment="Block social" place-before=0
add chain=forward src-address-list=blocked-users protocol=tcp dst-port=443 tls-host=*.youtube.com action=reject reject-with=tcp-reset comment="Block social" place-before=0
add chain=forward src-address-list=blocked-users protocol=tcp dst-port=443 tls-host=*.googlevideo.com action=reject reject-with=tcp-reset comment="Block social" place-before=04. Block QUIC for the same users. Browsers then fall back to normal HTTPS, which the rules above can see:
/ip firewall filter add chain=forward src-address-list=blocked-users protocol=udp dst-port=443 action=drop comment="Block QUIC" place-before=0To block only during office hours, add a time condition such as time=09:00:00-17:00:00,sun,mon,tue,wed,thu to each rule. See Time-based internet rules on MikroTik.
Verification
- From a blocked PC, open facebook.com. The page should fail to load.
- Watch the counters grow:
/ip firewall filter print stats where comment~"Block"Common errors
- Rules placed below the FastTrack or "accept established" rules: nothing is blocked.
- QUIC not blocked: YouTube still works in Chrome.
- Mobile apps use extra domains. Check
/ip firewall connectionor Torch to find them. - Browsers with Encrypted Client Hello (ECH) can hide the server name, so some sites may still open.
Rollback
/ip firewall filter remove [find comment="Block social"]
/ip firewall filter remove [find comment="Block QUIC"]Then, in WinBox, open the FastTrack rule (IP > Firewall > Filter Rules) and clear the two address-list conditions you added in step 2.
Watch the video: How to block Facebook using MikroTik router
This topic is covered hands-on in MTCTCE — MikroTik Certified Traffic Control Engineer.
View MTCTCE