LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-22-2008, 05:55 AM   #1
ochienged
Member
 
Registered: Oct 2007
Location: Plano, TX
Distribution: Fedora, CentOS, RHEL, Debian
Posts: 70

Rep: Reputation: 26
Squid restrictions and discriminating iptables rulesets


I am downed with the task of giving a group of employees where i work restriction to certain sites during working hours. Now here comes my questions:

1. How can i put down my "http_access" rules, having in mind that I need to restrict a certain range of IP's from accessing certain sites during working hours using squid. Consider, the scenario below:
Code:
acl RECEPTIONISTS src 192.168.0.20-192.168.0.30
acl WORK_HOURS time M T W H F 8:30-16:00
acl BAD_DOMAINS dstdom_regex -i "/etc/squid/bad_domains"
2. How can I configure iptables ruleset such that these range of IP's can't forward their requests directly to the gateway?
My problem is working with a range of IP addresses

Last edited by win32sux; 07-22-2008 at 06:12 AM. Reason: Changed QUOTE tags to CODE tags.
 
Old 07-22-2008, 06:15 AM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by ochienged View Post
1. How can i put down my "http_access" rules, having in mind that I need to restrict a certain range of IP's from accessing certain sites during working hours using squid. Consider, the scenario below:
Code:
acl RECEPTIONISTS src 192.168.0.20-192.168.0.30
acl WORK_HOURS time M T W H F 8:30-16:00
acl BAD_DOMAINS dstdom_regex -i "/etc/squid/bad_domains"
Basically you just use a deny rule like:
Code:
http_access deny RECEPTIONISTS WORK_HOURS BAD_DOMAINS

Quote:
2. How can I configure iptables ruleset such that these range of IP's can't forward their requests directly to the gateway?
My problem is working with a range of IP addresses
Assuming you mean through the gateway, here's an example:
Code:
iptables -I FORWARD -i eth0 -o eth1 \
-m iprange --src-range 192.168.0.20-192.168.0.30 -j REJECT

Last edited by win32sux; 07-22-2008 at 06:19 AM.
 
Old 07-22-2008, 07:08 AM   #3
ochienged
Member
 
Registered: Oct 2007
Location: Plano, TX
Distribution: Fedora, CentOS, RHEL, Debian
Posts: 70

Original Poster
Rep: Reputation: 26
Thanks a lot win32sux. All your responses worked well. If I may ask,
Quote:
What do I need to do to make the proxy server intercepting (or transparent)?
Considering that the internet gateway is also the mail server.

Last edited by ochienged; 07-22-2008 at 07:12 AM. Reason: Omission
 
Old 07-22-2008, 08:13 AM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
What do I need to do to make the proxy server intercepting (or transparent)?
Two things. First, you need to tell Squid you want it to run in transparent mode. How you do that depends on the version you have (let us know). Second, you need an iptables rule which redirects (to Squid) HTTP traffic which was meant to be NATed - something like:
Code:
iptables -A PREROUTING -p TCP -i $LAN_IFACE --dport 80 \
-j REDIRECT --to-ports 3128
 
Old 07-22-2008, 09:23 AM   #5
ochienged
Member
 
Registered: Oct 2007
Location: Plano, TX
Distribution: Fedora, CentOS, RHEL, Debian
Posts: 70

Original Poster
Rep: Reputation: 26
This means that the only thing that is not done is, setting squid to run in transparent mode. The version of squid am running is:
Quote:
[root@mail squid]# rpm -q squid
squid-2.6.STABLE6-5.el5_1.3
Its running on:
Quote:
CentOS release 5 (Final)
And my NAT table appears as shown below:
Quote:
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- 192.168.0.0 anywhere tcp dpt:http redir ports 3128
 
Old 07-22-2008, 05:14 PM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by ochienged View Post
This means that the only thing that is not done is, setting squid to run in transparent mode. The version of squid am running is:
Code:
[root@mail squid]# rpm -q squid
squid-2.6.STABLE6-5.el5_1.3
Then all you need to do is find the http_port line in your squid.conf and add "transparent" to it. Like, for example:
Code:
http_port 3128 transparent

PS: Please use CODE tags instead of QUOTE tags when posting output and stuff like that. It makes things display better and it makes it a lot easier to quote the relevant parts of your post when replying to it.

Last edited by win32sux; 07-22-2008 at 06:32 PM.
 
Old 07-31-2008, 02:25 AM   #7
ochienged
Member
 
Registered: Oct 2007
Location: Plano, TX
Distribution: Fedora, CentOS, RHEL, Debian
Posts: 70

Original Poster
Rep: Reputation: 26
Thanks a lot. I succeeded in my endeavours when in the iptables i redirect http requests to
Quote:
iptables -A PREROUTING -p TCP -i $LAN_IFACE --dport 80 \
-j REDIRECT --to-ports squidserver_ip:3128
 
  


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
iptables - interfaces, ports restrictions owbr4dh02 Linux - Security 9 02-04-2007 05:46 PM
Timed based access restrictions with squid & danguardian keithdj Fedora 3 04-19-2006 10:27 AM
Discriminating my flash drive! lbabey Linux - Newbie 1 07-30-2004 01:47 AM
Automating RuleSets to be loaded at startup. Seal-X Linux - Networking 2 05-12-2003 10:57 PM
Need some assistance with iptables rulesets... Diluted Linux - Networking 1 04-16-2003 07:53 AM

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

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