How to make Postfix use another IP address?
inet_interfaces=eth(whatever) that 184.108.40.206 is on.
Make that change, then stop/start postfix. You can't just reload if you're changing
If you use the "smtp_bind_address" solution then your mail server will only listen on that specified IP address for incoming mail as well. The same thing applies to the "inet_interfaces" solution. This may not be the desired soltution if you want to listen for incoming mail on multiple IP addresses/interfaces.
My solution is better, because I suggest not to change the default "smtp_bind_address" and "inet_interfaces" settings, so your mail server will still listen for incoming mail on all IP addresses.
Only need to make a small change in your /etc/postfix/master.cf file.
Change this part:
smtp unix - - - - - smtp # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - - - - smtp -o smtp_fallback_relay=
smtp unix - - - - - smtp -o smtp_bind_address=192.168.0.1 # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - - - - smtp -o smtp_bind_address=192.168.0.1 -o smtp_fallback_relay=
Of course, instead of 192.168.0.1 you must use one of your IP addresses, the one you want to send your mail from.
Create different Interfaces. One for each domain:
rotate1 unix - - n - - smtp -o syslog_name=postfix-rotate1 -o smtp_helo_name=domainone.com.br -o smtp_bind_address=220.127.116.11 rotate2 unix - - n - - smtp -o syslog_name=postfix-rotate2 -o smtp_helo_name=domaintwo.com.br -o smtp_bind_address=18.104.22.168
Disable all other transport maps, i.e.: # transport_maps = xxxxx
Enable dependent transport map (require postfix 2.7.x or later)
sender_dependent_default_transport_maps = mysql:/etc/postfix/config/transport_random_dependent.cf
user = postfix password = mypassword dbname = postfixdb hosts = localhost query = SELECT transport FROM transport_random WHERE domain = '%d' AND status='1' ORDER BY RAND() LIMIT 1
Column "transport" = rotate1, rotate2, rotate3, rotate4 (etc) Column "domain" = sender domains (replaced by %d) Column "status" = boolean (0 or 1) if is enabled the transport.
The instruction "RAND() LIMIT 1" is necessary only if you want to use random transports for the same domain.
In example, you want to send from mydomain.com from 3 different IPs.
Then, you create 3 transports (rotate1, rotate2 and rotate3) with 3 different IPs, then set at mysql lines:
transport = rotate1 | domain = mydomain.com transport = rotate2 | domain = mydomain.com transport = rotate3 | domain = mydomain.com
Then, when postfix will randomize three different transports (rotate one to three) to send this emails.
Edit /etc/postfix/main.cf and make sure that the following line is present
inet_interfaces = 22.214.171.124, localhost
Then run "postfix reload"