> <?php
> echo gethostbyname('www.google.de')."\n";
> print_r(dns_get_record('www.google.de', DNS_A))."\n";
> ?>
> I don't understand why the first lookup fails, but the second one succeeds.
> Unfortunately thinks like fsockopen() seem to use the same technique as
> gethostbyname(), so they don't work either.
> Any pointers would be appreciated!

PHP's gethostbyname() is a wrapper for the system call of the same
name, which may attempt to resolve the name using local mechanisms
(/etc/hosts, perhaps an internal cache, etc.) before resorting to a
DNS query. I've never studied any particular implementation of
gethostbyname(), but I wouldn't be surprised to find that in some
implementations it doesn't actually query DNS at all, but simply hands
off the name to another mechanism that queries DNS.

PHP's dns_get_record(), on the other hand, queries DNS using the
resolver(3) system calls. All it needs is a network connection and a
valid DNS server address.

So that should help explain why one can work while the other doesn't.
Not sure why gethostbyname() fails in your chroot environment, though.
I've seen situations where this has happened on my internal network,
but only fake hostnames that ended in ".local" were affected.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to