# Need help with PHP script for IP address of sites



## jeetesting (Apr 30, 2008)

Need help with PHP script for IP address of sites

Hi All
I need some assistance with getting the IP address of a web site. 

Basically I have to write a PHP page where if a site name is supplied it would return back the IP address of the site as well as specify if the IP Address is Dedicated for that site or a Shared IP Address

I have figured out how to get the IP address of a site in PHP however I am not able to figure out how can I find out whether that IP address is static i.e. dedicated IP for the site or a shared IP that the site is using.  

Does anyone know how to get around this problem, using PHP how can I figure out if an IP address of the site is a Dedicated IP address for that site or whether that IP is a shared one.

Any help on this matter is appreciated

Cheers
Asif


----------



## Captain Code (May 1, 2008)

You could try doing a reverse DNS lookup on that IP address.  Most likely you will get something else other than the original domain because most websites are hosted on servers with many other web sites.


----------



## jeetesting (May 2, 2008)

You could try doing a reverse DNS lookup on that IP address. Most likely you will get something else other than the original domain because most websites are hosted on servers with many other web sites.

----------------------------------------------------------------------------

I need all websites on that ip. 

How it's possible using php script?

Any suggestion give me, How can create script other sites hosted on same ip.

Cheers
Asif


----------



## billbaloney (May 11, 2008)

Did you ever figure this out?

The first question is this: How would you go about determining a dedicated vs. shared IP programmatically, using any language?

In a shell, I would use dig with the +short=1 flag to get a terse answer.

dig +short mydomain.com
[response: 1.2.3.4]
dig +short -x 1.2.3.4
[response: somedomain.com]

If the response to #2 isn't the same as the domain you started with, then you've *probably* got a shared hosting situation.


----------



## ksv (May 20, 2008)

Bill's method should work as well as you can get it programatically without having to index the web with a spider or refer to an existing index.

As for checking the IP for a domain, you can use gethostbyname():
http://no.php.net/manual/en/function.gethostbyname.php


----------

