LinuxQuestions.org
Visit Jeremy's Blog.
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-21-2004, 04:15 AM   #1
mchitrakar
Member
 
Registered: Mar 2004
Posts: 93
Blog Entries: 1

Rep: Reputation: 15
access and deny


Hi

I need to disable porn sites as per our company's policy. Is there any way through squid to disable? Also can I disable http access to some computers also? please send me some examples also. Thank you
 
Old 04-21-2004, 06:41 PM   #2
TheIrish
Member
 
Registered: Oct 2003
Location: ITALY
Distribution: Debian, Ubuntu, Fedora
Posts: 137

Rep: Reputation: 15
Hi,
I'm not actually a squid expert... though I'd love to.
As far as I know, you should use this kind of syntax:

Code:
acl badURL url_regex -i sex
http_access deny badUrl
http_access allow myNet
http_access deny all
In this code above, I deny all urls containing the word "sex". Obviously, the only way you can deny access to porn sites is parsing the words and this means that something might pass through; safe 99% anyway, I believe.
Reguarding the second question, there are more then one way for not allowing http traffic.
The easiest way is:
assuming your clients cannot change their ip addresses, you can use iptables to filter.
example:
Code:
iptables -I FORWARD -s 192.168.0.5 --dport 80 -j DROP
this line denies http traffir from host 192.168.0.5.
Or, using squid:
Code:
acl theweb proto HTTP
acl thebadip src 192.168.0.5
http_access deny theweb
http_access allow all
In both solutions, you must be sure that the bad client won't be able to change it's own ip.
If you really are an evil one, you can try this with iptables:
Code:
iptables -A INPUT -m mac --mac uu:vv:ww:xx:yy:zz --dport 80 -j DROP
Well, I hope i didn't type any mistake as usual.
Good Luck!
 
Old 04-22-2004, 06:13 AM   #3
mchitrakar
Member
 
Registered: Mar 2004
Posts: 93

Original Poster
Blog Entries: 1

Rep: Reputation: 15
still new problem

thank you for your suggestions. I have included your script into my squid.conf in /etc/squid/ and restarted the computer. BUt nothing happens.
please help me.
 
Old 04-22-2004, 07:01 AM   #4
silver2003
LQ Newbie
 
Registered: Apr 2004
Location: Romania
Distribution: RedHat 7.3
Posts: 28

Rep: Reputation: 15
You could use this command in you iptables script to redirectionate the porn sites to a another site like www.google.com

iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d www.newpornstars.com -j DNAT --to-destination www.google.com

As for the http acces i can't help you with that.

And if don't want that you network client not change theirs ip you coul use the "arp". To get the arp you first type "arp -e" to see theirs ip and mac address, or for more informations you could se tha man pages


This are some exemplase, the comand must be like this "arp -s 192.168.0.27"

[comand] [theirs IP] [MAC ADDRESS]

arp -s 192.168.0.27 00:40:F4:85:35:EC
arp -s 192.168.0.4 00:50:BF:20:B29

Those comands must be run when the server starts and you should put this commands in an initilizing script.

And if you want only some of the computers have internet you could use this comand in your iptables script:

iptables -t nat -A POSTROUTING -s 192.168.0.11 -j SNAT --to-source 197.31.125.8(this is the public address)

And you must quit using MASQUERADE if you use the command above.

CYA
 
Old 04-22-2004, 07:14 AM   #5
TheIrish
Member
 
Registered: Oct 2003
Location: ITALY
Distribution: Debian, Ubuntu, Fedora
Posts: 137

Rep: Reputation: 15
mmm... silver....
I was wondering how iptables can do...
Quote:
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -d www.newpornstars.com -j DNAT --to-destination www.google.com
it cannot resolve names... unless you altered your kernel with some kind of patch... let me know, 'cuz i'd love that patch too!

mchitrakar, maybe the problem is in the way squid is configured. Assuming you customized the scripts i gave you (assigning MyNet with your network address, adding more words to be blocked etc.) the only thing I can think about is squid is not analyzing any traffic.
So, a few hints:
1. check if the global configuration is correct (traffic is really passing through it?)
2. check if there are other rules contrasting with the new ones. Remember the rules are checked TOP-DOWN: the first match rulez.

Let us know!
 
Old 04-23-2004, 01:31 AM   #6
mchitrakar
Member
 
Registered: Mar 2004
Posts: 93

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Thanks for replies. I dont know how but i have found that it did worked.
But temporarily. When first accessing, there showed timed out error !!! (:-)
But again if I refresh it, alo!! and the page is accessed. (:-(
So I was thinking of producing "ACCESS DENIED because you surfed..."
on the web page of client instead of timed out error. How can we acheive this? And how can we fully block such sites even after refreshing...?
 
Old 04-23-2004, 04:05 AM   #7
silver2003
LQ Newbie
 
Registered: Apr 2004
Location: Romania
Distribution: RedHat 7.3
Posts: 28

Rep: Reputation: 15
"Also can I disable http access to some computers also? please send me some examples also."

Ofcourse you can do that i have read some of the Iptables HOWTO and i have write the next command:

iptables -A INPUT -p tcp --destination-port 80 -s 192.168.0.4(network IP client) -j DROP

This command don't allows acces on port 80 from 192.168.0.4 machine.
and you can do this for every machine that you don't want to acces http. Http is working on port 80 on tcp protocol.

TheIrish if you cannot resolve names you could you the sites ip and is much better because an machine can hold more then one site with the same IP address.

mchitrakar if that haven't work then try this comand in you iptables script:

iptables -A OUTPUT -p tcp --destination-port 80 -d 215.191.81.125(the porn site ip) -j DROP

Please send me a msg if it works.

CYA

Last edited by silver2003; 04-23-2004 at 04:17 AM.
 
Old 04-23-2004, 07:54 PM   #8
mchitrakar
Member
 
Registered: Mar 2004
Posts: 93

Original Poster
Blog Entries: 1

Rep: Reputation: 15
yeah..thank you..silver...your last code worked...but not the code snippet for squid.conf. Main problem with iptables banning sites is that i cannot undo it back. Can you send me code to undo it? Moreover, there was time out error instead of ACCESS DENIED type of message I would like to display.
 
Old 04-24-2004, 03:53 AM   #9
silver2003
LQ Newbie
 
Registered: Apr 2004
Location: Romania
Distribution: RedHat 7.3
Posts: 28

Rep: Reputation: 15
To show them acces denied you should have an webpage. And you will derectionate the porn sites to that webpage in what it will write ACCES DENIED. Another way i don't know it.

CYA
 
  


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
Deny a host access to all services objorkum Linux - Networking 5 08-17-2007 02:54 PM
Squid Deny Access but... Roach Linux - Software 4 11-23-2004 12:18 PM
Deny Webpage Access thebrave65 Linux - Security 5 05-20-2003 12:51 PM
deny this fruitcake access hux Linux - Networking 3 02-11-2002 03:08 PM
Deny access by IP address plisken Linux - Security 1 12-29-2001 10:11 PM

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

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