How to Disable IPV6 Address in Mailcow (Part Three)

Publish: 2022-08-17 | Modify: 2022-08-17

This is the third tutorial in the series of self-built mail server using mailcow. If you are interested in self-built mail servers, you can refer to my previous two articles:

When your server does not support IPv6 addresses, you can disable the IPv6 listener of mailcow to reduce resource consumption (mailcow starts an IPv6 NAT container) and avoid strange issues. This article will continue to share how to disable IPv6 for mailcow.

Disabling IPv6 for mailcow

Modify docker-compose.yml, change:

enable_ipv6: true

to:

enable_ipv6: false

You also need to disable the ipv6nat-mailcow container. Create a docker-compose.override.yml file in the mailcow directory and save the following content:

version: '2.1'
services:
  ipv6nat-mailcow:
    image: bash:latest
    restart: "no"
    entrypoint: ["echo", "ipv6nat disabled in compose.override.yml"]

Then restart the containers:

docker-compose down
docker-compose up -d

To disable IPv6 in unbound-mailcow, you only need to modify the data/conf/unbound/unbound.conf configuration file:

# Change
do-ip6: yes
# to
do-ip6: no

Then restart the corresponding container:

docker-compose restart unbound-mailcow

Next, to disable IPv6 for postfix, you need to modify the data/conf/postfix/extra.cf configuration file with the following content:

smtp_address_preference = ipv4
inet_protocols = ipv4

Then restart the container:

docker-compose restart postfix-mailcow

Finally, you need to modify the nginx listener. You can use the following sed command for replacement:

sed -i '/::/d' data/conf/nginx/listen_*
sed -i '/::/d' data/conf/nginx/templates/listen*
sed -i 's/,\[::\]//g' data/conf/dovecot/dovecot.conf
sed -i 's/\[::\]://g' data/conf/nginx/dynmaps.conf
sed -i 's/\[::\]://g' data/conf/phpfpm/php-fpm.d/pools.conf

Other Notes

  1. If your server supports IPv6, you do not need to disable IPv6 addresses.
  2. Please backup configuration files before making any modifications.
  3. Some content in this article is referenced from: https://mailcow.github.io/mailcow-dockerized-docs/post_installation/firststeps-disable_ipv6/

If you need to build your own mail server, you can contact me via QQ: 446199062 or WeChat: xiaozme.


Comments