LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-05-2007, 03:32 PM   #1
aaron4katie
Member
 
Registered: Dec 2006
Location: Bristol, England
Distribution: Fedora Core 6
Posts: 77

Rep: Reputation: 15
How To Block Websites? Maybe /etc/hosts (.deny maybe) How?


How do I block websites, I am using Fedora Core 6, using Firefox 2, in Windows I know that a /etc/hosts files in system32 controls which sites are allowed or blocked by searching google. In Linux I found some host files in /etc directory. How do I use it or block sites another way?
 
Old 01-05-2007, 03:37 PM   #2
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,734
Blog Entries: 12

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
The /etc/hosts works the same as the HOSTS file in windows, just add the sites you want blocked:
127.0.0.1 example.com

Of course you could also use dansguardian and squid to do the same thing, but that takes a little more to set up.
 
Old 01-05-2007, 05:37 PM   #3
aaron4katie
Member
 
Registered: Dec 2006
Location: Bristol, England
Distribution: Fedora Core 6
Posts: 77

Original Poster
Rep: Reputation: 15
Every example I see has an IP then a website, is the IP needed, is it the websites server IP or is it the Networks IP.. the Network that isn't allowed to access the site?

Just to make the question simpler.. Do I need an IP and who's IP is it. If it is the websites and needed, no problem.
 
Old 01-05-2007, 06:25 PM   #4
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid
Posts: 4,734
Blog Entries: 12

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Example/part of my /etc/hosts file:

127.0.0.1 localhost.localdomain localhost
# This MVPS HOSTS file is a free download from: #
# http://www.mvps.org/winhelp2002/ #
#start of lines added by WinHelp2002
# [Misc A - Z]
127.0.0.1 ad.a8.net
127.0.0.1 asy.a8ww.net
127.0.0.1 www.abcsearcher.com #[Spamdexing][Microsoft.Strider]
127.0.0.1 www.acezip.net #[Win32/Adware.180Solutions]
127.0.0.1 adserver.adbunker.com
127.0.0.1 phpadsnew.abac.com

The hosts file in Linux (/etc/hosts) is a simple list of IP addresses and the hostnames that they correspond to. Every hosts file in Linux should have an entry for the IP address "127.0.0.1", with the name "localhost" following it. This is also known as the loopback address. That same file may also have an entry for your system name, unless you did not provide one during installation.

Last edited by craigevil; 01-05-2007 at 06:32 PM.
 
Old 01-06-2007, 07:15 AM   #5
aaron4katie
Member
 
Registered: Dec 2006
Location: Bristol, England
Distribution: Fedora Core 6
Posts: 77

Original Poster
Rep: Reputation: 15
ok, so the IP is the same every time and is the localhost IP. Basically I just use the IP from this line 127.0.0.1 localhost.localdomain localhost and add the sites after.. is it possible to block something like *.*porn*.* instead of each individual www.crapornsiteinthe.net
 
Old 01-06-2007, 07:49 AM   #6
live_dont_exist
Member
 
Registered: Aug 2004
Location: India
Distribution: Redhat 9.0,FC3,FC5,FC10
Posts: 257

Rep: Reputation: 30
You'll have to use Squid I believe.
 
Old 01-06-2007, 02:14 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
/etc/hosts entries (or iptables OUTPUT chain rules) are a nice and quick solution for blocking just a few hosts.

Blocking something like
Quote:
*.*porn*.*
requires more flexibility, and I'll agree with the solution that was already suggested several times: squid. It's well documented and lots of folks use it.
 
Old 01-08-2007, 04:58 PM   #8
aaron4katie
Member
 
Registered: Dec 2006
Location: Bristol, England
Distribution: Fedora Core 6
Posts: 77

Original Poster
Rep: Reputation: 15
Well my hosts file is working OK.

I don't know how to use Squid, is it an external program.. because I cannot find a way to open it. If it is a part of SELinux then I don't know how to edit it for certain bans.

Also could I get it to ban say.. the word porn but still allow anti-porn...say?
 
  


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
/etc/hosts.deny/hosts.allow have no effect on sshd access bganesh Linux - Security 4 05-04-2006 08:06 PM
Block country's with hosts.deny narmida Linux - Security 7 03-02-2006 10:01 AM
hosts.allow & hosts.deny question... jonc Linux - Security 9 03-05-2005 09:41 PM
hosts.deny doesn't block an SSH attempt vmattila Linux - Security 4 11-14-2004 12:18 PM
Adding shell commands to hosts.deny and hosts.allow ridertech Linux - Security 3 12-29-2003 03:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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