How to open port 25 on the server
Solution 1
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
Solution 2
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.
Related videos on Youtube
liuxingruo
Updated on September 17, 2022Comments
-
liuxingruo almost 2 years
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!
-
Ophidian about 14 yearsNote that sudo is not set up for any users in the default configuration on CentOS
-
liuxingruo about 14 yearsIt returns iptables: No chain/target/match by that name
-
liuxingruo about 14 yearsI have done this setting already.
-
Secoe about 14 yearsIt would also be handy if you could run: netstat -nltp that will show what proceses are listening on what ports on TCP.
-
liuxingruo about 14 yearsUnloading iptables modules: Applying iptables firewall rules: iptables-restore: line 7 failed
-
liuxingruo about 14 yearsEN 1869/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LIST
-
Kyle Brandt about 14 yearsOh ya, after the change if all is good you want
service iptables save
-
Mike about 14 yearsI edited the line to put in your iptables script
-
liuxingruo about 14 yearsservice iptables save still not work.
-
Aakash over 6 yearsThis answer is pretty old, but solved my problem. Thank you @mike