Sunday, April 25, 2021

Mikrotik Block Site Layer7

Restrictions that apply using filter rules are usually applied to web traffic. These rules cannot control the traffic of any type of app. So we have to take the help of Layer-7 protocol to control the traffic of the app. This layer-7 protocol works using some regular express code. To block an app's traffic, the layer-7 protocol is first created using a regexp code. The filter rule is then created using the layer-7 protocol, which is able to apply restrictions on the traffic of any type of app. In this tutorial, we will discuss regexp codes for some of the known services.

Usually, Facebook, Youtube, Instagram, TikTok, Whatsapp, Netflix, Twitter websites are restricted to any type of corporate office. This restriction is applied using the traditional filtering method. Due to which the restriction can be applied only on web access of the services. But access cannot be blocked through the app. To apply the restriction on the app, we must use the layer-7 protocol. Below are the regexp codes for all those services.


Regexp code for "Youtube" as follows:-

^.+(ytstatic.l.google.com|youtube-ui.l.google.com|youtubei.googleapis.com|youtube.googleapis.com|youtube.com|www.youtube.com|m.youtube.|.m.youtube.|ytimg.com|s.ytimg.com|ytimg.l.google.com|youtube.l.google.com|i.google.com|googlevideo.com|youtu.be|youtube-nocookie.com).*$


Regexp code for "Facebook" as follows:-

^.+(www.facebook.com|facebook.com|login.facebook.com|www.login.facebook.com|fbcdn.net|www.fbcdn.net|fbcdn.com|www.fbcdn.com|static.ak.fbcdn.net|static.ak.connect.facebook.com|connect.facebook.net|www.connect.facebook.net|apps.facebook.com|m.facebook.com|fbsbx.com).*$


Regexp code for "Tiktok" as follows:-

^.+(myqcloud.com|wsdvs.com|worldfcdn.com|footprint.net|byteoversea.|ibyteimg.|.ibyteimg|ibyteimg.com|musemuse.cn|muscdn.com|.byteoversea|byted.org|bytecdn.cn|byteoversea.com|.musical|musical.|musical.ly|tiktokcdn.com|tiktokv.com|tiktokcdn.com|.tiktokv|tiktokv.|tiktokcdn-com|.akamaized|akamaized.net|akamaized.|tiktok.com|www.tiktok.com|m.tiktok.com|tiktok.|tiktok|.zhiliaoapp|.musically|zhiliaoapp.|musically.).*$


Regexp code for "Snapchat" as follows:-

^.+(feelinsonice.appspot.com|appspot.l.google.com|data.flurry.com|appspot.com|.appspot|appspot.|feelinsonice-hrd.appspot.com|data.flurry.com|snapchat.com|snap.net|www.snapchat.com|www.feelinsonice.com|feelinsonice.com|www.snap.net|.snap.net.).*$


Regexp code for "Instagram" as follows:-

^.+(instagram.com|cdninstagram.com|.cdninstagram.com|.instagram.com|instagram.|.instagram|.cdninstagram|cdninstagram.).*$


Regexp code for "Netflix" as follows:-

^.+(netflix.com|netflix.net|nflxext.com|nflximg.com|nflximg.net|nflxso.net|nflxvideo.net|.netflix.).*$


Regexp code for "Twitter" as follows:-

^.+(.twitter.|ads-twitter.com|twimg.com|twitter.com|twttr.com|twimg.com.akahost.net|twitter.map.fastly.net).*$


Regexp code for "Whatsapp" as follows:-

^.+(whatsapp.com|whatsapp.net|.whatsapp.|.whatsapp).*$


Listed websites or apps will be completely blocked by the firewall if we use these regexp codes during the creation of the layer 7 protocol.


1 comment: