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.

This question may have been asked many times here but after several failed attempts, I repeat the history:

How do I open port 25 port on my server running CentOS.

Here is my iptables config:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
REJECT     all  --  anywhere             loopback/8          reject-with icmp-port-unreachable 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp 
ACCEPT     icmp --  anywhere             anywhere            
LOG        all  --  anywhere             anywhere            limit: avg 5/min burst 5 LOG level debug prefix `iptables denied: ' 
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp-data 

Here is the output of sudo netstat -plntu

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1283/nginx          
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1039/sshd           
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      5981/master         
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      1297/php-cgi        
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1177/mysqld         
tcp        0      0 :::22                       :::*                        LISTEN      1039/sshd           
tcp        0      0 :::25                       :::*                        LISTEN      5981/master 

Whenever I try to telnet like this

telnet 158.549.236.54 25

the connection times out. The IP used here is random.

share|improve this question
    
Are you sure that there is no firewall outside the server blocking this? –  SvW Mar 13 at 17:46
    
I don't think so. Is there a way i can check that? –  beNerd Mar 13 at 17:47
    
Where is the server located? How is it connected to the net? –  SvW Mar 13 at 18:36
    
Its in new york from digital ocean. –  beNerd Mar 14 at 5:29

3 Answers 3

The problem is not with your firewall (you appear to have added a rule at the top which allows all traffic).

You main problem is that port 25 is only listening on 127.0.0.1 and ::1, which are both localhost. You need to configure your SMTP server to listen on the 158.549.236.54 interface (or all interfaces)

share|improve this answer
    
and how do i do that? –  beNerd Mar 13 at 16:51
    
I edited my postfix configuration but it still doesn't work. I updated my answer with the output of sudo netstat -plntu –  beNerd Mar 13 at 17:17

Configuration seems fine (firewall allows all traffic and mail server exposed on :25), most likely your ISP is blocking traffic to mail port (for fighting spam purposes).

A workaround is to add a NAT redirect in your server from a random port (say 2525) to port 25 iptables -t nat -I PREROUTING -p tcp --dport 2525 -j REDIRECT --to-port 25 and then try telnetting to that port: telnet ip 2525

share|improve this answer

I strongly suspect that the problem is your firewall rules. Although the first rule appears to allow everything, this is why the output of iptables -L is worse than useless for diagnosing these problems - it doesn't give interface restrictions.

I suspect that if you were to paste in the output of iptables -L -n -v instead, we'd see that that first rule applied to traffic only on the loopback interface.

Try

iptables -I INPUT 1 -p tcp --dport 25 -j ACCEPT

and see if that fixes anything.

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.