Bind an ip address to Postfix as outgoing ip

ip addresspostfix

Is that possible to bind all available public IP addresses on a server to one Postfix instance as its outgoing IP address pool and let it choose a random IP address or specified IP address from the pool each time it sends out an email?

If above is not possible, can it be configured to listen on one public IP address per instance and each time it delivers a message, it use the binded one as outgoing IP address?

Best Answer

If the ip addresses belongs to different subnets, the first could be done with multihop routing giving each outgoing line a weight depending on how often you want it to be used. You can check this chapter from the LARTC for more details.

Another way would be using the same default gateway each time and SNATing outgoing packets using iptables to one of your available ips from the pools using a round robin algorithm. This will also work no matter whether the ips belong to the same subnet or not.

On the other hand, running multiple instances of the mail server on the same machine doesn't seem like a good idea. In theory it could work but you have no real reason to do so and also, I don't think you can set a different routing table within each postfix instance so all outgoing mails would follow the normal hop route to the next relay server.

Related Topic