how to use postfix as a mail gateway with multiple IPs

Run multiple Postfix daemons on different ports/IPs

cp -pr /etc/postfix /etc/postfix2
vim /etc/postfix2/ and change
smtp inet n – n – – smtpd
27 inet n – n – – smtpd

mkdir /var/spool/postfix2 && chown root.postfix /var/spool/postfix2
mkdir -m 700 /var/lib/postfix2 && chown postfix.root /var/lib/postfix2

vim /etc/postfix/ and add
inet_interfaces =
smtp_bind_address =

vim /etc/postfix2/ and change
queue_directory = /var/spool/postfix2
data_directory = /var/lib/postfix2

and add
inet_interfaces =
smtp_bind_address =

also change any other setting, if necessary, like mynetworks or myorigin.

/etc/init.d/postfix restart
postfix -c /etc/postfix2 start
(use stop instead to stop it)

– make control scripts for postfix2 start/stop/restart
– make mailq for postfix2’s queue

* Use a load balancer to balance mails to all IPs
yum install haproxy

vim /etc/postfix/ and change
smtp inet n – n – – smtpd
26 inet n – n – – smtpd

vim /etc/haproxy/haproxy.cfg and delete everything AFTER the defaults section and add

listen postfix
mode tcp
balance roundrobin
option tcplog
# rate-limit sessions 5 #useful if you want to limit the incoming mail inject rate from another gw to 5/second
# backlog 100000 #to be used in conjunction with rate-limit
server postfix
server postfix2