April 2, 2010

Bug in mod_php: DNS cached after change

Filed under: Hacking,Host — Schlagwörter: — paddy @ 4:00 pm

After a change of Domain Name Server (in /etc/resolv.conf) it seems to be necessary to stop and start the Apache server. A simple restart will not do. I have not done any tests on which versions of Apache and mod_php are affected.

This weblog encountered the problem which showed in WordPress plugin Akismet. Nice job that the programmers of Akismet have done. Not only do they show an error message but they provide you with first step diagnostic tools and with a page of further reading.  The best hint I got from the latter was that php methods/functions fsockopen and gethostbynamel must work flawlessly.  So I created a file with the following code on my server:

echo '<h1>fsockopen(rest.akismet.com, 80, $errno, $errstr);</h1>';
$r = fsockopen('rest.akismet.com', 80, $errno, $errstr);
echo '<h1>fsockopen(google.com, 80, $errno, $errstr);</h1>';
$r = fsockopen('google.com', 80, $errno, $errstr);
echo '<h1>gethostbynamel(rest.akismet.com);</h1>';
$t = gethostbynamel('rest.akismet.com');
echo '<h1>gethostbynamel(google.com);</h1>';
$t = gethostbynamel('google.com');

Executing it from shell will work fine. But you must execute it in the Apache Webserver context meaning you need to call the script in your browser calling the server URI via http://YOUR_HOST/YOUR_PATH_TO_SCRIPT/YOUR_SCRIPTNAME.php

Further reading:

  • bytes.com php_network_getaddresses: getaddrinfo failed

Keine Kommentare »

Noch keine Kommentare

RSS-Feed für Kommentare zu diesem Artikel. TrackBack URL

Schreib einen Kommentar