Virtual Host

IP-based virtual host vs Name-based virtual host. The magic of sharing.

Virtual Host

To understand more about IP-based virtual host vs Name-based virtual host, first, we would need to clear the path with the definition of the virtual host. A virtual host is a technology that allows multiple websites to be called using their own domain names and all of this happens on the same server or inside the same system. They have in common that they all share the same environment.

Imagine that you have a domain name called carsforsale.com and a website with the content hosted in Neteron, at the same time another person who happened to be the owner of a restaurant called Steak House owns the domain name steakhouse.restaurant, and yes; nowadays it is possible to register hundreds of new domain extensions like .bar, .restaurant, .rocks etcetera apart of the traditional .com, org and so on; and this person has its own web site hosted in neteron, in the same server as the carsforsale.com.

Do you see now what is happening? at least two domain names and two different websites are hosted inside the same server and both share resources, hard discs, processor, memory, interface card, and IP addresses, but...

How a web server knows what information to send when some client (web browser) makes requests for a specific domain that has an IP address that is been shared by multiple web hosts?. This is where IP-based virtual hosting vs Name-based virtual host enters into action.

To understand what is the dilemma we would need to go deep into the topic of how the domain names are resolved.

There is something called DNS, and they are in charge of translating a domain name into a numeric IP address, and in the example before they could or could not be sharing the same IP address, and this is where virtual hosts are coming into action together with the web server software, like the famous Apache.

There are two types of virtual hosts used in the shared web hosting environment, the IP-based virtual host and the Name-based virtual host, and they make everything possible.

IP-based virtual host

The IP-based virtual host would let a single domain name have its own dedicated IP address and given the fact that one interface can have multiple IP addresses, it would be possible to have multiple domains with their own exclusive IP address. For this to work, these IP addresses must be announced and routed from and to the entire world.

When somebody writes the domain name in a navigator, this will resolve the IP address using a DNS server and this will give back the unique IP address owned by that domain. The Web server knows what information to send based on the fact that the IP address requested belongs only to the specific domain name.

Name-based virtual host

The Name-based virtual host is different in the way that multiple domain names share the same IP address. What this means is that the DNS servers will have in their database different domain names assigned with the same IP address, and when the client uses the navigator and write a domain name, a DNS server will be consulted and it will give back the shared IP address for that request.

The web server relies on the client to give back the correct hostname as part of the information needed, meaning that the server will have both not only the IP but the hostname requested before it send the website information to the client and that is how the client navigator displays the correct information in its navigator, even when different domain name shares the same IP address.

Conclusion

In conclusion, both methods are valid options and It is up to you to decide if you want an IP-based or a Name-based hosting. In general and for the majority of the cases the Name-based is enough, cheaper, and absolutely transparent in all aspects. There are cases where customers would prefer to have a dedicated IP address for their own applications but this depends entirely on you.

It is always possible to change and jump from one to another, at any time you want.

Resources:

DNS Server: https://en.wikipedia.org/wiki/Name_server

Apache documentation: https://httpd.apache.org/docs/

Vhost documentation: https://httpd.apache.org/docs/2.4/en/vhosts/