DNS question.

kekie

Junior Member
Feb 16, 2015
6
0
0
So, as I understand things, when I connect to www.google.com, my browser first initiates a connection to a DNS server and says "what's the IP associated with www.google.com?" Then the DNS server responds with `216.58.216.4` or whatever. Then my browser connects to 216.58.216.4 (or something), and all is well.

My confusion arises when I try to connect to a webserver, and it only lets me in when I use their domain name, and not when I type in their IP. How does the server know that I didn't contact a DNS server?

Also, when two domain names 1.example.com and 2.example.com resolve to the same IP address, but otherwise identical URLS will yield different pages. i.e., 1.example.com/whatever is different from 2.example.com/whatever, despite 1.example.com and 2.example.com resolving to the same address.
 

kevnich2

Platinum Member
Apr 10, 2004
2,465
8
76
That's because most web server's store multiple websites. Most of the time, you can't access access a web server directly by IP address. The target hostname is transmitted to the web server when you make an http request to that server, so it knows what website subdirectory to point you to.
 

kevnich2

Platinum Member
Apr 10, 2004
2,465
8
76
Your second question is the same answer. The hostname determines what website you're trying to access. www.example.com, www1.example.com and www.example.net may all be located on the same physical server, using different subdirectory' and accounts. When you type www.example.com in your browser, it sends that request to the specific web server who then points you to that account's directory on the server. You usually cannot pull up a general website by IP address anymore. You used to be able to about 15 years ago but that's not usually possible anymore, especially with the IPv4 shortage.
 

kekie

Junior Member
Feb 16, 2015
6
0
0
Oh! I didn't know that the hostname was transmitted in the HTTP header.
That makes sense.