Wednesday, July 7, 2021

Mikrotik Layer7 Regexp Whatsapp

Whatsapp access is restricted in almost every corporate network. Usually, if we apply the restriction using the firewall of the MikroTik router, then the users will be blocked from the web access of Whatsapp, but they will get access with Whatsapp apps.

To block Whatsapp apps we need to take the help of MikroTik's "layer-7 protocol" feature. There some kind of "RegExp Code" is written. Later,  restrictions are applied using those codes. One screenshot is given below.


The regexp code for blocking the "Whatsapp" app is given below: -


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


How to block "Whatsapp" apps using layer-7 protocol is discussed step by step below.

First, we will go to the layer-7 protocol from the firewall. Here, we will add a new protocol rule.


We will assign a name for this rule entry and then we will write the regexp code. To write this code, just copy and paste it from the upper location. We named it "Block_Whatsapp". Then click on the "apply" and "OK" buttons to save as well as close this window.


Now we will navigate to the "Filter Rules" tab. Here, we will create a new filter rule. After click on the (+) sign, navigate to the "Advanced" tab.


Here, in the "Layer7 Protocol" field, we will select the layer 7 protocol rule that we created earlier. That is "Block_Whatsapp".


Now go to the "Action" tab. In the "Action" field, select the "Drop" value from the drop-down list.


Finally, we will click on the "Apply" and "OK" buttons to save as well as close this window. From now on Whatsapp web access will be blocked as well as access through apps will be blocked.

If you have multiple firewall rules or access rules configured then please make sure you have placed this rule in the right sequence. If you are not sure about that, then place this rule at the top of all of your firewall rules. Just drag it on the up way and drop it at the first position and make sure the rule sequence number is "0". Just like below.


Thank you.

2 comments: