1

In a Debian server, I added a second IP by the following configuration in /etc/network/interfaces

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
    address 1.1.1.1
    netmask 255.255.255.255
    gateway 1.1.1.1

auto eth0:1
iface eth0:1 inet static
    address 1.1.1.2
    netmask 255.255.255.255

Now, postfix sends emails with the second IP instead of the primary IP.

I use a dedicated IP for each domain managed by nginx. Is it possible to send email from each domain by the IP dedicated to that domain?

If NOT, how to use the primary IP for sending emails?

1
  • Interface aliases are deprecated. As for a general solution to choose which source address the system use as a default, use ip route change default via <your gateway> src <your prefered source address>.
    – BatchyX
    May 19, 2013 at 17:38

2 Answers 2

3

Its possible to use the IP dedicated to that domain for sending.
You need sender dependent transport maps.
Something like this:
add to /etc/postfix/main.cf:

sender_dependent_default_transport_maps=hash:/etc/postfix/sender_maps

/etc/postfix/sender_maps:

@domain1.com   domain1_transport:
@domain2.com   domain2_transport:

add to /etc/postfix/master.cf

domain1_transport unix - - - - - smtp -o smtp_bind_address=1.1.1.1 
domain2_transport unix - - - - - smtp -o smtp_bind_address=1.1.1.2 

Do a postmap /etc/postfix/sender_maps and reload postfix.
To accept mail's on both IP the best probably to have inet_interfaces = all in main.cf

0

Is it possible to send email from each domain by the IP dedicated to that domain?

Yes, you can do that. Try changing master.cf configuration file with:

ipaddress1:smtp inet n - n - - smtpd -o myhostname=hostname1
ipaddress2:smtp inet n - n - - smtpd -o myhostname=hostname2

Restart postfix and check send mail.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .