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 0.0.0.0) 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 0.0.0.0 address to the real ip whereas the client is
not.

How does address 0.0.0.0 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.


Thanks,
William McKee and Chad Leigh

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


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



More information about the freebsd-questions mailing list