Mikrotik: Layer 7 Filtering

Regex filter

/ip firewall layer7-protocol
add name=youtube\
    regex=^.+(youtube.com|youtu.be|googlevideo.com|ytimg.com|instagram.com|catchplay.com|iflix.com|dailymotion.com|netflix.com|vimeo.com|hulu.com|twitch.tv|ttvnw.net|bigo.tv|cubetecn.com|tiktok.com|facebook.com).*$
/ip firewall filter
add chain=forward\
    layer7-protocol=youtube\
    action=drop

Block Instagram

/ip firewall raw
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.instagram.\
    protocol=tcp\
    tls-host=*.instagram.*
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.cdninstagram.\
    protocol=tcp\
    tls-host=*.cdninstagram.*

Block Facebook

/ip firewall raw
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.facebook.\
    protocol=tcp\
    tls-host=*.facebook.*
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.fbcdn.\
    protocol=tcp\
    tls-host=*.fbcdn.*

Block Youtube

/ip firewall raw
add action=add-dst-to-address-list\
    address-list=Block-list\
    address-list-timeout=none-dynamic\
    chain=prerouting\
    content=.youtube.\
    protocol=tcp\
    tls-host=*.youtube.*
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.googlevideo.\
    protocol=tcp\
    tls-host=*.googlevideo.*

Block Tiktok

/ip firewall raw
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.tiktokv.\
    protocol=tcp\
    tls-host=*.tiktokv.*
add action=add-dst-to-address-list\
    address-list=Block-list\
    chain=prerouting\
    content=.tiktokcdn.\
    protocol=tcp\
    tls-host=*.tiktokcdn.*

Last step

/ip firewall filter
add action=drop\
    chain=forward\
    comment=BLOCK_LIST\
    dst-address-list=Block-list

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *