14

I've configured my mail server for IPv6 and IPv4 but in the most cases it uses IPv4 while IPv6 is available on the remote host. I use Postfix in version 2.9. So my thought was that postfix uses IPv6 if available and has a fallback to IPv4 or am I wrong?

4
  • Are you sure you have IPv6? Post a copy of your /etc/gai.conf, the output from ip addr and ping6 -c 5 www.google.com. Jan 5, 2014 at 1:29
  • Well I know it works because I can receive mails via IPv6 and also I've tested my IPv6 setup before I asked here.
    – nazco
    Jan 5, 2014 at 10:53
  • 2
    Due to the Google sending all my IPv6 email to SPAM, I ended up using "smtp_address_preference = ipv4". I would highly suggest against preferring IPv6, as most major email providers (gmail, aol, yahoo, hotmail/outlook, etc.) won't accept, don't support, or will spam bin from ipv6 senders. Just saying .... IPv6 is ready for the world, but the world isn't ready for it >.< :(...
    – user228461
    Jun 29, 2014 at 9:30
  • 4
    @BOB You mainly just need reverse DNS on your IPv6 addresses to get past Gmail. Mar 1, 2015 at 17:18

2 Answers 2

19

Have you set the smtp_address_preference option to expliclity prefer IPv6?

From postconf(5):

smtp_address_preference (default: any)
       The address type ("ipv6", "ipv4" or "any") that the Postfix SMTP client will try first, when a destination has IPv6 and IPv4 addresses with equal MX preference. This feature has no effect unless  the
       inet_protocols setting enables both IPv4 and IPv6.  With Postfix 2.8 the default is "ipv6".

       Notes for mail delivery between sites that have both IPv4 and IPv6 connectivity:

       ·      The setting "smtp_address_preference = ipv6" is unsafe.  It can fail to deliver mail when there is an outage that affects IPv6, while the destination is still reachable over IPv4.

       ·      The setting "smtp_address_preference = any" is safe. With this, mail will eventually be delivered even if there is an outage that affects IPv6 or IPv4, as long as it does not affect both.

       This feature is available in Postfix 2.8 and later.
11
  • 3
    Not really sure under what conditions that kind of failure would happen. I have "smtp_address_preference = ipv6" set myself, and have verified cases of it falling back to the A record after a connection failure against the AAAA record.
    – andol
    Jan 5, 2014 at 11:26
  • 4
    It can be useful in cases where you can connect over IPv6 but there is some other problem. Not having reverse DNS set up for your source IPv6 address is a common one. The destination (i.e. Google Mail) accepts the IPv6 connection but then rejects your mail because the reverse DNS check fails. When you prefer IPv6 you'll always get the rejection. When you randomise the protocol then the message might be delayed a bit, but at a next attempt it will go through. Jan 5, 2014 at 12:15
  • 1
    @sander: Hmm, nope, just tested. Even with "smtp_address_preference = ipv6" a 4xx reject on the AAAA will still trigger a resend on the A address.
    – andol
    Jan 5, 2014 at 13:02
  • 1
    @sander: For my quick test I went without MX, and delivery directly to hostname. But no, no second MX record. paste.ubuntu.com/6696807
    – andol
    Jan 5, 2014 at 13:12
  • 1
    @sander: Yet, the exact same result with a proper MX record in place - paste.ubuntu.com/6696854
    – andol
    Jan 5, 2014 at 13:19
2

Granted that Postfix is correctly configured with IPv6, it is instructed to use both protocols and the MX host it connects to has both A and AAAA record, Postfix makes a random choice every time, as Wietse Wenema himself explained:

Recent Postfix SMTP clients randomly select between IPv4 and IPv6 so that mail won't get stuck when one of the two is down.

2
  • Ok, so this means that there is no "I try IPv6 and if it fails IPv4" anymore like in older versions of postfix?
    – nazco
    Jan 5, 2014 at 10:56
  • @nazco Regardless of protocol, the following statement should always be true: "try X and if it fails try Y". Same for smtp_address_preference.
    – Chazy Chaz
    Jan 5, 2022 at 14:39

You must log in to answer this question.

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