LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial 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
 
Search this Thread
Old 11-29-2012, 07:39 PM   #1
AsherSevyn
LQ Newbie
 
Registered: Jul 2010
Posts: 26

Rep: Reputation: 0
n00b iptables question.


I am setting up a new squid daemon to run on my server. I want to make sure that everyone inside my network can access squid but I want to make sure everyone on the internet is blocked.

eth0 is connected to my internal LAN via: 192.168.0.5/255.255.255.0
eth1 is connected to the internet via: 1.1.1.1/255.255.255.248
Squid listens on port 3124

Is this the correct syntax for doing that?:

iptables -F
iptables -t nat -F
iptables -X
iptables -P FORWARD DROP
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 3124 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

As you can probably see I prefer to block everything except for what I'm actually using.

The tricky part is I'm not sure how to block everyone on the net but allow everyone on my local network access to squid.

Thanks in advance.
 
Old 11-30-2012, 10:50 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 1,536

Rep: Reputation: 375Reputation: 375Reputation: 375Reputation: 375
You can specify '-i eth0' in a rule to have it only apply to packets coming in on that port. iptables can get so complicated that I'm not sure there is anything other than n00b questions.
 
Old 11-30-2012, 02:13 PM   #3
AsherSevyn
LQ Newbie
 
Registered: Jul 2010
Posts: 26

Original Poster
Rep: Reputation: 0
So how would you phrase eth0 in this table?
 
Old 11-30-2012, 02:23 PM   #4
descendant_command
Member
 
Registered: Mar 2012
Posts: 796

Rep: Reputation: 180Reputation: 180
Can you not simply configure squid to listen only on the internal interface?
Using iptables to deny access to closed ports is stupid.
 
Old 11-30-2012, 02:45 PM   #5
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 1,536

Rep: Reputation: 375Reputation: 375Reputation: 375Reputation: 375
Theres's nothing wrong with only opening the port on the internal interface. Should just be:

Code:
iptables -A INPUT -p tcp -i eth0 --dport 3124 -j ACCEPT
I do something like this for DNS.
 
Old 12-02-2012, 03:21 AM   #6
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: KirraMail Live Email Server
Posts: 1,279

Rep: Reputation: 61
You can add a line to only except from the local network

Quote:
iptables -A INPUT -i eth0 -p tcp -s 192.168.0.0/24 --dport 3124 -j ACCEPT
 
  


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
n00b question FD_Doc Linux - Newbie 5 11-20-2005 05:09 PM
N00b question Bendert_katier Linux - Software 7 11-01-2004 01:06 AM
iptables n00b Jestrik Linux - Software 3 12-12-2003 09:58 PM
just another n00b question BriceM LinuxQuestions.org Member Intro 2 08-23-2003 09:00 PM
n00b Question sandy_obrien Linux - General 6 08-18-2003 12:19 PM


All times are GMT -5. The time now is 09:46 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 Google+: linuxquestions
Open Source Consulting | Domain Registration