LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   n00b iptables question. (https://www.linuxquestions.org/questions/linux-security-4/n00b-iptables-question-4175439380/)

AsherSevyn 11-29-2012 07:39 PM

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.

smallpond 11-30-2012 10:50 AM

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.

AsherSevyn 11-30-2012 02:13 PM

So how would you phrase eth0 in this table?

descendant_command 11-30-2012 02:23 PM

Can you not simply configure squid to listen only on the internal interface?
Using iptables to deny access to closed ports is stupid. :)

smallpond 11-30-2012 02:45 PM

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.

fotoguy 12-02-2012 03:21 AM

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


All times are GMT -5. The time now is 01:03 PM.