Force outgoing mail to come from a specific IP

Add an iptables rule such as:

[code lang=”bash”]iptables -t nat -A POSTROUTING -p tcp -s ! 127.0.0.1 –dport 25 -j SNAT –to-source 65.61.180.228[/code]

This will make all outgoing mail leave over the secondary IP, 65.61.180.228, as opposed to the primary IP address of the server (the standard behavior of MTAs).

Leave a Reply