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?
Best Answer
Possible solution
When sending an email, the parameter used to control outgoing IP address was
smtp_bind_address
. So you should explicitly set parametersmtp_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 affectsmtp_bind_address
if these three conditions were sufficient:smtp_bind_address
is empty (by default)inet_interfaces
only have ONE IPv4 IP Addressinet_interfaces
list wasn't loopback.When it happened,
smtp_bind_address
=$inet_interfaces
.Because you have setup two IP address in
inet_interfaces
, thensmtp_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 saysSo, in your case it's understandable that kernel choose 46.38.238.137 to make outgoing connection.