How DNS Works

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

Both websites point to this IP address:

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.


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 if the user goes to

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 can serve a python application while another (sub)domain with the vhost 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.

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