Bind Postfix Mail Server To Localhost or Specific IP Address Only

Q. How do I bind Postfix MTA to specific IP address such as 127.0.0.1 or 202.5.1.2?

A. Postfix allows you to listen on a particular IP address. By default MTA will list on all network interfaces and loopback. You need to setup inet_interfaces parameter. You need Postfix version 2.2 and later to use this feature. The parameter also controls delivery of mail to user@[ip.address].

Postfix IP address bind configuration

Open /etc/postfix/main.cf file:
# vi /etc/postfix/main.cf
Append / modify line as follows to bind to localhost (127.0.0.1) only:
inet_interfaces = 127.0.0.1
If you need to bind to 127.0.0.1 and 202.5.1.2, enter:
inet_interfaces = 202.5.1.2,127.0.0.1
Save and close the file. You need to stop and start Postfix when this parameter changes. So type the following to restart Postfix:
# /etc/init.d/postfix restart
Verify that everything is working fine:
# netstat -tulpn | grep 25
# tail -f /var/log/maillog


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • neeeko Jun 2, 2011 @ 15:30

    OK.
    But what about this :

    OPenVPN client is active and a new tap0 interface has been created.

    Even if you have specified the parameters in main.cf, your Postfix will not receive nor send any email…

    How to fix this ?

  • Todd Aug 12, 2011 @ 13:49

    Thank you for the great explanation. I would like to segragate my email domains, can you give you an expand on this a bit further and explain how you bind 1 unique ip address to 10 domains in Postfix, rather than 1 ip’d domain with 9 virtual addresses?

    Thank you in advance for any tips.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum