Thursday, August 11, 2011

Iptables block facebook

There are many “solutions” for blocking your company employees accessing Yahoo Messenger, hi5, Facebook or any other distracting services, but none of them is working properly.



So here is a perfect solution:


What you need:


- linux router for your network
- iptables firewall at least v1.3.7


Here are the rules:
Deny Yahoo Messenger packets:


iptables -I FORWARD -m string --string 'YMSG' --algo bm -j DROP
iptables -I FORWARD -m string --string 'messenger' --algo bm -j DROP
iptables -I FORWARD -m string --string 'meebo' --algo bm -j DROP
iptables -I FORWARD -m string --string 'buddy' --algo bm -j DROP
iptables -I FORWARD -m string --string 'webmessenger' --algo bm -j DROP
iptables -I FORWARD -m string --string 'web-messenger' --algo bm -j DROP


Deny facebook traffic rule:


iptables -I FORWARD -m string --string 'facebook' --algo bm -j DROP


Deny hi5 traffic rule:


iptables -I FORWARD -m string --string 'hi5' --algo bm -j DROP

and so on… you can modify these rules to fit your needs, you just need to edit the –string parameter


--string ''


Using this solution to filter specified traffic you don’t have to worry about port, protocol, application , source or destination.


Hope it helps someone.

6 comments:

Anonymous said...

Thaaaaannnnks!!!

I've tried to block these sites many times with no success. But now this is working fine.

Regards

Anonymous said...

Really working rules. Thank a lot

Unknown said...

thanks

i was struggling to block facebook
this help me lot

Víctor Manuel said...

I've found this post really helpful. This is simple, neat and easy, thank you very much!

Faisal said...

i still cannot block facebook via string command

Anonymous said...

It won't work when the remote side is HTTPS as iptables doesn't get to see the plaintext strings. So, it's kind of useless these days unless you block all HTTPS traffic as well.

 Simple Python Calculator This script will allows your to calculate the integers given with the chosen operation. You can add, substract, mu...