1

I want to know how a web server can distinguish between requests of different DNS names on the same server (same IP)?

for example, in my university there are two websites:

fea.kau.edu.sa
engineering.kau.edu.sa

and when I use nslookup on Windows, I got the same IP address for both domain names. Can you explain please?

3 Answers 3

8

HTTP 1.1 requires that all client systems send a header, Host, which indicates to the server which hostname they are sending the request for.

This allows the server to read that header, and respond with content for the appropriate site.

Without this feature, a different IP address would be needed for each different site; we would have run out of IPv4 space even sooner if we didn't have this in place.

6

Fire up your favourite packet tracer (something like wireshark) and watch what actually happens when you connect.

A very simple request might look like this:

GET / HTTP/1.1
Host: www.example.com
​

(note the empty line at the end if you want to re-create this yourself by using, say, telnet. You can see a lot of this stuff also over in wikipedia)

The Host: part of the request tells the web server which site to access.

There's a lot of stuff shown in these headers, so you might want to get to know them with a browser plugin like Firebug

1
  • What happens if the IP is accessed directly? For example, if I enter http://216.58.213.238 instead of http://google.com in my browser?
    – bweber
    Sep 2, 2016 at 8:20
2

Simple.

Since a long tim, every HTTP request.... ...INCLUDES THE DOMAIN.

Basically the PAYLOAD (not tcp, the http request structure) tells the web serve rwhat the domiain is for.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

has the fields transmitted by the browse. There is one "HOSTNAME".

Most other protocols - do not care.

2
  • is English your first language?
    – Alnitak
    Jan 10, 2012 at 9:47
  • No. Simlpe like that.
    – TomTom
    Jan 10, 2012 at 10:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .