4

Is it possible to configure postfix to send via IPV4 only but receive using both IPV4 & IPV6?

My server, running on AWS Lightsail, now can have an IPV6 address. The address is relatively static (as long as I keep IPV6 active on the instance), but it's not truly static because I can't move the address from server to server (like I can do with the static IPV4 address). I also can't (currently) as Amazon to assign an PTR record for the IPV6 address.

As I have the IPV6 address available, I'd like to be able to receive mail using either IPV4 or IPV6 but only send using IPV4.

I know I can set postfix to only listen on the IPV4 address using the inet_protocols setting.

3
  • Huh? The inet_protocols is absolutely supposed to affect outgoing connections, too. Applying it to your smtp service in master.cf should limit name lookups and connections postfix makes, if that is not the case you are using an old or buggy version. Commented Jan 15, 2021 at 5:47
  • Please elaborate ... is there a way to specify inet_protocols only for outgoing connections? The inet_protocols setting in main.cf appears to control all of postfix. Commented Jan 15, 2021 at 13:17
  • 1
    You can setup different configuration for smtpd (receiving mails) and for smtp (sending mails). Define per-service options, e.g. by adding space-prefixed ` -o option=value` after the relevant service in your master.cf file. Commented Jan 16, 2021 at 15:51

1 Answer 1

7

It's not exactly what you asked for, but you can make postfix prefer IPv4 for outgoing email with this configuration:

smtp_address_preference=ipv4 

That should usually have the effect you desire, unless the receiver explicitly gives the preferred MX only an IPv6 address.

The manual reference: https://www.postfix.org/postconf.5.html#smtp_address_preference

4
  • I don't want postfix to use IPV6 to send to any server at all. Only IPV4. I have a static IP address for IPV4 and a PTR record. I don't have the same for the IPV6 address. I just want to have postfix RECEIVE mail for both IPV6 & IPV4. Commented Jan 14, 2021 at 20:08
  • 2
    @DavidG I think this is the best you are going to get. I also don't think there are any IPv6-only mail servers out there yet, so it should not be an issue, at least long enough for Amazon to finish joining us in the 21st century. Commented Jan 15, 2021 at 1:10
  • Yeah, you're probably right. Thanks. Commented Jan 15, 2021 at 13:11
  • 1
    The docs state: "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" To me this indicates that smtp_address_preference will not have the desired effect in case the MX records offer both but give higher preference to IPv6. Commented Jul 27, 2024 at 8:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.