Question

I understand the process by which an IP address is obtained from a domain name, contacting the hierarchy of name servers until an address is returned, but when an IP address corresponds to multiple domain names, how is the request resolved? If I set up an Apache server, is there a method by which it would be able to distinguish these different domains?

Was it helpful?

Solution

When you reverse-resolve an IP it will come back to it's PTR record in the zone, which there is only one. So for example www.google.com

Non-authoritative answer:
Name:    www.google.com
Addresses:  2607:f8b0:4007:800::1010
          74.125.224.242
          74.125.224.244
          74.125.224.240
          74.125.224.241
          74.125.224.243

but 74.125.224.242 reverse resolves back to:

Name:    lax04s08-in-f18.1e100.net
Address:  74.125.224.242

and not www.google.com.

===

The apache server itself listens on an ip address independent of the hostnames attached to the ip, using the Listen directive in the config file. Apache just wants to hear data coming across port 80 on that IP.

Listen *:80 <-- listen on all adapters (127.0.0.1 and all network IPs)

or

Listen AAA.BBB.CCC.DDD:80 <-- listen on a specific adapter..

When you set up your virtual hosts Apache is able to pull the hostname from the headers and send it over to the right DocumentRoot to handle the pages you are presenting with that hostname.

Example:

<VirtualHost *:80>
    ServerName www.server.com
    ServerAlias server.com
    DocumentRoot "c:\htdocs\wwwroot"
</VirtualHost>

<VirtualHost *:80>
    ServerName www.server2.com
    DocumentRoot "c:\htdocs\wwwroot2"
</VirtualHost>

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top