How to open port 25 on the server

56,134

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.

Share:
56,134

Related videos on Youtube

liuxingruo
Author by

liuxingruo

Updated on September 17, 2022

Comments

  • liuxingruo
    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
    Ophidian about 14 years
    Note that sudo is not set up for any users in the default configuration on CentOS
  • liuxingruo
    liuxingruo about 14 years
    It returns iptables: No chain/target/match by that name
  • liuxingruo
    liuxingruo about 14 years
    I have done this setting already.
  • Secoe
    Secoe about 14 years
    It would also be handy if you could run: netstat -nltp that will show what proceses are listening on what ports on TCP.
  • liuxingruo
    liuxingruo about 14 years
    Unloading iptables modules: Applying iptables firewall rules: iptables-restore: line 7 failed
  • liuxingruo
    liuxingruo about 14 years
    EN 1869/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LIST
  • Kyle Brandt
    Kyle Brandt about 14 years
    Oh ya, after the change if all is good you want service iptables save
  • Mike
    Mike about 14 years
    I edited the line to put in your iptables script
  • liuxingruo
    liuxingruo about 14 years
    service iptables save still not work.
  • Aakash
    Aakash over 6 years
    This answer is pretty old, but solved my problem. Thank you @mike