LinuxQuestions.org
Review your favorite Linux distribution.
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 07-05-2017, 02:55 PM   #1
tomislav91
Member
 
Registered: Apr 2012
Posts: 46

Rep: Reputation: Disabled
Forbid Facebook.Com On All My Vpn Connections Using Squid


Hello guys, i want to all my vpn connections in linux ubuntu distro to forbid in a period of a time facebook.com. So between 00:00 - 06:00 facebook.com is not be available. I can manage this with squid. So my question is, can i somehow put it on all my connections at once, some global install and configuration like in windows you have domain. I just have my connections in vpn, so i have just ip addresses. Can you give me some advice how can i fastest do this job?
 
Old 07-06-2017, 03:15 AM   #2
elcore
Senior Member
 
Registered: Sep 2014
Distribution: Slackware
Posts: 1,719

Rep: Reputation: Disabled
Maybe a cron.daily job to push iptables rules @0:00 and flushes them @6:00
I used these rules to ban fb, but note this is ipv4 specific, and there may be additional iprange to block since the time these rules were written.
Code:
####
iptables -A INPUT -m iprange --src-range 31.13.0.0-31.13.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 45.64.0.0-45.64.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 69.63.0.0-69.63.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 69.171.0.0-69.171.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 66.220.0.0-66.220.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 74.119.0.0-74.119.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 103.4.0.0-103.4.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 129.134.0.0-129.134.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 157.240.0.0-157.240.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 173.252.0.0-173.252.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 179.60.0.0-179.60.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 185.60.0.0-185.60.255.255 -j DROP
iptables -A INPUT -m iprange --src-range 204.15.0.0-204.15.255.255 -j DROP
####
iptables -A OUTPUT -m iprange --dst-range 31.13.0.0-31.13.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 45.64.0.0-45.64.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 69.63.0.0-69.63.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 69.171.0.0-69.171.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 66.220.0.0-66.220.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 74.119.0.0-74.119.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 103.4.0.0-103.4.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 129.134.0.0-129.134.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 157.240.0.0-157.240.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 173.252.0.0-173.252.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 179.60.0.0-179.60.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 185.60.0.0-185.60.255.255 -j DROP
iptables -A OUTPUT -m iprange --dst-range 204.15.0.0-204.15.255.255 -j DROP
 
Old 07-06-2017, 06:21 AM   #3
tomislav91
Member
 
Registered: Apr 2012
Posts: 46

Original Poster
Rep: Reputation: Disabled
can i put this ip tables into some bash script and run it. can i somehow run it for test and stop it? Or allow in iptables with same command?
 
Old 07-06-2017, 08:25 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,084
Blog Entries: 3

Rep: Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665Reputation: 3665
Do you want it in Squid or on each machine's packet filter? You can find out Faecebook's network:

Code:
host facebook.com
whois -h whois.radb.net 31.13.72.36
Then you can extract all the networks

Code:
whois -h whois.radb.net '!gAS32934' \
 | tr ' ' '\n' \
 | sed '/^[0-9]/!d' \
 | sort -t . -k1,1n -k2,2n -k3,3n -k4,4n \
 > /tmp/faecebook.ips
and add them to your Squid configuration or iptables. That's for the IPv4 networks only though.

Which version of Squid do you have?
 
  


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
squid drops connections to ip addresses, but allows connections to domain names igoryonya Linux - Networking 4 11-07-2014 06:10 PM
squid drops connections to ip addresses, but allows connections to domain names igoryonya Linux - Networking 2 11-06-2014 11:33 PM
LXer: Fake Digital Certificates Found in the Wild While Observing Facebook SSL Connections LXer Syndicated Linux News 0 05-14-2014 03:01 AM
blocking facebook on squid anis123 Linux - Server 1 09-10-2013 10:02 AM
Facebook and Squid privacy qwertyjjj Linux - Software 6 12-23-2009 07:29 PM

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

All times are GMT -5. The time now is 01:04 PM.

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