LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 09-03-2008, 01:51 PM   #1
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Rep: Reputation: 32
How to block ALL websites except 2


I would like to allow access to only 2 webites on my computer.

What is the simplest way to accomplish this?

Thanks
 
Old 09-03-2008, 02:05 PM   #2
w3bd3vil
Senior Member
 
Registered: Jun 2006
Location: Hyderabad, India
Distribution: Fedora
Posts: 1,191

Rep: Reputation: 49
I think if you play around with OpenDNS you will manage to achieve that in no time.
opendns.com

Just block all networks and then set the two domains you want to always allow on your opendns account.
 
Old 09-03-2008, 02:11 PM   #3
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
modify /etc/sysconfig/iptables
The following entries allow traffic from the two domains listed.

-A INPUT -s 172.35.111.239 -j ACCEPT
-A INPUT -s 172.35.111.233 -j ACCEPT

Also, use the /etc/hosts.allow and /etc/hosts.deny.
In the hosts.deny file you want to deny all by saying
all:all
The host.allow file migh tlook something like the one below. You need to add your IP's for each of the service you will be runnning. Add the netmask also.
#
# hosts.allow file for App Servers
#
ALL: localhost
in.rshd: 172.35.111.233/255.255.255.224 etc.... for each line.
bpcd:
bpbkar:
portmap:
lockd:
mountd:
rquotad:
statd:
snmpd:
 
Old 09-03-2008, 02:31 PM   #4
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Original Poster
Rep: Reputation: 32
Quote:
modify /etc/sysconfig/iptables
I do not have a directory named sysconfig. I am using Mepis Antix. Should I make the file?
 
Old 09-03-2008, 02:58 PM   #5
jkzfixme
Member
 
Registered: Sep 2006
Location: Orange County, NY
Distribution: Ubuntu, Solaris, Android
Posts: 329
Blog Entries: 21

Rep: Reputation: 52
I would use a proxy server like squid, wich is also easily administered with webmin

Regards
JKZfixme
 
Old 09-03-2008, 03:13 PM   #6
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
Quote:
Originally Posted by glenn69 View Post
I do not have a directory named sysconfig. I am using Mepis Antix. Should I make the file?
No, I doubt that would work. The files I mentioned are on the distros I work with. I 'thought' they were pretty universal. I was wrong.

Setting up a proxy sounds like another way to accomplish the task.
 
Old 09-03-2008, 04:24 PM   #7
voger
Member
 
Registered: Oct 2005
Distribution: Arch
Posts: 68

Rep: Reputation: 15
Maybe a stupid idea but how about playing with /etc/hosts.allow and /etc/hosts.deny?
http://www.itc.virginia.edu/unixsys/sec/hosts.html
 
Old 09-21-2015, 06:25 AM   #8
secretlydead
Member
 
Registered: Sep 2003
Location: Qingdao, China
Distribution: mandriva, slack, red flag
Posts: 249

Rep: Reputation: 31
Use dnsmasq. This is a really neat service.

On Debian/Ubuntu/Mint:

Code:
sudo apt-get install dnsmasq
edit /etc/dnsmasq.conf

add this line to make all sites redirect to localhost:

Code:
address=/#/127.0.0.1
add these lines to make specific sites use the DNS server at 8.8.8.8:

Code:
server=/allowed.com/8.8.8.8
then restart the dnsmasq service:

Code:
sudo service dnsmasq restart
 
Old 12-12-2019, 12:56 PM   #9
Kernel009
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by secretlydead View Post
Use dnsmasq. This is a really neat service.

On Debian/Ubuntu/Mint:

Code:
sudo apt-get install dnsmasq
edit /etc/dnsmasq.conf

add this line to make all sites redirect to localhost:

Code:
address=/#/127.0.0.1
add these lines to make specific sites use the DNS server at 8.8.8.8:

Code:
server=/allowed.com/8.8.8.8
then restart the dnsmasq service:

Code:
sudo service dnsmasq restart
Old thread but definitely one I needed to find! This almost does exactly what I am looking for - I need to block all web traffic but unfortunately this stops incominb TeamViewer sessions from working on the machine. Has anyone run into this and solved it? I'll of course keep digging but wanted to post here in case someone has invented that wheel already. I guess what I'm looking for is a way to disallow ALL EXCEPT, not just ALL. Or maybe it's a port that needs to be opened in the config?

Hm, think I actuall6y figured it out right after posting... seems the SERVER line does work on top of the ADDRESS line... I added server=/teamviewer.com/8.8.8.8 and restarted and it allowed it to connect!

Last edited by Kernel009; 12-12-2019 at 12:59 PM.
 
  


Reply



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
block ports or websites sujitkale Linux - Server 1 09-23-2007 06:23 AM
Allow only certain websites with squidgaurd and block alll other. karelvdm Linux - Networking 1 08-17-2007 09:26 AM
block certain websites in konqueror rcrummett Linux - Networking 3 12-31-2006 04:29 AM
How to block specific Websites? alfredh SUSE / openSUSE 3 06-24-2006 05:17 AM
how to block websites .. huno Linux - Software 5 04-22-2004 08:31 PM

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

All times are GMT -5. The time now is 03:17 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