mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.75k stars 1.17k forks source link

Binding and SNAT for both IPv4 and IPv6 #1499

Closed Geitenijs closed 6 years ago

Geitenijs commented 6 years ago

Hello,

I'd like to be able to set IP bindings and the SNAT IP for both IPv4 and IPv6.

My current setup contains 2 IPv4 addresses, as well as 2 IPv6 addresses. On my first IPv4 and IPv6 addresses, I host my webserver. On the other IPv4 address, I have a working Mailcow setup. I would like use the other IPv6 address for Mailcow as well. I know this is possible by not specifying an IP in the binding settings, however that way Mailcow uses all 4 IPs and so my webserver can't function.

To summarize, my Mailcow binding settings currently look like this:

SMTP_PORT=136.x.x.x:25 SMTPS_PORT=136.x.x.x:465 SUBMISSION_PORT=136.x.x.x:587 IMAP_PORT=136.x.x.x:143 IMAPS_PORT=136.x.x.x:993 POP_PORT=136.x.x.x:110 POPS_PORT=136.x.x.x:995 SIEVE_PORT=136.x.x.x:4190 DOVEADM_PORT=127.0.0.1:19991 SQL_PORT=127.0.0.1:13306

SNAT_TO_SOURCE=136.x.x.x

and I want them to be like this:

SMTP_PORT=136.x.x.x:25 SMTP_PORT_V6=[2a01:x]:25 SMTPS_PORT=136.x.x.x:465 SMTPS_PORT_V6=[2a01:x]:465 SUBMISSION_PORT=136.x.x.x:587 SUBMISSION_PORT_V6=[2a01:x]:587 IMAP_PORT=136.x.x.x:143 IMAP_PORT_V6=[2a01:x]:143 IMAPS_PORT=136.x.x.x:993 IMAPS_PORT_V6=[2a01:x]:993 POP_PORT=136.x.x.x:110 POP_PORT_V6=[2a01:x]:110 POPS_PORT=136.x.x.x:995 POPS_PORT_V6=[2a01:x]:995 SIEVE_PORT=136.x.x.x:4190 SIEVE_PORT_V6=[2a01:x]4190 DOVEADM_PORT=127.0.0.1:19991 DOVEADM_PORT_V6=[::1]:19991 SQL_PORT=127.0.0.1:13306 SQL_PORT_V6=[::1]:13306

SNAT_TO_SOURCE=136.x.x.x SNAT_TO_SOURCE_V6=[2a01:x]

Is it possible for you to add this to Mailcow?

Thanks in advance!

andryyy commented 6 years ago

You can do this only when you defined IPv4 bindings for all services - which you seem to have done.

So... to proceed, create a docker-compose.override.yml file with the following content:

version: '2.1'
services:

    dovecot-mailcow:
      ports:
        - 'A:B:C:D:E:F:G:H:143:143'
        - 'A:B:C:D:E:F:G:H:993:993'
        - 'A:B:C:D:E:F:G:H:110:110'
        - 'A:B:C:D:E:F:G:H:995:995'
        - 'A:B:C:D:E:F:G:H:4190:4190'

    postfix-mailcow:
      ports:
        - 'A:B:C:D:E:F:G:H:25:25'
        - 'A:B:C:D:E:F:G:H:465:465'
        - 'A:B:C:D:E:F:G:H:587:587'

    nginx-mailcow:
      ports:
        - 'A:B:C:D:E:F:G:H:80:80'
        - 'A:B:C:D:E:F:G:H:443:443'

Run docker-compose down and docker-compose up -d -- it is better to first "down" in this case.

That's for the binding. I can add a SNAT option for IPv6 soon.

Geitenijs commented 6 years ago

Thanks! It would be fantastic to have the SNAT option for IPv6 as well.

Geitenijs commented 6 years ago

Do you have an ETA on the SNAT for IPv6

EDIT: It has been added, thanks!

andryyy commented 6 years ago

Sorry! I wanted to have mentioned it here. :-(