Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to allow mail through iptables?
    primarykey
    data
    text
    <p>I'm securing my server (with iptables) so that only http and ssh ports are open and that is fine, although I use the <code>mail</code> command (server: CentOS 6.2) in some applications and it does not get through now thanks to iptables blocking everything.</p> <p>What ports do I allow it access to?</p> <p>Mail usage: <code>echo "{{message}}" | mail -s "{{subject}}" me@mail.com</code></p> <p>I've tried the standard mail port 25, but I have had no success with that. Here is the current setup:</p> <pre><code>iptables --flush iptables -P INPUT DROP iptables -P OUTPUT DROP # incoming ssh iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT # outgoing ssh iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT #HTTP iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT # mail (does not work) iptables -A INPUT -i eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT </code></pre> <p><strong>(EDIT) ANSWER: The working iptables rule:</strong> </p> <pre><code>iptables -A OUTPUT -o eth0 -p tcp --sport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -o eth0 -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A INPUT -i eth0 -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload