For PHP’s gethostbyname() to work properly, the server’s DNS must be properly configured with available nameservers in /etc/resolv.conf (on Linux boxes). Without a work domain name resolution kit, gethostbyname() returns the hostname supplied to the function.
Make sure /etc/resolv.conf contains several nameservers to query. The format is
nameserver yyy.yyy.yyy.yyy
Where xxx.xxx.xxx.xxx and yyy.yyy.yyy.yyy are the IP addresses of nameservers the host has permission to use.
OpenDNS is a free DNS service that allows public access to their nameservers at:
208.67.220.220
To use in /etc/resolv.conf use:
nameserver 208.67.222.220
Using OpenDNS’s nameservers could even boost your server’s performance. Their goal is to provide some of the faster domain name resolvers on the internet for free.
Popularity: 2%
{ 6 comments }