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'm using centOS.

I want to implement a smtp mail server, and I have installed postfix and dovecot(both have been set correctly).

I tried to telnet the 25 port, but it returns Unable to connect to remote host: Connection refused

So, How can I open the 25 port? Thanks!

share|improve this question

4 Answers 4

up vote 3 down vote accepted

make sure postfix is listening on the external IP for port 25. By default it only looks on 127.0.0.1:25

If you have this

inet_interfaces = localhost

Put a # in front of that line and remove the comment from

#inet_interfaces = all

Then restart postfix

service postfix restart
share|improve this answer
    
I have done this setting already. –  liuxingruo May 10 '10 at 13:25

Assuming you actually have a service listening on that port you would do something like the following to open up the firewall if the ip of your server is 172.16.1.20:

sudo iptables -I RH-Firewall-1-INPUT 5 -p tcp -d 172.16.1.20 -m tcp --dport 25 -j ACCEPT

You want to list the rules with:

sudo iptables -L -n --line-numbers

To make sure you put it in the right place. Here is a tutorial that covers the basics of iptables with CentOS.

share|improve this answer
    
Note that sudo is not set up for any users in the default configuration on CentOS –  Ophidian May 10 '10 at 13:23
    
It returns iptables: No chain/target/match by that name –  liuxingruo May 10 '10 at 13:24
    
It would also be handy if you could run: netstat -nltp that will show what proceses are listening on what ports on TCP. –  Jason Tan May 10 '10 at 13:43
    
EN 1869/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LIST –  liuxingruo May 10 '10 at 13:52
    
Oh ya, after the change if all is good you want service iptables save –  Kyle Brandt May 10 '10 at 13:55

The easiest way to accomplish this on CentOS is probably to use this utility:

sudo /usr/bin/system-config-securitylevel-tui
share|improve this answer

Here's another solution

Edit

/etc/sysconfig/iptables

Add the following line in

-A INPUT -p tcp -m tcp --dport 25 --syn -j ACCEPT

Restart iptables

service iptables restart
share|improve this answer
    
Unloading iptables modules: Applying iptables firewall rules: iptables-restore: line 7 failed –  liuxingruo May 10 '10 at 13:51
    
I edited the line to put in your iptables script –  Mike May 10 '10 at 15:58

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.