Jie Gao wrote:
[...]
We need to write a generic function to resolve localhost and make sure that we
get an ip and not ::1 on the ipv4 systems. If we get ::1 Apache won't start.
Help to accomplish that is very appreciated.


I have spent some time into this and found some interesting things.

On a Solaris 9 host with both IPv4 and IPv6 configured, and with the
following in /etc/nsswitch.conf:

hosts:      files dns
ipnodes:    files

and with the following in /etc/inet/ipnodes (defaults):

#
# Internet host table
#
::1             localhost
127.0.0.1       localhost

and with the following in /etc/hosts:

127.0.0.1 localhost

, I did a "ifconfig lo0 inet6 down".

Now, nslookup localhost resolves to 127.0.0.1 and vice versa.
(Using /etc/hosts file?)

"dig" will not resolve it.
(Not using /etc/hosts?)

The following piece of perl code succeeds in connecting
to the daytime port:

my $proto = getprotobyname('udp');
socket(SOCKET, PF_INET, SOCK_DGRAM, $proto);
my $sin = sockaddr_in(13,inet_aton('localhost'));
connect(SOCKET,$sin) || print "not connected:$!\n";

(Why and how does perl find the IPv4 interface?)

strace it to see why. e.g. on my machine:


strace perl -le 'use Socket; sockaddr_in(13, inet_aton("localhost"))' ;

open("/etc/host.conf", O_RDONLY)        = 3
[...]
open("/etc/hosts", O_RDONLY)            = 3
read(3, "127.0.0.1\t\tlocalhost.localdomain"..., 4096) = 80


But ping fails.
(Only looks into /etc/inet/ipnodes?)

again, strace it - on my machine (linux/ipv4) it also reads from /etc/hosts.


A piece of puzzle that needs more time to solve it.

__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to