-
-
Notifications
You must be signed in to change notification settings - Fork 2k
docs: Guidance for binding outbound SMTP with multiple interfaces available #3465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Guidance for binding outbound SMTP with multiple interfaces available #3465
Conversation
|
@polarathene What I'm wondering about is if it should be filed under |
polarathene
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll apply these via the web UI, then pull the changes on your end to apply future feedback.
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
Yes, I think this is more niche. It would be better added to our Example docs for now. The config section of our docs is already quite big. Please move the file and choose a smaller title like "Binding to a specific network". It's possible for DMS to have more than one network attached without using host network mode too, so the advice can still be helpful there. Thanks for taking the time to contribute to DMS! It's very much appreciated 😁 |
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
polarathene
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, last few changes to address should be good to go now 👍
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
|
This is rather a very specific and special setup, because I host several things at one node with multiple IP addresses. Be free to to squash your commits and amend while insert your-self with Postfix is configured in DMS to deliver incoming mail and use a
This is basically what I'm doing with the custom postfix-master.cf for smtp traffic targeting amavis. (which is used by the The default DMS configuration for postfix-master.cf could probably contain this default binding to localhost ( |
|
I'll wrap up this PR and merge it, although your feedback on advice below would be good to hear first :)
Is there any reason you use host mode networking for DMS btw? If you want to target a specific interface, I believe you can specify that beside the port mapping in If you could test that and let me know that'd be appreciated, we could add it in the docs page too.
Yes, and DMS isn't really maintained for internal services to be scaled out individually (although we do provide a means to disable/enable many of them specifically). If No As |
I only ended up with host networking due to gmail rejecting emails with spf failures, and then I looked into why it was rejecting. I didn't notice right away that outbound smtp connections randomly bound to the "first" random IP address on the interface. I started a new job this week, but I can probably test during the weekend if time allows it by temporarying adding a server and configure a domain for testing in https://github.com/norrs/ansible/tree/main/playbooks/mailserver .
I believe those changes should work without issues, even in non host-mode in docker networking. Unsure what happens if you try to configure IPv6 binding and your system doesn't have IPv6 enabled tho.. Also IPv6 in docker probably needs to be configured like mentioned here ( https://docs.docker.com/config/daemon/ipv6/ ), which I actually haven't done myself .. 😨 Which I guess is also why I went direct to networking host-mode in the first place 🙃 |
| bind outgoing SMTP connections to specific IP-addresses to ensure MX records are aligned with | ||
| PTR-records in DNS when sending emails to avoid getting blocked by SPF for example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the phrase about SPF should be more clear:
bind outgoing SMTP connections to specific IP-addresses to ensure MX records are aligned with PTR and SPF records in DNS when sending (and receiving emails).
You expect at least the resolving IP-addresses from the MX records in DNS to have reverse DNS (PTR records) matching the MX records.
And those IP-addresses for sending emails need to be specified in the SPF records in DNS. (should be correct for bounces etc as well, so affects receiving as well?)
Agree @polarathene ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the PTR records have to match MX records since that's only related to where mail should be delivered/received for that domain.
IIRC, when this type of check is done, it's not necessarily strict, it's usually acceptable to resolve the sending mail-server shares the same IP as the PTR record and the address it points to are the same.
Example setup:
- DMS server + config:
- PTR
1.2.3.4=>example.com - A
example.com=>1.2.3.4 - A
mail.example.com=>1.2.3.4 compose.yamlwith hostnamemail.example.com+setup email add [email protected]
- PTR
- DNS support for mail account
[email protected](mail accounts don't need to share the same domain or server as DMS):- A
example.org=>5.6.7.8(not important to DMS) - MX
example.org=>mail.example.com(Mail sent toexample.orgwill be handled by DMS, not relevant to example below) - TXT (SPF)
example.org=>"v=spf1 mx ip4:1.2.3.4 a:mail.example.com -all"(only themxshould be necessary, but could alternatively specify an IP address authorized to send mail on behalf ofexample.org, that IP address could implicitly be resolved for anArecord lookup too if theMXofexample.orgis not appropriate)
- A
MTA connection example:
1.When connecting to another MTA to send mail to (with sender [email protected]), DMS will greet the MTA with HELO / EHLO of mail.example.com.
2. The MTA we are sending the mail to (eg: belonging to a recipient, or is a relay service) may do a PTR lookup for the IP that mail.example.com points to (1.2.3.4), which the PTR record resolves to example.com, which in turn resolves back to 1.2.3.4, same as DMS at mail.example.com, pass ✔️
3. SPF record can also be checked, verifying that example.org authorizes mail.example.com (or in this case anything sending from that IP).
I may be mistaken if I'm recalling the above incorrectly. But the PTR check is tied to DMS hostname (that Postfix gets configured for), like with the TLS certificate, the trust is in the mail-server here, the sender address is not relevant (separately checked via DNS lookup for records like SPF that authorize DMS server to send).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So perhaps it should be advising in the docs here to match the IP that hostname (compose.yaml) would resolve to via DNS?
Congrats on the new role! 🎉 No rush. If you can find the time to test and get back to me (in this PR is fine, even if it's closed), that'd be appreciated 👍
I recently rewrote our IPv6 docs, until v13 is released you can only see them in the I also contributed to the updated upstream Docker IPv6 docs you linked, as prior they were not very good. I'd advise giving our IPv6 docs a good look. If you have a more advanced IPv6 setup where ULA is not appropriate for you, you'll find some extra tips linked to the IPv6 docs rewrite PR, as I didn't have the time to figure all that out and document it properly. IPv6 ULA should meet most users needs very well though (just specify the IPv6 address on host to bind the containers internal ULA address to). |
|
For the record: @polarathene I have not forgotten about this, but I havent had any free time the last weeks. Maybe I find some wriggle room next week or early october. As I plan to test #3465 (comment) this in regards of |
|
@norrs can you please resume working on this? I am trying to "clean" up old PRs because I know from experience that PRs like this tend to fade and rot 🙈 I removed the label for the stale-bot; this PR has approximately 3 more weeks until it is labelled as stale. |
👍🏼 Please close if you come to the conclusion that this may not be worthwhile :) |
polarathene
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll apply these revisions.
| If your host system is running multiple IPv4 and IPv6 IP-addresses, you probably have an interest to | ||
| bind outgoing SMTP connections to specific IP-addresses to ensure MX records are aligned with | ||
| PTR-records in DNS when sending emails to avoid getting blocked by SPF for example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| If your host system is running multiple IPv4 and IPv6 IP-addresses, you probably have an interest to | |
| bind outgoing SMTP connections to specific IP-addresses to ensure MX records are aligned with | |
| PTR-records in DNS when sending emails to avoid getting blocked by SPF for example. | |
| If your Docker host is running multiple IPv4 and IPv6 IP-addresses, it may be beneficial to bind outgoing SMTP connections to specific IP-address / interface. When a mail is sent outbound from DMS, it greets the MTA it is connecting to with a EHLO (DMS FQDN) which might be verified against the IP resolved, and that a `PTR` record for that IP resolves an address back to the same IP. If DMS connections are inconsistent with the IP used here, these DNS checks are likely to fail. |
reject_unknown_sender is a setting DMS has which other mail servers may also check for, where a foreign sender address is checked for having a valid DNS MX or A record. The linked issue is an SPF failure related to that.
There are two related restrictions Postfix can configure related to the suggestion that other MTAs may also check for.
reject_unknown_reverse_client_hostname:
Reject the request when the client IP address has no address -> name mapping.
This is a weaker restriction than thereject_unknown_client_hostnamefeature, which requires not only that the address -> name and name -> address mappings exist, but also that the two mappings reproduce the client IP address.
Related references within DMS contributions:
- Posfix: add option to re-enable
reject_unknown_client_hostnameafter #3248 #3255 - Rspamd: replace
reject_unknown_client_hostnamewith RspamdHFILTER_HOSTNAME_UNKNOWNand make it configurable #3248 (comment) - Add
reject_unknown_client_hostnameto main.cf #2691
SPF only comes into play when it authorizes a mail server via mx / ip4 / ip6 / a etc, as demonstrated in my prior review comment. Likewise those DNS records related changes would need to have consistent IP.
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
docs/content/config/advanced/tips/server-multiple-ip-addresses.md
Outdated
Show resolved
Hide resolved
polarathene
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! ❤️
|
Documentation preview for this PR is ready! 🎉 Built with commit: ff7bcee |
|
A huge thanks @polarathene , I never managed to follow this up in a timely manner and I apology for this. In the end, the suggested changes and extra work you put into it made it even better 💜 Next challenge, able to solve this with a non host networking mode as mentioned in #3465 (comment) ? 🤔 |
Just letting you know we received a contribution recently that resolves that concern: #4330 |

Description
Add tips section to the documentation, and include how I solved ensuring SMTP clients in postfix was bound to the right IP-addresses to match the entries in my SPF-record and reverse DNS (PTR) configuration on those specific IP-addresses.
Tricky part is that when you first involving the
smtp_bind_addressit also uses this as source IP address for forwarding to content_filter amavis. Since amavis is running on same node, enforce it to bind to localhost.Interesting topics to maybe look into later:
Maybe you have even more advanced setup and want to look into specific IP-addresses used for particular domains (ie used for bulk-sending) and get some inspiration from https://serverfault.com/a/650326 .
I were happy with only binding to the correct IP-addresses for now as I don't really have any bulk-needs in this setup.
Type of change
Checklist:
docs/)