Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

does anyone know how to programmatically quiery the list of web sites sitting at a given server IP address? And, by the way, how to prevent others from seeing what other sites your server hosts??

share|improve this question

migrated from stackoverflow.com Nov 3 '09 at 14:03

This question came from our site for professional and enthusiast programmers.

7 Answers 7

You can't hide a site if its in the interweb DNS - would be like having an ex-directory phone number that is in the directory.

Of course you can run a server that is not associated with anything in DNS.

share|improve this answer

I don't think there's any way to do this from the outside. As long as your server configuration is secure (it should be anyway), there's no reasonable way to do it. Someone could always do an ip address lookup for every possible domain name and compare the ip addresses. There's no way you could prevent them from doing that, but it's not very realistic.

share|improve this answer
    
that's a brute force approach :) this may be acceptable, and I understand it's always possible. I just want to understand how to prevent other - easier - ways. –  Andy Nov 2 '09 at 18:43
    
Right. I think the brute force method is the ONLY way. –  Scott Saunders Nov 2 '09 at 18:49

This isn't programmatic, but this site attempts to answer that question. Here's the page for stackoverflow.com's IP

http://onsamehost.com/69.59.196.211/

EDIT: That is, it tries to answer your first question.

share|improve this answer
    
OK, scrape this! (But how do they do it?) –  Ewan Nov 2 '09 at 19:32
    
One way one could do it, in bulk, is to create a dictionary. Given a list of domain names (getting which is its own problem), resolve DNS on them & note the IPs. And that might be what this site is doing. –  Grumdrig Nov 2 '09 at 22:12

This is knows as a reverse DNS lookup (or simply, rDNS).

You can use the host command to do an rDNS on Linux:

$ host 72.14.179.79

You can use the nslookup command on Windows/Linux:

nslookup 72.14.179.79

Most networking libraries provide some way to get this information. For example, you can use the following in Java:

java.net.InetAddress.getByName("72.14.179.79");

But please note that you might not get a list of all the domain names that are pointing to the specified IP address. For example, the IP address in the above examples belongs to one of my servers which has several domains pointing to it but an rDNS lookup only returns a single record. Perhaps further investigation of this behaviour can help you figure out how to prevent your domain names from showing up in the rDNS lookups.

share|improve this answer
    
thanks! basically it means if I want to prevent others seeing all of my sites at a given host I will need to remove the reverse DNS entries from my DNS server.. –  Andy Nov 2 '09 at 18:55
    
@Andy: No. Reverse DNS will only return one single hostname. It will not show ALL the sites on your server. Make the REverse DNS hostname something generic, and no one will know what other sites are on there. –  Scott Saunders Nov 2 '09 at 18:58

From the "outsite" or in an anonymous manner, there is no way to programatically request the list of domain names that are bound to a particular web server's IP address. Stock security built into IIS/Apache/others prevent such a thing from happening. The ability to have a web server listen for multiple domain names on a single IP address is credited to HTTP 1.1's Host Header implementation.

Websites like http://www.sitedossier.com maintain a database of domain names and their respective "www" DNS A record, then allow us to query by IP address. They likely scrape search engine results by requesting a large sampling of fake queries (say straight from a dictionary), or have implemented a basic spider themselves (which would be by far more efficient).

share|improve this answer

Perform a port scan using nmap and look for web servers.

share|improve this answer
    
nmap will tell you whether a server is running at an IP address, but it won't tell you what sites that server is serving, will it? –  Scott Saunders Nov 2 '09 at 18:36
    
is there a chance to prevent this? I want to host a few sites on one server, but don't want others they are related to each other in any way... –  Andy Nov 2 '09 at 18:39

Another site I have used with good results is http://www.sitedossier.com/ip/69.59.196.211

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.