[Dovecot] "listen=*, ::" broken?

Phil Howard ttiphil at gmail.com
Thu Aug 5 16:44:56 EEST 2010


On Wed, Aug 4, 2010 at 10:47, Peer Heinlein
<p.heinlein+dovecot at heinlein-support.de> wrote:

> the default:
>
> listen = *, ::
>
> should work and should open port 143 on IPv4 and IPv6.

On Linux, listening to :: in IPv6 has the effect of listening also on
0.0.0.0 in IPv4, even though only a single socket is involved.

If the process binds a socket first to IPv4 then another socket to
IPv6, the IPv6 bind will fail with EADDRINUSE (Address already in
use).  At this point the process is listening to IPv4 but not IPv6.

If the process binds a socket first to IPv6 then another socket to
IPv4, the IPv4 bind will fail with the same error.  But the socket
bound to IPv6 will be listening also to IPv4 via 4-in-6.  IPv4 peers
can connect and will show a peer address like ::ffff:xxxx:xxxx or
::ffff:xx.xx.xx.xx depending on how the address gets formatted.

On OpenBSD, this does not happen, and a process must bind a socket
separately for IPv6 and IPv4 to be able to listen in both address
spaces.

I don't know how other operating systems do it.  But it should be one
way or the other.

What a program doing such socket binding could (maybe should) do is
either understand what OS it is running on and act accordingly, or
just bind the IPv6 socket first and treat a failure to bind on IPv4 as
a soft error if the IPv6 succeeded.

So, if you are on Linux, just use listen = :: and test if you can
connect via the IPv4 address.  If so, you are good to go.  But, if you
are on OpenBSD, just use listen = * and test if you can connect via
the IPv6 interface address (you can use the IPv6 link-local address if
you connect from an IPv6 peer on the same LAN segment and specify the
outgoing interface index as part of the address).  On another OS, try
each way and use what works.

Or you can listen on your explicit interface addresses (not
::ffff:xxxx:xxxx or ::ffff.xx.xx.xx.xx) in each address space.

-- 
sHiFt HaPpEnS!


More information about the dovecot mailing list