8/23/2007
PHP gethostbyname() and DNS
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: 35%



August 23rd, 2007 at 6:51 pm
To boost server’s performance it’s better to have a local (preferably within the same network segment) caching nameserver. BTW it can forward requests to the OpenDNS, although I prefer using co-location facility’s DNS.
August 27th, 2007 at 12:16 pm
Local nameservers are a better setup if the datacenter ISP maintains a high QOS on its DNS servers and doesn’t overload them with too many hosts for each nameserver. Many ISPs don’t which is why I’ve seen better response in a lot of cases using a fast service like OpenDNS.
August 27th, 2007 at 12:26 pm
In this case it’s still worth to set up own caching NS and forward requests to OpenDNS.
August 27th, 2007 at 1:41 pm
For optimum performance… yes. However, setting up a caching nameserver takes time (thus $$) and some know how or you can totally hose your server. Using a third party DNS takes two seconds and almost anyone can follow the few steps it takes to configure.
If everyone could setup a nameserver properly on their own, there are a lot of us that would be out of a job.