How DNS Works

dash-dns
#1

I would like to know how DNS works.
According to Cloudflare, DNS translates domain names to [IP addresses] so browsers can load Internet resources.

Consider these two websites
pasarworld.com

Both websites point to this IP address: 85.10.193.139

How is the possible that the first domain points to webpage and second domain points to different webpage?

I would appreciate if some one could provide a detailed explanation.

Thanks!

#2

Your browser resolves the website to a certain IP address, but upon making the request sends the Host header. This is the exact domain name that the user wanted to go to (eg the Host header will be www.google.com if the user goes to https://www.google.com/imghp).

With almost every single web server out there, there is a way to serve different content based on what this Host header is. In apache, it’s virtual hosts or vhosts. in nginx, it’s just a separate server block. So a configuration with the vhost python.example.com can serve a python application while another (sub)domain with the vhost php.example.com can instead serve a PHP application.

A good SO post on the topic:

It goes a little more in-depth than this, eg. for HTTPS connection, the browser sends SNI instead, but that’s the basics.

closed #3

This topic was automatically closed after 14 days. New replies are no longer allowed.