LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 04-25-2006, 12:32 PM   #1
murphydims
LQ Newbie
 
Registered: Mar 2006
Posts: 3

Rep: Reputation: 0
Post using iptables how do i block file listing of websites?


Hi guys,
I have been informed one can block a list of sites listed/saved in a file by using firewall rules/iptables. i use redhat enterprise 3 and i have a set of firewall rules for internet sharing and security looks like this.

*filter
:INPUT DROP [117:62544]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1180:576525]
-A INPUT -m state --state ESTABLISHED -j ACCEPT
-A INPUT -m state --state RELATED -j ACCEPT
-A INPUT -i ! eth0 -m state --state NEW -j ACCEPT
-A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -o eth1 -m state --state RELATED -j ACCEPT
-A FORWARD -i eth1 -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o eth0 -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -d 64.235.230.106 -j REJECT --reject-with icmp-port-unreachable
COMMIT
# Completed on Tue Apr 11 15:46:43 2006
# Generated by iptables-save v1.2.8 on Tue Apr 11 15:46:43 2006
*nat
:PREROUTING ACCEPT [241:76631]
:POSTROUTING ACCEPT [15:5946]
:OUTPUT ACCEPT [53:31646]
-A POSTROUTING -o eth0 -j SNAT --to-source 80.190.56.192
COMMIT
# Completed on Tue Apr 11 15:46:43 2006
# Generated by iptables-save v1.2.8 on Tue Apr 11 15:46:43 2006
*mangle
:PREROUTING ACCEPT [1322:573941]
:INPUT ACCEPT [1191:541126]
:FORWARD ACCEPT [131:32815]
:OUTPUT ACCEPT [1190:582879]
:POSTROUTING ACCEPT [1331:616335]
COMMIT
# Completed on Tue Apr 11 15:46:43 2006

so eth0 is the external card while eth1 is the lan card on which i have workstations but dont know how to include a rule to block workstations only from browsing any of the sites listed and saved in the file :- sites.txt

NB: its easier this way because i have a wide range of sites that needs to be blocked wont do to set rule for each one by one. pls need help.
murphy.

Last edited by murphydims; 04-25-2006 at 12:36 PM.
 
Old 04-25-2006, 04:09 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
As far as I am aware, you have either been misinformed or misinterpreted what was meant.

IPTABLES is a kernel function, and does not dynamically read files for data. You can create a script to transform a list of IP addresses into a block list, which can be loaded by IPTABLES. However, large rule sets can significantly impact network performance and consume memory.

If you simply want to remove the directory listing from a web site, then remove the 'Options Indexes' from the web server configuration (if you have access to it).
 
Old 04-25-2006, 05:58 PM   #3
DaveG
Member
 
Registered: Nov 2001
Location: London, UK
Distribution: Fedora
Posts: 161

Rep: Reputation: 43
If you want to _enforce_ a security policy for HTTP, then the best way is to set up a proxy such as squid or privoxy. I belive both can be configured to block sites based on a dynamic list, possibly in their own formats. Once configured and running you can "force" users to use it by turning off all HTTP forwarding and provide "proxy autoconfigure" facilities. Users need only change one setting in their browser. I use privoxy and I can add and remove blocked sites on-the-fly. Users benefit from faster web pages since most of the advertising is filtered out for them. Squid provides a local cache and hooks for all kinds of filters and blocks.

I believe there is an iptables module (ipt_filter?) that can block connections by matching regular expressions in the data stream, but it's not widely used and difficult to make it work well.
 
Old 04-26-2006, 10:23 AM   #4
murphydims
LQ Newbie
 
Registered: Mar 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Exclamation how do you block sites with proxy?

Thanks for the tip but one thing is "How do i block sites with proxy?"
 
Old 04-26-2006, 11:49 AM   #5
DaveG
Member
 
Registered: Nov 2001
Location: London, UK
Distribution: Fedora
Posts: 161

Rep: Reputation: 43
Privoxy was designed mainly to improve web privacy. It comes complete with a set of default filters that list known "problem" sites, known advertising strings and image sizes etc.

All you need to do is configure your browser to use the proxy, usually port 8118 for privoxy, and see what gets through. Anything you don't want, find the web address and add it to privoxy's user configuration through the built-in web interface. Adding a name like ".hacked-site.com" to the "block" list will block all sites whose domain name ends with .hacked-side.com, replacing it with an information page to tell the user what happened and how to change it. There are plenty of filtering options but basic allow/block is the best place to start.
 
  


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
How to block Firefox to visit some websites? yumener Linux - Networking 1 03-11-2006 05:18 AM
IPTables and PPTPD :S (to block or not to block) thewonka Linux - Networking 0 03-24-2005 06:58 PM
iptables is not listing to me pietsebrie Fedora 4 11-18-2004 01:03 AM
why does shorewall block my websites and vsftp stop postfix? Michele Linux - Newbie 5 06-18-2004 12:01 AM
how to block websites .. huno Linux - Software 5 04-22-2004 08:31 PM

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

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