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?
Asked
Active
Viewed 1.6k times
14
-
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`. – Michael Hampton Jan 05 '14 at 01: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 05 '14 at 10:53
-
2Due 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 >.< :(... – Jun 29 '14 at 09:30
-
4@BOB You mainly just need reverse DNS on your IPv6 addresses to get past Gmail. – Michael Hampton Mar 01 '15 at 17:18
2 Answers
18
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.
![](../../users/profiles/3245.webp)
andol
- 6,848
- 28
- 43
-
Well I've seen this part of the documentation but it is not clear to me. If I prefer IPv6 the doc say that this isn't a good idea and that there could be problems if IPv6 has an outage. So if I prefer IPv6 there isn't a fallback to IPv4? – nazco Jan 05 '14 at 10:50
-
3Not 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 05 '14 at 11:26
-
4It 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. – Sander Steffann Jan 05 '14 at 12:15
-
@Sander: You mean in situation where the TCP connecton is accepted, but you get a 4xx SMTP reject? – andol Jan 05 '14 at 12:42
-
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 05 '14 at 13:02
-
@andol: the A address of the same MX record, or on a subsequent MX record that doesn't have an AAAA address? – Sander Steffann Jan 05 '14 at 13:06
-
1@sander: For my quick test I went without MX, and delivery directly to hostname. But no, no second MX record. http://paste.ubuntu.com/6696807/ – andol Jan 05 '14 at 13:12
-
1@sander: Yet, the exact same result with a proper MX record in place - http://paste.ubuntu.com/6696854/ – andol Jan 05 '14 at 13:19
-
@andol: Thank you for researching this! This behaviour is different from what I thought it was. – Sander Steffann Jan 05 '14 at 17:00
-
1Documentation seems contradictory: on one hand it says `With Postfix 2.8 the default is "ipv6"` and on the other hand the actual default is `"any"` – IanB Dec 20 '17 at 00:00
-
Just for the sake of completeness, this parameter has to be used in conjunction with `inet_protocols`. See https://serverfault.com/a/544672/133346 or, even better, http://www.postfix.org/postconf.5.html#inet_protocols – Gwyneth Llewelyn Jul 27 '21 at 19:35
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.
-
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 05 '14 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 05 '22 at 14:39