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… read them below or add one }
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.
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.
In this case it’s still worth to set up own caching NS and forward requests to OpenDNS.
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.
Hi. My /etc/resolv.conf currently shows the IP addresses of my own server. (I am on the usual Cpanel/WHM thing). Can I simply add the OpenDNS stuff you mention above?
Thanks!
Yes you can add the OpenDNS records below the ones already in the file. The resolver will try them in the order listed in the file until it receives a valid response.