How to Configure Postfix to use an Alternate Port for SMTP

Linux Servers

​Configure Postfix to use an alternate port for SMTP

  1. Log into your server as root, or any other user with the ability to sudo.
  2. CD to /etc/postfix/
  3. Create a backup of master.cf (cp master.cf master.cf-bak)
  4. Open master.cf with a text editor
  5. Find the line labeled: "smtp     inet     n......"
  6. Just below the line, insert a new line containing the following:
    • 2525     inet     n     -     n     -     -     smtpd
  7. 2525 can be changed to match the port that you wish to use.
  8. Save the file, and exit the text editor.
  9. Run "/etc/init.d/postfix restart" to restart Postfix.

Configure the firewall to accept incoming connections

  1. Add the new port to iptables by running: "iptables -A INPUT -p tcp --dport 2525 -j ACCEPT", changing 2525 to the port you choose. 
  2. Run "/etc/init.d/iptables save" to save the rule.
  3. Run "/etc/init.d/iptables restart" to apply the new rule.

Add Feedback