Skip to content

docs: bind-smtp-network-interface.md - Add bridge network config advice#4330

Merged
polarathene merged 11 commits intodocker-mailserver:masterfrom
zveljkovic:patch-1
Feb 3, 2025
Merged

docs: bind-smtp-network-interface.md - Add bridge network config advice#4330
polarathene merged 11 commits intodocker-mailserver:masterfrom
zveljkovic:patch-1

Conversation

@zveljkovic
Copy link
Copy Markdown
Contributor

@zveljkovic zveljkovic commented Jan 27, 2025

Description

Added info how to setup docker to use the same interface for outgoing traffic. Problem was that I was using single VPS for sites and mailserver. I got the additional IP address but all outgoing traffic from mailserver was going through the original IP. This network config makes the container use specified IP for outgoing traffic too.

Problem manifested as the mail-tester.com saw the original VPS IP address and failed on rDNS checks even when setup with suggestions from this part of page.

Fixes #

Type of change

  • Documentation update

Checklist

  • [] My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary, I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added information about changes made in this PR to CHANGELOG.md

Added options to setup docker into using the same interface for outgoing traffic
@georglauterbach georglauterbach added kind/improvement Improve an existing feature, configuration file or the documentation area/documentation labels Jan 29, 2025
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting inconsistent with the rest. Rejection for style violation.

The admonition should probably also be an "example" instead of a "note". Please, take two more minutes to get things like this straight!

Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md Outdated
@georglauterbach georglauterbach changed the title Update bind-smtp-network-interface.md docs: add example on bind-smtp-network-interface.md Jan 29, 2025
@georglauterbach
Copy link
Copy Markdown
Member

I have added @polarathene as a reviewer on this one. It will probably take a few das for him to go through this, even if it is a small change.

Copy link
Copy Markdown
Member

@polarathene polarathene left a 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, I've provided feedback and will come back to this for a 2nd pass later. I'd appreciate a reproduction example if you can offer one, otherwise I'll sort it out before merging.

Comment on lines +59 to +62
=== "Multiple IP hosts"

Sometimes containers use the first IP address from Docker host for outgoing traffic and verifications of rDNS (PTR) can occur for that IP address.
To force container to use specific IP address from host you can use following configuration in compose.yml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rDNS would be for a mail server receiving mail to verify the connecting MTA. From the context of DMS connecting to another mail server that checks rDNS:

  • DMS (Postfix) greets the third-party MTA with "Hello from mail.example.com
  • Third-party MTA resolves mail.example.com to the connecting IP, and then IIRC also does rDNS to verify that IP resolves to a DNS record that resolves back to same IP DMS is connecting from.

So your main concern here is when DMS traffic routes through a public interface with an outbound IP that doesn't match the associated DNS. The container isn't really involved in that with a bridge network, so this description isn't right? It's more about routing the bridge network through the preferred host network interface.

This will need to be revised in that case if I've understood that correctly. You can try that or I'll provide a suggestion when I return to this PR again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my config and environment. VPS with two IP's. I have sites on 203.161.53.206 and can't have there the PTR record. So I got another IP address 203.161.53.53 with proper PTR set.

ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 203.161.53.206  netmask 255.255.255.0  broadcast 203.161.53.255
eth0:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 203.161.53.53  netmask 255.255.255.0  broadcast 203.161.53.255

In compose.yaml

    ports:
      - "203.161.53.53:587:587"  # ESMTP (explicit TLS => STARTTLS)
      - "203.161.53.53:993:993"  # IMAP4 (implicit TLS)

In mailserver.env I have NETWORK_INTERFACE=eth0:0

With default bridge I get this warning when sending to mail-tester.com

mailserver  | 2025-02-03T01:40:11.948379+01:00 mail postfix/smtp[1072]: warning: smtp_connect_addr: bind 203.161.53.53: Cannot assign requested address
mailserver  | 2025-02-03T01:40:14.550576+01:00 mail postfix/smtp[1072]: 6D2A010B342: to=<[email protected]>, relay=reception.mail-tester.com[94.23.206.89]:25, delay=3.1, delays=0.03/0.02/1.8/1.3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as BBC929F61E)

On mail-tester I get 3 negative points due to
[SPF] zedologija.com does not allow your server 203.161.53.206 to use [email protected]
and on source there is raw message received by postfix and it has
Received: from server1.rsc-hosting.com (unknown [203.161.53.206]) from which it is finding this IP

https://www.mail-tester.com/test-nt7unksg7&reloaded=1

Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md Outdated
Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md Outdated
Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this information. I'll apply the suggested changes in a moment.

Regarding this:

warning: smtp_connect_addr: bind 203.161.53.53: Cannot assign requested address

I see that you bound the IP via ports instead of the host_binding_ipv4 setting, which should be fine. However did you apply that smtp_bind_address Postfix setting as this page documents for host mode networking? (but you had a bridged network instead)

If so, it fails to bind to that IP because that is the host IP that the container has nothing to do with. It's assigned it's own private IP address on the bridge subnet, which has the container port mapped to the host IP + port (or for the default 0.0.0.0, the port on host has a listener bound for all host IP addresses).

I'll do a follow-up PR on this page to better clarify the distinction of required config between host vs bridged network modes 👍

Postfix will just emit that warning from failing to bind, but should still work unless the Postfix 3.7+ setting smtp_bind_address_enforce is enabled, which would prevent that. Instead for you, just avoid the smtp_bind_address change entirely 😎

Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md Outdated
Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md Outdated
Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md Outdated
Comment thread docs/content/examples/use-cases/bind-smtp-network-interface.md
@polarathene polarathene added this to the v15.0.0 milestone Feb 3, 2025
@polarathene polarathene changed the title docs: add example on bind-smtp-network-interface.md docs: bind-smtp-network-interface.md - Add bridge network config advice Feb 3, 2025
@zveljkovic
Copy link
Copy Markdown
Contributor Author

I think I get what you wrote but it's been a while when I set it up, and I tried many things so it is a bit fuzzy what exactly I did. I just wanted to help others with similiar issue and share what worked for me to get that 10/10 on mail-tester.com. Let me know if I need to change/edit something or close PR...

@polarathene
Copy link
Copy Markdown
Member

I just wanted to help others with similiar issue and share what worked for me to get that 10/10 on mail-tester.com. Let me know if I need to change/edit something or close PR...

It's greatly appreciated thanks!

We've had two users previously reach out about not being able to figure out the outbound IP seen by servers when they used bridged networking.

No need to change anything or close the PR. I'll take it from here, thank you so much for contributing! ❤️

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 3, 2025

Documentation preview for this PR is ready! 🎉

Built with commit: 1e7dd3e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation area/networking kind/improvement Improve an existing feature, configuration file or the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants