View Single Post
Old 28th August 2009, 10:40
Craig Craig is offline
Join Date: Dec 2006
Posts: 56
Thanks: 1
Thanked 3 Times in 1 Post

More info about what is not the problem.

Some references in Google mention permissions issues, namely /etc/resolv.conf not being accessible to user "apache" and therefore PHP can't find how to resolve things properly. The common test is to run a test script in CLI under user root to test this. This is not the problem because the test script also fails the same way, resolution of non-existent domains continue to point to the server's external IP address, when run as root in CLI.

I thought that maybe there was a domain name conflict so I created a dummy domain name totally different than anything on the box and added it and the server's IP to my hosts file and everything ran as expected but, resolving non-existent domains still point to the server's external IP address.

I also temporarily replaced the production server with a dev box, on which it works correctly, and the dev box continued to work correctly. This is probably redundant but worth the 5 minutes it took to test it.

I'm at the point now of scripting a work around in PHP so that:

1) The domain name to be resolved is first compared to the server name and if the same or one includes sub-domains of the site's domain, the site's external IP is returned.

2) If they are not the same, gethostbyname() is then called on the query domain.

3) If the call to gethostbyname() returns the site/server's IP, the test function returns the original query domain. This is what will happen on the box with broken DNS resolution in PHP and so the result of the function call is as it should be from a call to gethostbyname().

4) If the call to gethostbyname() returns an actual IP address that is not the site/server's, it is returned, again, as it should be.

5). If the call to gethostbyname() returns the query domain, as it should on a box with properly functioning PHP DNS resolution if the domain is a non-existent domain, the test function returns the original query domain.

Fortunately there is only one site/service on this box that does php dns or it would really be a pain.

Although I do have a kluge that works, if anyone can suggest how to track it down, I would be very happy.
Reply With Quote