gethostbyname

PeterT

Verified User
Joined
Aug 18, 2005
Messages
20
I'm running into some trouble on 1 - newly installed - box.
The PHP gethostbyname() function does work, but only limited; as long as there's an A-record for the domain, it returns the right IP.
However, and here comes the problem, when the domain doesn't exist, it returns the server's main IP...
 
PeterT said:
I'm running into some trouble on 1 - newly installed - box.
The PHP gethostbyname() function does work, but only limited; as long as there's an A-record for the domain, it returns the right IP.
However, and here comes the problem, when the domain doesn't exist, it returns the server's main IP...

PHP Related problems are for PHP not DA! ;)

http://nl2.php.net/gethostbyname

Your problem isn't a problem it's just how PHP handles the function! :D


http://nl2.php.net/gethostbyname

Description
string gethostbyname ( string hostname)


Returns the IP address of the Internet host specified by hostname or a string containing the unmodified hostname on failure.
 
Last edited:
Re: Re: gethostbyname

fusionictnl said:
PHP Related problems are for PHP not DA!

Which is why I asked it in this subforum:

DirectAdmin Forums > Technical Discussion > MySQL / PHP


http://nl2.php.net/gethostbyname

Your problem isn't a problem it's just how PHP handles the function! Check it next time you ask such a question!

I think you misunderstood what I wrote:

The PHP gethostbyname() function does work, but only limited; as long as there's an A-record for the domain, it returns the right IP.
However, and here comes the problem, when the domain doesn't exist, it returns the server's main IP...

Example with the above:

Let's say the server operates on 192.168.1.13

gethostbyname("domain.com"); = 67.7.239.163 ---> correct, and expected output

gethostbyname("totallyfakedomain1234234234234234.com"); = 192.168.1.13 ---> incorrect and unexpected output, expected output is totallyfakedomain1234234234234234.com
 
Re: Re: Re: gethostbyname

PeterT said:
Which is why I asked it in this subforum:

DirectAdmin Forums > Technical Discussion > MySQL / PHP



I think you misunderstood what I wrote:



Example with the above:

Let's say the server operates on 192.168.1.13

gethostbyname("domain.com"); = 67.7.239.163 ---> correct, and expected output

gethostbyname("totallyfakedomain1234234234234234.com"); = 192.168.1.13 ---> incorrect and unexpected output, expected output is totallyfakedomain1234234234234234.com

[EDIT]

totallyfakedomain1234234234234234.com should be returned and not 192.168.1.13, but what hapens if you try to resolve it ?

dig / nslookup totallyfakedomain1234234234234234.com ? Does it return you IP ?
 
Last edited:
Re: Re: Re: Re: gethostbyname

fusionictnl said:
[EDIT]

totallyfakedomain1234234234234234.com should be returned and not 192.168.1.13, but what hapens if you try to resolve it ?

dig / nslookup totallyfakedomain1234234234234234.com ? Does it return you IP ?

Nope, dig/host return nothing at all, like they're supposed to.
Which is a failure for php, so it should return the input domain (totallyfakedomain1234234234234234.com).
On other boxes this works just fine, just not on this one.
Already re-formatted and reinstalled DA, but it will just not work.

Same network/ip-range as the other boxes, same hardware, same configuration..
 
Back
Top