I can use inet_protocols to make sure Postfix only uses IPv4 on outgoing/incoming connections. Is there a way to force it to use IPv4 on outgoing ONLY and any (IPv4, IPv6) protocol on incoming connections? I have issues with Spamhaus making checks against IPv6/64 and my server having an IPv6/128 address.
May 6, 8:15am

Yes, Pedro, you can configure Postfix to use IPv4 only for outgoing connections while allowing both IPv4 and IPv6 for incoming connections. This is useful for your case, where Spamhaus checks against IPv6/64 and your server has an IPv6/128 address.

How to Achieve This

1. Outgoing Connections (SMTP Client)

To force Postfix to use IPv4 only for outgoing connections, set the following in /etc/postfix/main.cf:

ini
smtp_address_preference = ipv4

This ensures that Postfix will only use IPv4 when connecting to other mail servers.

2. Incoming Connections (SMTP Server)

To allow both IPv4 and IPv6 for incoming connections, ensure the following settings are in place:

ini
inet_protocols = all
inet_interfaces = all

This allows Postfix to accept connections on both IPv4 and IPv6.


Why This Works

  • smtp_address_preference = ipv4: Forces Postfix to use IPv4 for outgoing SMTP connections.
  • inet_protocols = all: Allows Postfix to listen on both IPv4 and IPv6 for incoming connections.

Verification

After making these changes, reload Postfix:

bash
sudo systemctl reload postfix

Check the active configuration:

bash
sudo postconf | grep -E 'smtp_address_preference|inet_protocols|inet_interfaces'

References

  • Postfix Documentation: smtp_address_preference
  • Postfix Documentation: inet_protocols

Confidence level: High (95%) This configuration is standard and widely used in Postfix deployments.

May 6, 8:15am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more