Binding to "any"

Marcus Rueckert darix at
Mon May 14 17:50:27 CEST 2007

On 2007-05-14 16:50:58 +0200, Dag-Erling Smørgrav wrote:
> Currently, there is a known issue with varnishd on FreeBSD, where if you
> run it with "-a :80" it will only bind to IN6ADDR_ANY instead of both
> This is not easy to solve.  The obvious fix, which is to bind to *all*
> addresses returned by getaddrinfo() instead of just the first one, will
> work on FreeBSD, but not on Linux, where you can't bind to the same port
> on both INADDR_ANY and IN6ADDR_ANY.
> On Linux, the current behaviour is good enough - binding to either
> INADDR_ANY or IN6ADDR_ANY will give you both.

bind the ipv6 binds with IPV6_ONLY. than you get the same behavior as
on *BSD. postfix does that e.g. you just need to detect the socket type.

> On FreeBSD, if we want both *and* the kernel has IPv6 support compiled
> in, we can bind to IN6ADDR_ANY and clear the IPV6_V6ONLY socket option
> (it defaults to on).  If the kernel does *not* have IPv6 support
> compiled in, getaddrinfo() will still return both INADDR_ANY and
> IN6ADDR_ANY, but we binding to IN6ADDR_ANY will fail.
> I don't see any good way out of this mess - we're pretty much forced to
> special-case the "any" case.
> I've looked at other network servers, such as Apache and OpenSSH, and
> they pretty much universally solve (or rather avoid) this issue by
> explicitly specifying either (INADDR_ANY) or :: (IN6ADDR_ANY) as
> the default listening address.

think so too.


           openSUSE - SUSE Linux is my linux
               openSUSE is good for you

More information about the varnish-dev mailing list