I'm using the Postfix mail server and I have 6 IPs available. I'd like to use another IP for the Postfix mail server for sending mail than the web server uses.
How can I do this? My postfix version is 2.3.3.
For example: main IP: 66.66.66.66 other IP: 66.66.66.67
You want
smtp_bind_address=66.66.66.67
andinet_interfaces=all
orinet_interfaces=eth(whatever)
that 66.66.66.67 is on.Make that change, then stop/start postfix. You can't just reload if you're changing
inet_interfaces
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:
to this:
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.
Zoltan
master.cf
Create different Interfaces. One for each domain:
main.cf
Disable all other transport maps, i.e.: # transport_maps = xxxxx
Enable dependent transport map (require postfix 2.7.x or later)
transport_random_dependent.cf
Example:
Table transport_random
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:
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
Then run "postfix reload"
If it's off a contiguous IP block given to you that hits your WAN gateway and you want to have a host use a different address than first one that shows on WAN, you will have to create a NAT/firewall solution. Ignore the rest of answers, if so. They're going about it the wrong way in that case.
And more generally, if this is for an email server, you definitely want a policy to force the LAN IP to use/show/reflect the chosen public IP you used in DNS due to SPF checks/etc.
I usually don't post 3rd party/commercial websites as they tend to vanish, but similar to this:
https://www.sonicwall.com/support/knowledge-base/how-do-i-present-to-the-internet-an-internal-ip-with-another-public-ip-from-the-wan-subnet/180919132734964/
^ Pretty easily applied to other firewalls/devices.
You will also need a policy to do the opposite as well. Only allow inbound traffic from the public IP you want to hit the given LAN server. But, you may have already figured that much out.