Community discussions

MikroTik App
 
akram
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 88
Joined: Wed Aug 10, 2005 4:58 pm

Block Facebook & Youtube on Certain Ips - and it works

Thu Dec 19, 2013 5:22 pm

i'm sharing how i did block on facebook and youtube
here is how

1-add in firewall Layer7
ip firewall layer7-protocol add name=Blockface&youtube regexp=^.+(facebook.com|youtube).*$

2-add in address list the allow list
ip firewall address-list add address=192.168.1.5 list=allow_face_youtube

3-add in address list the Block list
ip firewall address-list add address=192.168.1.112 list=block_face_youtube

4-mark packet in mangle for allow list
ip firewall mangle add chain=forward src-address-list=allow_face_youtube action=mark-packet new-packet-mark=allow_fb_youtube_mark passthrough=no

5-mark packet in mangel for block list
ip firewall mangle add chain=forward src-address-list=block_face_youtube action=mark-packet new-packet-mark=block_fb_youtube_mark passthrough=no

6-firewall drop in port 80
ip firewall filter add chain=forward protocol=tcp port=80 packet-mark=mark-packet new-packet-mark=block_fb_youtube_mark action=drop


7-firewall drop in port 443
ip firewall filter add chain=forward protocol=tcp port=443 packet-mark=mark-packet new-packet-mark=block_fb_youtube_mark action=drop

and it works perfect for me
 
User avatar
c0d3rSh3ll
Long time Member
Long time Member
Posts: 557
Joined: Mon Jul 25, 2011 9:42 pm
Location: [admin@Chile] >

Re: Block Facebook & Youtube on Certain Ips - and it works

Fri Dec 27, 2013 4:57 am

thank for the regexp, it work ¡¡
 
dally1336
just joined
Posts: 1
Joined: Wed Jan 15, 2014 2:43 pm

Re: Block Facebook & Youtube on Certain Ips - and it works

Wed Jan 15, 2014 2:46 pm

this doesnt work, it keeps telling me commands 1,6 and 7 are wrong
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26931
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia
Contact:

Re: Block Facebook & Youtube on Certain Ips - and it works

Thu Jan 23, 2014 3:33 pm

be aware that pasting these rules will not work. this regext must be pasted in winbox, console will not understand it. just make the l7 rule in winbox with this regex:

ros code

^.+(facebook.com|youtube).*$
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7195
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Block Facebook & Youtube on Certain Ips - and it works

Thu Jan 23, 2014 3:38 pm

To add these regexps in console they need to be quoted and all special characters need to be escaped.

For example to add regexp aaa$

you ned to write:
/ip firewall regex add name=example regexp="aa\$"


List of escape characters are listed here
http://wiki.mikrotik.com/wiki/Manual:Sc ... _Sequences
 
User avatar
mahnet
Long time Member
Long time Member
Posts: 654
Joined: Tue Jul 07, 2009 9:11 pm

Re: Block Facebook & Youtube on Certain Ips - and it works

Fri Jan 24, 2014 6:01 pm

I guess there r some errors in line 6 & 7

1. port type not mentioned

2. error in command

6-firewall drop in port 80
ip firewall filter add chain=forward protocol=tcp port=80 packet-mark=mark-packet new-packet-mark=block_fb_youtube_mark action=drop

7-firewall drop in port 443
ip firewall filter add chain=forward protocol=tcp port=443 packet-mark=mark-packet new-packet-mark=block_fb_youtube_mark action=drop

skipping this blocks each site for me