LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2013, 03:26 PM   #16
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50

have you tried to block facebook via iptables (-m string):
http://blog.mynux.net/2011/08/iptabl...-facebook.html
 
Old 02-25-2013, 06:29 AM   #17
contozo
Member
 
Registered: Jan 2013
Posts: 32

Rep: Reputation: Disabled
Why you dont try making an alias and block access to it? I did in this way on pfsense box and it works, think can work in linux too, but if you block it with alias non will be aviable to access facebook, even if you have PC's wich are not filtered in proxy.
 
Old 09-03-2013, 05:42 AM   #18
skyfly
LQ Newbie
 
Registered: Apr 2004
Location: Johannesburg, South Africa
Distribution: Redhat Fedora Slackware
Posts: 7

Rep: Reputation: 0
Block Facebook with iptables

Let's say your LAN IP range is 10.1.1.0/24 then:


### Block connections to Facebook #########################################################################

IPT="/sbin/iptables"

$IPT -A OUTPUT -p tcp -m string --string "facebook.com" --algo kmp -j DROP
$IPT -A FORWARD -d facebook.com -j DROP

echo "Obtaining Facebook IP ranges from whois..."

RESULT=$( /usr/bin/whois -h whois.radb.net '!gAS32934' | tr ' ' '\n' | sort -n -k1,1 -k2,2 -k3,3 -k4,4 )

arr=$(echo $RESULT | tr " " "\n")

if [ -f facebookips ] ; then
rm -f facebookips
fi

for x in $arr
do
echo "$x" >> facebookips
done

tail -n +6 facebookips > tmp.tmp
mv tmp.tmp facebookips

y=0

while read line
do
(( y++ ))
$IPT -I FORWARD -s 10.1.1.0/24 -d $line -j DROP
$IPT -A INPUT -p tcp -d $line --dport 443 -j REJECT
done <facebookips

echo "$y Facebook IP ranges blocked."

#################################################################################################### #######

Last edited by skyfly; 09-03-2013 at 05:44 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] iptable rules to block https://www.facebook.com mandyapenguin Linux - Newbie 21 11-18-2015 11:35 PM
Most YouTube videos and Facebook games won't play. LinuxLiker Linux - Software 13 04-19-2012 09:54 AM
Try to block https://facebook.com but cannot able to do this yet tanin007 Linux - Software 10 01-13-2012 09:09 AM
[SOLVED] how to deny block https sites for some users Winanjaya Linux - Security 10 12-01-2009 12:36 AM
deny access to youtube.com 7mza Linux - Networking 3 01-20-2009 05:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration