Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 12th, 2006, 02:45 AM
yawnmoth
Guest
 
Posts: n/a
Default conflicting gethostbyname behaviors

I seem to be getting conflicting gethostbyname behavior on different
servers. Before going into detail, here's the script I'm using:

<?
$address = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$rev = implode('.',array_reverse(explode('.', $address)));

$lookup = "$rev.l1.spews.dnsbl.sorbs.net";
echo gethostbyname($lookup);
echo '<br />';
echo $lookup;
?>

On server A, the output I get is as follows:

176.115.112.70.l1.spews.dnsbl.sorbs.net
176.115.112.70.l1.spews.dnsbl.sorbs.net

On server B, the output I get is this:

195.69.95.204
176.115.112.70.l1.spews.dnsbl.sorbs.net

As I understand it, server A's output is the correct output - not
server B's.

Server A is running PHP Version 4.4.1 with Apache/1.3.34 while server B
is running PHP Version 4.3.11 with Apache/2.0.52. I'd like the above
script, however, to work just as well on server A as it does on server
B.

Any ideas as to how I might go about doing this or what the problem is?
Any help would be appreciated - thanks!

  #2  
Old May 12th, 2006, 12:35 PM
Erwin Moller
Guest
 
Posts: n/a
Default Re: conflicting gethostbyname behaviors

yawnmoth wrote:
[color=blue]
> I seem to be getting conflicting gethostbyname behavior on different
> servers. Before going into detail, here's the script I'm using:
>
> <?
> $address = $HTTP_SERVER_VARS['REMOTE_ADDR'];
> $rev = implode('.',array_reverse(explode('.', $address)));
>
> $lookup = "$rev.l1.spews.dnsbl.sorbs.net";
> echo gethostbyname($lookup);
> echo '<br />';
> echo $lookup;
> ?>
>
> On server A, the output I get is as follows:
>
> 176.115.112.70.l1.spews.dnsbl.sorbs.net
> 176.115.112.70.l1.spews.dnsbl.sorbs.net
>
> On server B, the output I get is this:
>
> 195.69.95.204
> 176.115.112.70.l1.spews.dnsbl.sorbs.net
>
> As I understand it, server A's output is the correct output - not
> server B's.
>
> Server A is running PHP Version 4.4.1 with Apache/1.3.34 while server B
> is running PHP Version 4.3.11 with Apache/2.0.52. I'd like the above
> script, however, to work just as well on server A as it does on server
> B.
>
> Any ideas as to how I might go about doing this or what the problem is?
> Any help would be appreciated - thanks![/color]

Hi,

Did one of them change recently their name maybe?
PHP caches lookups. (Or rather Apache does if I understand it well).

What MIGHT help are some usercontributed notes on www.php.net:

Two possibilities:
1) restart Apache (in case of caching DNS-problem)
2) Do not use gethostbyname, but use 'dig' instead.

Just go to www.php.net and look up the function for details.

Regards,
Erwin Moller

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.