When I was dealing with another mailserver I take care of I discovered that my own setup use seemingly random ip’s to ship out my mail. I don’t like that so I dug into how to change that and came up with a solution working. For me was the solution to add options to 2 entries in the master.cf, namely “smtp” and “relay”. To those I added the following statements as options:
-o smtp_bind_address=100.75.2.22 -o smtp_bind_address=2001:0db8:85c3:08d3:13a9:8a2e:0350:7344
The first option is for IPv4 and the second is for IPv6. While here it would be allowed to use brackets it is discuraged to do so in the documentation. You need to replace the IPv6 and IPv4 with your own IP addresses. If you also want to set the preference which IP-version gets used by the outgoing connection, you can do so by adding the following to the previous options:
With this it would be IPv6 then IPv4 (if IPv6 doesn’t work/is not available). The default is for this setting “any”, meaning that postfix will try randomly. You can also set it to “ipv4” for a IPv4 preference.
The options shown here should be also compatible with setups using AmaViS. I do use it and didn’t had to change anything, and couldn’t so far detect any negative influence. Setting the smtp_bind_address(6) in the main.cf can have negative effects on AmaViS; I found this during my search around how to deal with this.