Skip to content

fix: Only listen on 127.0.0.1 for the Dovecot quota-status service#3057

Merged
polarathene merged 2 commits intodocker-mailserver:masterfrom
yogo1212:dovecot_quota_localhost
Feb 4, 2023
Merged

fix: Only listen on 127.0.0.1 for the Dovecot quota-status service#3057
polarathene merged 2 commits intodocker-mailserver:masterfrom
yogo1212:dovecot_quota_localhost

Conversation

@yogo1212
Copy link
Copy Markdown
Contributor

@yogo1212 yogo1212 commented Feb 3, 2023

Description

Docker-Mailserver has dovecot listen on port 65265 for any address. When using host networking, that isn't necessarily desirable. Fix existing indentation.

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
    Fairly confident.
  • I have performed a self-review of my own code
    And a test.
  • I have commented my code, particularly in hard-to-understand areas
    Not sure it's worth it.
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
    The docs don't mention the port. All existing code already uses localhost.
  • If necessary I have added tests that prove my fix is effective or that my feature works
    Not sure it's worth it.
  • New and existing unit tests pass locally with my changes

@georglauterbach georglauterbach added service/dovecot kind/improvement Improve an existing feature, configuration file or the documentation area/configuration (file) labels Feb 3, 2023
@georglauterbach georglauterbach added this to the v12.0.0 milestone Feb 3, 2023
Comment thread target/dovecot/90-quota.conf Outdated
inet_listener {
port = 65265
# You can choose any port you want
address = localhost
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach Feb 3, 2023

Choose a reason for hiding this comment

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

Could localhost here potentially resolve to an IPv6 address? Would it be better to use 127.0.0.1?

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.

if the docker-container is set up properly, that shouldn't be the case.

but i also don't see any reason against changing it, so i will.

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.

well, technically, other components are using localhost to connect. so unless any of them have a non-standard way of resolving localhost or prefers ipv4 over ipv6 (or vice-versa), using localhost, dovecot will use the same as the other applications.

then again, the day anyone starts turning of ipv4 addresses for the loopback interface is probably far in the future.

@yogo1212 yogo1212 force-pushed the dovecot_quota_localhost branch from 0850299 to 8683d53 Compare February 3, 2023 18:10
@georglauterbach georglauterbach requested a review from a team February 3, 2023 23:06
@polarathene
Copy link
Copy Markdown
Member

When using host networking

Out of curiosity, why are you using host networking with this image? Is there an issue with a bridge network at all?

@yogo1212
Copy link
Copy Markdown
Contributor Author

yogo1212 commented Feb 4, 2023

@polarathene hi :-)

i encountered deliverability issues with providers like gmail, outlook, and icloud.
a large enough fraction of incoming email was bounced to cause their spam detection to flag/reject outgoing mail.
it appears the issue was related to ipv6.
because of the lower volume, it took me months to figure out that there were bounces, these bounces were causing outgoing mail to be flagged as spam, and the bounces were caused by the container not seeing ipv6 source addresses.

it has nothing to do with docker-mailserver, per se but with docker itself.
it's really stupid - imho - that the docker default bridge doesn't do ipv6.
yes, ipv6 private networking with NAT is frowned upon but how is it better than doing NAT from ipv6 to ipv4?!?!
in userland... (referring to the default behaviour of --publish)

if ipv6nat had been part of the configuration template, maybe i would've rolled with it.
but since - apart from an ssh server - nothing else uses the network on that machine, i'm reluctant to add the extra complexity.

@polarathene
Copy link
Copy Markdown
Member

Thanks for sharing 👍

it's really stupid - imho - that the docker default bridge doesn't do ipv6.
yes, ipv6 private networking with NAT is frowned upon but how is it better than doing NAT from ipv6 to ipv4?!?!

I am aware, and looked into this regarding a recent-ish IPv6 issue, but didn't get around to posting a response. The good news is support is improving (albeit rather slowly). While experimenting with Docker support, I did find a bug, which has since been fixed but I'm not sure if it's made it to a public release yet.

If you want to use container networking with IPv6, make sure you have the following in /etc/docker/daemon.json:

{
  "ip6tables": true,
  "experimental" : true,
  "userland-proxy": true
}

You'll need to restart the daemon if it's running, not just reload it. The above enables the ipv6 NAT which will avoid the routing to ipv4, so long as the container is on an ipv6 network that we'll configure next. experimental is required currently for ip6tables to work, pretty sure userland-proxy is too (but should be enabled by default, there is upstream talk to switch to disabled by default though).

Then you need to configure a network for your container, in docker-compose.yaml the default bridge network isn't the same as the default bridge config in /etc/docker/daemon.json, that only applies to docker CLI (eg docker run). Instead you can override the default network like I detailed here:

networks:
  # Overrides the `default` compose generated network, avoids needing to attach to each service:
  default:
    enable_ipv6: true
    # An IPv4 subnet is implicitly configured, IPv6 needs to be specified:
    ipam:
      config:
        - subnet: fd00:cafe:babe::/48

I don't see any issue for IPv6 NAT with ULA addresses for internal routing like that.

I might not know IPv6 well enough though, but unless I'd explicitly want an IPv6 address for a container to be publicly reachable, I prefer the NAT config above. Then my server with it's public IPv6 address can be reached, and be compatible with the containers without all those containers being reachable publicly 🤔

@polarathene polarathene changed the title listen only on localhost for quota with dovecot fix: Only listen on 127.0.0.1 for the Dovecot quota-status service Feb 4, 2023
@polarathene polarathene enabled auto-merge (squash) February 4, 2023 09:26
@polarathene polarathene merged commit 9df71c2 into docker-mailserver:master Feb 4, 2023
@yogo1212 yogo1212 deleted the dovecot_quota_localhost branch February 4, 2023 09:58
@yogo1212
Copy link
Copy Markdown
Contributor Author

yogo1212 commented Feb 4, 2023

@polarathene nice, good info - thanks!

my previous attempts with the bridge failed - likely because i didn't know about the experimental flag..
maybe i'll give it another go!

georglauterbach added a commit that referenced this pull request Apr 10, 2023
see #1438 and #3057 (with
#3057 (comment))
for reference.

Superseeds #3061
@georglauterbach georglauterbach mentioned this pull request Apr 10, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/configuration (file) kind/improvement Improve an existing feature, configuration file or the documentation service/dovecot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants