LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 06-21-2008, 05:33 AM   #1
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 214

Rep: Reputation: 30
block port squid


using squid as proxy on linux.issue is I want to close port 3128 which is expose to internet n any out side user can connect it n surf internet.

pls. tell how to use iptable command to block outsider to connect that squid port.
 
Old 06-21-2008, 09:09 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 39,853

Rep: Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121
your internet firewall / router would be the place to do this, indeed if your squid server is an internal node than it's already implicitly "blocked" if you've not manually configutred your firewall to pass it through.
 
Old 06-21-2008, 12:41 PM   #3
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,891

Rep: Reputation: 68
Also, ‘‘http_access allow’’ is a good idea. I'd setup both that and iptables, just in case. You never know whether a security bypass will be found in Squid; neither you know when you will need to alter iptables configuration in a complicated enough way to ruin your filter.
 
Old 06-21-2008, 03:03 PM   #4
win32sux
Moderator
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
You can use http_port to specify which address you want Squid to listen on.

To use iptables as an additional layer of security on the box itself, you could use a rule which only allows IPs on your LAN to access Squid. It might look something like this:
Code:
iptables -I INPUT -p TCP -i eth0 --dport 3128 -s ! 192.168.1.0/24 -j DROP
But like acid_kewpie already said, it's kinda weird that you'd be needing to do stuff like this - unless your dedicated router/firewall is forwarding this port to the Squid box. If you explain to us what your actual network setup looks like, we'll be able to provide you with some better feedback.

Last edited by win32sux; 06-21-2008 at 03:26 PM.
 
Old 06-23-2008, 01:38 AM   #5
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 214

Original Poster
Rep: Reputation: 30
Nice win32sux,

My setup a linux box

Intrnet-----eth1(LinuxBOX)Public ip
LAN---------eth0(linuxBox)Private ip

I am using NAT to access internet from LAN, what I want to is block accessing default squid port from outside world on public ip. that's all

Pls. suggest now.
 
Old 06-23-2008, 02:07 AM   #6
win32sux
Moderator
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 367Reputation: 367Reputation: 367Reputation: 367
Quote:
Originally Posted by sunlinux View Post
Nice win32sux,

My setup a linux box

Intrnet-----eth1(LinuxBOX)Public ip
LAN---------eth0(linuxBox)Private ip

I am using NAT to access internet from LAN, what I want to is block accessing default squid port from outside world on public ip. that's all

Pls. suggest now.
Well in that case the simplest thing would be to use http_port to tell Squid to only listen on the private IP. You could then follow that up with an iptables rule to make certain that hosts on the WAN side couldn't connect to Squid even if it was listening on that address.
Code:
iptables -I INPUT -p TCP -i eth1 --dport 3128 -m state --state NEW -j DROP
This will do what you want, but in all honesty it is much better to simply firewall all unwanted connections on the WAN side (whitelisting instead of blacklisting).

Last edited by win32sux; 06-23-2008 at 02:12 AM.
 
Old 06-23-2008, 03:00 AM   #7
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 214

Original Poster
Rep: Reputation: 30
thanx that helped..
 
Old 06-23-2008, 03:06 AM   #8
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 214

Original Poster
Rep: Reputation: 30
hi can u gys help me a little more. I want to execute my NAT script at system start up. Currently I hv to run it after login into system.

Pls. help me out

usin REDHAT AS 4
 
Old 06-23-2008, 05:11 AM   #9
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,560

Rep: Reputation: Disabled
Put the script in /etc/rc.local file
 
Old 06-23-2008, 10:53 AM   #10
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,891

Rep: Reputation: 68
Or write it into an executable file in /etc/init.d directory and place a symlink (name must start with S) to it into /etc/rcS.d. The script will be called with single parameter ‘‘start’’.
 
Old 06-23-2008, 11:37 PM   #11
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 214

Original Poster
Rep: Reputation: 30
Hi I put my script in /etc/rc.local file

Like: /etc/script/./nat

but it didn't work.

??
 
Old 06-24-2008, 12:10 AM   #12
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,560

Rep: Reputation: Disabled
Quote:
Originally Posted by sunlinux View Post
Hi I put my script in /etc/rc.local file

Like: /etc/script/./nat

but it didn't work.

??
Remove the "." that you put infront of /nat.
 
Old 06-26-2008, 10:34 PM   #13
drokmed
Member
 
Registered: Dec 2005
Location: St Petersburg, FL, USA
Posts: 219

Rep: Reputation: 30
No firewall on that box? That's scary. Is ssh server installed? I bet your server gets attacked constantly. You should take a look at your logs, I bet they are huge.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to block yahoomail.com in squid sunlinux Linux - Networking 1 08-25-2007 04:21 PM
using squid to block p2p yawe_frek Linux - Software 2 08-15-2007 10:58 AM
Squid block sites linuxnirmal Linux - Security 5 11-15-2006 10:59 AM
debian iptables squid - redirect port 80 to port 8080 on another machine nickleus Linux - Networking 1 08-17-2006 12:59 AM
How can i block msn through squid linuxeagle Linux - Networking 5 04-08-2004 09:08 AM


All times are GMT -5. The time now is 05:18 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration