Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a server with multiple interfaces (IPs). I'd like to block all ports on one of the IPs (I don't want to change anything for other IPs/interfaces), but allow outgoing connections from it. For example, it should be possible to run a IRC client from it, but it should not be possible to simply connect to it from the outside (I'll be connecting from a whitelisted IP).

This is what I got until now:

Chain INPUT (policy ACCEPT)
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
DROP       all  --  0.0.0.0/0            IP

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED

But these rules don't work. Even when I initiate a connection from this IP, the remote server can't connect back, despite I'm allowing RELATED/ESTABLISHED connections. What's wrong?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

First of all, default policy for OUTPUT Chain is ACCEPT, so the last line:

ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED

isn't necessary.

Then the first line:

ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED

is redundant too because default policy for INPUT is ACCEPT.

Try with only these two rules and see if it helps:

iptables -A INPUT -d IP -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -d IP -j DROP
share|improve this answer

Are you specifically having an issue with IRC connections? The IRC server you're trying to connect to may be requiring you to run an ident server. Most IRC clients fake one. Try allowing incoming connections on port 113 and see if it improves.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.