Layer 7 facebook block

Hi guys,

In our company we want to block facebook page. So i decided to use layer 7 protocol. Iv put ^(.)(facebook)(.)$ as a regexp value and in firewall set this parameters.

/ip firewall layer7-protocol
add name=“Deny worktime” regexp=“^(.)(facebook)(.)$”
/ip firewall connection tracking
set enabled=yes generic-timeout=10m icmp-timeout=10s tcp-close-timeout=10s
tcp-close-wait-timeout=10s tcp-established-timeout=1d tcp-fin-wait-timeout=
10s tcp-last-ack-timeout=10s tcp-syn-received-timeout=5s
tcp-syn-sent-timeout=5s tcp-syncookie=no tcp-time-wait-timeout=10s
udp-stream-timeout=3m udp-timeout=10s
/ip firewall filter
add action=accept chain=forward disabled=no layer7-protocol=“Deny worktime”
src-address=192.168.5.1-192.168.5.49
add action=drop chain=forward disabled=yes layer7-protocol=“Deny worktime”
src-address=192.168.5.0/24 time=8h-12h,mon,tue,wed,thu,fri
add action=drop chain=forward disabled=yes layer7-protocol=“Deny worktime”
src-address=192.168.5.0/24 time=13h-17h,mon,tue,wed,thu,fri
add action=drop chain=forward disabled=no dst-port=443 layer7-protocol=
“Deny worktime” protocol=tcp src-address=0.0.0.0/0 src-port=“”
add action=drop chain=forward disabled=no dst-port=80 layer7-protocol=
“Deny worktime” protocol=tcp src-address=0.0.0.0/0 src-port=“”


Rule work perfectly BUT it block more page than facebook. And some page are available in chome and not in IE or firefox. Others are available in IE bud not in chrome… and so on… Facebook is blocked in all browsers

Any ideas?? :confused:

Using layer7 to block facebook causes a lot of problems. It is better to block facebook via IP addresses like this.

/ip firewall filter
add action=drop chain=forward comment=“Block Facebook” dst-address=
74.119.76.0/22
add action=drop chain=forward comment=“Block Facebook” dst-address=
173.252.64.0/18
add action=drop chain=forward comment=“Block Facebook” dst-address=
204.15.20.0/22
add action=drop chain=forward comment=“Block Facebook” dst-address=
66.220.144.0/20
add action=drop chain=forward comment=“Block Facebook” dst-address=
69.171.224.0/19

All right ill try your way :slight_smile: btw where u got thoose IPs?

http://bgp.he.net/AS32934#_prefixes

Oh thank you. Do u thing that will work what i did? I ping fb page and make that ip static record do dns. Then i make rules out of it. I did same for youtube and badoo.

And one more question. I need to block exe and msi files. Is it “save” solve it throu content?

Cheers :wink:

Odesláno z mého GT-I9300 pomocí Tapatalk 2

Hi cbrown. I tested with your rules and it works. but now I want to block Youtube using the dst-address. but which ip should I use? I cannot get it working.

Also you can update those rules by using whois in a linux/unix/mac box running the following commands:

echo “/ip firewall filter” ; whois -h whois.radb.net – ‘-i origin AS32934’ | grep ‘^route:’ | sort -n | uniq | awk ‘{print “add action=drop chain=forward comment=Facebook dst-address=”$2}’

echo “/ipv6 firewall filter” ; whois -h whois.radb.net – ‘-i origin AS32934’ | grep ‘^route6:’ | sort -n | uniq | awk ‘{print “add action=drop chain=forward comment=Facebook dst-address=”$2}’

You can modify awk command to fit your needs.

xMikes04, your regex layer7-protocol is ok but it should be used in dns requests
reject dns packets to any server with dst-port 53 and which hit the layer7-protocol
also fbcdn.net should be blocked

i want to allow the following:

gmail.com (only for emails)
yahoo.com (only for emails)
100.30.20.10
gregsowell.com
ports: 995, 465, 25, 110, and
ports: 8080, 8000 for only internal IP 192.168.1.101

i also have a L2TP+IPSEC VPN running on the same router right now…

everything else from inside the network should be blocked…

ETHER1 → WAN with Fixed IP
ETHER2 to ETHER5 → LAN Bridged Ports (IP RANGE: 192.168.1.150 - 192.168.1.250)
MASQUERADE → ENABLED

i am getting pretty confused with all this above conditions… all help in this is highly appreciated… please…help me!!!

Shifting from Pure Mikrotik Wireless to Firewall’s from Mikrotik as an additional service…hence facing hurdles…

sound like a company scenario, in such cases i recommend to allow http traffic only via a proxy server. it much easier to make a URL based to filter such stuff. For example: To block/allow only parts of the google services you need to intercept the encrypted https connection anyway. Some proxies can do that but you clients need to install and trust the the proxies certificate, otherwise the browsers will complain and show a warning and that’s absolutely correct because technical you’re doing a man in the middle “attack”.

I want to allow the following:

gmail.com (only for emails)
yahoo.com (only for emails)
or another website with https port 443

1 ;;; WebProxy

chain=dstnat action=redirect to-ports=8080 protocol=tcp src-address=192.168.0.0/25 
     dst-port=80,443

All https are block and I want to expect two:
One for login in gmail account and the secont for login in another https://aaaaa.xxxx

Is this posible because I make some test on web proxy access but nothing

I added these and its blocked, but i want to make an exception for some ip’s on the network, where can i put the addresses that i want to be able to access fb ?

Put another rule for any ip you want to access facebook above those with :
add action=accept chain=forward src-address=

But this rule will allow them everything so if you have some other restrictions you need to arrange the order.

Dear all,

I have been trying to block Facebook from our MikroTik router, but till now, I just can not manage. I have tried basically everything from blocking individual IP’s to changing the DNS to point to openDNS (which was configured to block social networks) to using the layer7 method. Nothing. I am a bit lost to be honest, and I am quite new with MikroTik.

We currently have have two WLAN networks configured, one is corporate and the other one is a guest network. The guest network is fire-walled, so that no one can access the corporate LAN.

Hi
I need to block viber any one have idea

well you can use squid to block fb but you have to use a modified version of squid to do it and you will need a box which can run it but once your setup and running it is smooth sailing, the dns blacklist and layer7 is unreliable so I use the ssl bumping to block fb at my work place I have set up two http/https redirect rules on the routerboard which is controlled via sheduling and set up filtering on the squid box based on acl which controls access. but ssl bumping is illegal even for Facebook in most cases, so consult with your legal folks at your company.

plz, I need these type of setup for our network. We want to block facebook for some staff from 9am(9:00 till 15hrs) but allow it for some systems, using their mac addresses to except them from the facebook blocking.

I need the steps and possible way of doing it.

Thanks

i use opendns

Every think you can drop, block
With open dns?

using opendns is an indirect way to block access to some sites avoiding to resolve dns to this sites