Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was wondering if someone could help me with the following iptables rule:

We would like to allow ANY and ALL locally originating (as in, on the server running iptables) traffic.

DNS, HTTP, etc... all of it. Any connection initiated by the server running iptables should be allowed.

Currently we are using basically OUTPUT default policy, ACCEPT. Is this correct? Inputs are blocked, so I am assuming this means that the connections (except those we allow) cannot be started because they will be dropped before our side can hit the OUTPUT policy?

Sorry, my iptables skills are weak ;)

Thank you kindly.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

You need two rules to do that:

iptables -I OUTPUT -o eth0 -d 0.0.0.0/0 -j ACCEPT
iptables -I INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

Some notes.

  • Preexisting rules that you may have may do this already, but look different.
  • This uses -I to force these rules to be first. iptables rules are evaluated top down.
  • The -o and -i flags mean "out" and "in" respectively. Replace eth0 with the proper ethernet interface name.
share|improve this answer
    
we have both :) i failed to mention the 2nd one because like i said... my iptables skills are weak sauce. thanks for the clarification :) –  anonymous-one Sep 18 '12 at 11:43
add comment

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.