Loopback addresses and socket() inside of jail

Chad Leigh -- Shire.Net LLC chad at shire.net
Fri Feb 18 20:27:45 GMT 2005

While tracking down test errors while installing Apache 2.0.53 and
mod_perl2.0.0-RC4 into a jail process on a FreeBSD 5.3 server, we have
encountered some errors with how the ip is being resolved for the
loopback device.

Using test code from the Apache project[1], we were able to determine
that a client socket created with an unspecified sin_addr (which
defaults to is not able to resolve to the loopback device.

If you patch the original nonblock.c with the lines listed below, the
script will work and it will be apparent that the listener socket is
able to resolve the address to the real ip whereas the client is

How does address work inside of a jail?  The code nonblock.c
starts up a listener on that address, which works, and then tries to
connect to it and it fails.

William McKee and Chad Leigh

[1] http://www.apache.org/~jorton/nonblock.c

>     printf("listening to %s:%d\n", inet_ntoa(sa.sin_addr), 
> listen_port);
>     sa.sin_addr.s_addr = inet_addr ("");

More information about the freebsd-questions mailing list