Iptables – Blocking Facebook on certain IP Addresses with iptables

iptablesrulessquid

Here's my current environment:

I have a VM running Ubuntu Server/Squid, and it is set as non-transparent. I have some IP Addresses which need to bypass Squid authentication so they have unrestricted access. In some cases it is need because some applications don't work well with the proxy.

It is currently done with the following iptables rule:

iptables -t nat -I PREROUTING -s 192.168.0.12 -p tcp --match multiport --dports 80,443  -j ACCEPT

My problem now is that I have to block Facebook for a few of those unrestricted IP Addresses.

I have searched for a long time now and tested a bunch things to implement in my current rule, with no success, so I'm hoping some of you could enlighten me on this situation.

Best Answer

To reliably filter facebook, you'd need to set up a transparent proxy (for example squid) and filter there based on the domain name.