Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Need help with PHP script for IP address of sites

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    1

    Need help with PHP script for IP address of sites

    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

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Quote Originally Posted by jeetesting
    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.
    AFAIK there's no way to figure that out remotely.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    Senior Member nihil's Avatar
    Join Date
    Jul 2003
    Location
    United Kingdom: Bridlington
    Posts
    17,188
    I don't know if this helps but if you type an IP address into your browser's address bar and only that site comes up, then it is dedicated. If more than one comes up then it is shared.

  4. #4
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Quote Originally Posted by nihil
    If more than one comes up then it is shared.
    How can more sites come up? If the site uses virtual hosts (multiple websites on 1 ip) it will just show the default.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  5. #5
    Senior Member nihil's Avatar
    Join Date
    Jul 2003
    Location
    United Kingdom: Bridlington
    Posts
    17,188
    Sorry SD, I was a bit obtuse with that post.

    If you get a default it won't be the site that you were expecting, so that tells you it is a shared IP?

    As far as I know you cannot find who or how many shares there are, just that there is a share.


  6. #6
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    http://us3.php.net/manual/en/functio...ostbynamel.php

    That will at least get you one or more IPs of the site, but I don't know how you would tell if one IP is hosting multiple sites.
    Last edited by skiddieleet; May 3rd, 2008 at 12:21 AM.

  7. #7
    Senior Member
    Join Date
    Oct 2003
    Location
    MA
    Posts
    1,052
    I will show you!

    So for example take a look at my site (oofki.net) it resolves to 74.208.29.120
    If you goto the ip directly it says page cannot be found - it is shared

    Now take a look at antionline.com it resolves to 63.146.109.212
    If you goto the ip directly it goes to this page! - it is dedicated :-)

  8. #8
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Quote Originally Posted by oofki
    So for example take a look at my site (oofki.net) it resolves to 74.208.29.120
    If you goto the ip directly it says page cannot be found - it is shared
    Which means you haven't set it up properly..

    Now take a look at antionline.com it resolves to 63.146.109.212
    If you goto the ip directly it goes to this page! - it is dedicated :-)
    Or AO is the default site..

    Don't get me wrong, I'm just showing you that this isn't a good way to check
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  9. #9
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,915
    Time for a bit of WebServer 101

    SirDice is 100% correct... so for those that don't understand.. here's how it works.

    When you request a webpage (typing a domain name or IP in your browser's address bar)... A request is generated that looks similar to the following (we'll use antionline.com as our example).

    Code:
    GET / HTTP/1.1
    HOST: antionline.com
    Of course your browser puts plenty of other stuff in there, but that's basic enough to work.

    Web Servers (with a few exceptions) can host multiple websites, configured by hostname, ip, etc. The most common (as in the case of purchased web hosting) is by hostname using Virtual Hosts. In this case the site has a default configured site, and then multiple virtual sites. Depending on the setup that default site could be a valid page or a standard server configuration page. Since your browser simply resolves the domain name you provide and connects to the IP Address that it resolves to, it needs a way to specify which virtual host it is looking for. The HOST: header allows this to happen. It is also a requirement in HTTP/1.1.

    The concept that oofki / nihil suggested is flawed... here's an example:

    74.208.75.235 -- Displays: It Works!
    www.securitysentience.com -- Displays: It Works!

    However that sites also hosts:
    www.killthesun.org
    www.numerophobe.com
    Along with a couple of others.

  10. #10
    Senior Member Maestr0's Avatar
    Join Date
    May 2003
    Posts
    604
    As HT pointed out most servers today use the hostname from the HTTP request to determine the site served. If your IP address serves no site, you didn't set it up to do so. The only way you could script something even remotely accurate would be to dig the PTR record for the IP, and then if you were allowed to do a DNS zone transfer from the domain said record belongs to (if you are not explicitly allowed to do so, I am reasonably certain that even if said DNS server would allow you to pull a zone transfer, which it certainly shouldn't if configured correctly, could land you some time in the pokey) and then find all records in the domain resolving to that IP. Of course as HT noted, that won't find you the names resolving from other domains, unless the DNS server you transfer from had the records.

    -Maestr0

    PS. Zone transfers from domains that don't belong to you are illegal.
    Last edited by Maestr0; May 8th, 2008 at 01:17 AM.
    \"If computers are to become smart enough to design their own successors, initiating a process that will lead to God-like omniscience after a number of ever swifter passages from one generation of computers to the next, someone is going to have to write the software that gets the process going, and humans have given absolutely no evidence of being able to write such software.\" -Jaron Lanier

Similar Threads

  1. PHP script question
    By Moira in forum General Programming Questions
    Replies: 11
    Last Post: July 17th, 2007, 08:34 AM
  2. Assembly Addressing Scheme
    By neemitjamwal in forum Code Review
    Replies: 6
    Last Post: December 27th, 2003, 07:01 PM
  3. Speeding up PHP script execution
    By PuReExcTacy in forum Web Development
    Replies: 2
    Last Post: September 22nd, 2003, 05:02 AM
  4. Date Encryption
    By CyberSpyder in forum AntiOnline's General Chit Chat
    Replies: 0
    Last Post: March 25th, 2003, 09:31 AM
  5. Subnetting tutorial
    By mountainman in forum Other Tutorials Forum
    Replies: 2
    Last Post: December 21st, 2001, 09:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •