Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using gmail as a relay to send mail through postfix. I can send mail when the firewall is down, but I can't when its up. What should I add to these iptables rules to send mail?

*filter

:INPUT DROP [14:1434]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]

#SSH
##HOME
  -A INPUT -i eth0 -p tcp -s 1xx.1xx.1.xx/255.255.255.0 --dport 9991 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A OUTPUT -o eth0 -p tcp --sport 9001 -m state --state ESTABLISHED -j ACCEPT

##PSd
  -A INPUT -i eth0 -p tcp -s xx.xxx.xxx.xxx/255.255.255.0 --dport 9991 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A OUTPUT -o eth0 -p tcp --sport 9991 -m state --state ESTABLISHED -j ACCEPT

#HTTP
  -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED,RELATED -j ACCEPT

#HTTPS
  -A INPUT -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A OUTPUT -o eth0 -p tcp --sport 443 -m state --state ESTABLISHED,RELATED -j ACCEPT


#Loop Back (FOR MY SQL!!)
  -A INPUT -i lo -j ACCEPT
  -A OUTPUT -o lo -j ACCEPT

#Stopping DDOS
  -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
  -A INPUT -p tcp --dport 443 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT

#Allowing Mail
  -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A OUTPUT -o eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A INPUT -i eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT

# DNS
-A INPUT -p tcp -m tcp --sport 53 -j ACCEPT
-A INPUT -p udp -m udp --sport 53 -j ACCEPT

#apt-get
-A INPUT -p tcp --sport 80 -j ACCEPT

COMMIT

Here's something I tried

-I OUTPUT -p tcp --dport 465 -j ACCEPT
-I OUTPUT -p tcp --dport 587 -j ACCEPT

And obviously, this rule does nothing right now

#Allowing Mail
  -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A OUTPUT -o eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
  -A INPUT -i eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT

I've searched a lot, and variations of the aforementioned rules are all that I found. I apologize if this is a beginner problem.

Also this happens with my firewall up

johndoe@serve:/home$ host -t mx gmail.com
gmail.com mail is handled by 20 alt2.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 30 alt3.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 5 gmail-smtp-in.l.google.com.
gmail.com mail is handled by 40 alt4.gmail-smtp-in.l.google.com.
gmail.com mail is handled by 10 alt1.gmail-smtp-in.l.google.com.

If there's more information needed to answer this question let me know!!

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.