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.

My iptables is causing postfix server not to send emails.

A problematic mail.log line is:

Mar 1 06:19:44 server postfix/smtp[9744]: 3D62CA06CA9: to=, relay=none, delay=42, delays=2.3/0.01/40/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again)

I found the other guy's explanation on how to fix this.

He proposed:

SERVER_IP="202.54.10.20"
DNS_SERVER="202.54.1.5 202.54.1.6"
for ip in $DNS_SERVER
do
iptables -A OUTPUT -p udp -s $SERVER_IP --sport 1024:65535 -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp -s $ip --sport 53 -d $SERVER_IP --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT-p tcp -s $SERVER_IP --sport 1024:65535 -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp -s $ip --sport 53 -d $SERVER_IP --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
done

Isn't there any simpler rule without using the IP?

Thank you very much.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Firewall paranoia doesn't really work if you don't even understand your firewall.

Just set the OUTPUT policy to ACCEPT and allow ESTABLISHED traffic back in.

share|improve this answer
    
Thanks. Now I have ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED and since my OUTPUT policy is ACCEPT so everything now works. –  valk Mar 1 '12 at 14:15

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.