1

Having some trouble here. My server has 3 IP addresses and this is my /etc/hosts:

127.0.0.1     localhost
46.38.235.226 brian.smares.de brian
46.38.238.199 stewie.smares.de stewie
46.38.238.137 mail.smares.de mail

postfix is set up with

inet_interfaces = localhost, $myhostname
mynetworks = 127.0.0.0/8
mydestination = localhost
myhostname = mail.smares.de
mydomain = smares.de
myorigin = $mydomain

If I send an e-mail, the source reads

Received: from mail.smares.de (pelikansal.at. [46.38.235.226])

pelikansal.at is the rDNS target for 46.38.235.226.

What I don't understand is why that IP is being used instead of 46.38.238.137. My server's FQDN is brian.smares.de which would map to the 226 address, but is that the cause?

Any ideas?

1 Answer 1

2

Possible solution

When sending an email, the parameter used to control outgoing IP address was smtp_bind_address. So you should explicitly set parameter smtp_bind_address to one IP address.


Explanation

Your configuration above, you already modified inet_interfaces parameter. It only set which IP Address that postfix will receive mails on.

However, parameter inet_interfaces can also affect smtp_bind_address if these three conditions were sufficient:

  1. smtp_bind_address is empty (by default)
  2. inet_interfaces only have ONE IPv4 IP Address
  3. inet_interfaces list wasn't loopback.

When it happened, smtp_bind_address = $inet_interfaces.

Because you have setup two IP address in inet_interfaces, then smtp_bind_address was still empty. In that case, smtp client uses 0.0.0.0 as its IP address and 0.0.0.0 (INADDR_ANY) means the kernel will chose the IP address based on where the packet goes. From this SO thread by Remy Lebeau, he says

If the client does not bind to a specific IP, or it binds to INADDR_ANY, the socket will use the first IP it finds that has an available route to the server IP being connected to.

So, in your case it's understandable that kernel choose 46.38.238.137 to make outgoing connection.

You must log in to answer this question.