Changing postfix's incoming smtp port

CC-BY-4.0 by Peter Molnar () at
#mailserver #postfix

Which line to change to have Postfix listen on specific ports are well?

This is one of the most simple tasks, yet I had to Google around for hours: change the incoming port of postfix’s SMTP, without iptables prerouting.

Open /etc/postfix/, and search for the following line (usually the first uncommented line):

smtp    inet    n   -   -   -   -   smtpd

To change the port, simply write the number instead of smtp in the begining.

For example:

2525    inet    n   -   -   -   -   smtpd

Restart postfix

/etc/init.d/postfix restart

and the system can not accept messages on the port you added. Don’t forget to enable the port on your firewall, if you have one!