Shared hosting is a type of Web hosting service that allows multiple websites to share a physical Web server and its resources among the hosted websites. Shared hosting logically distributes a Web server to accommodate, serve and operate more than one website.
Techopedia explains Shared Hosting
Shared hosting is one of the most common and popular forms of Web hosting service. It is generally provided by Web hosting service providers, which usually have multiple Web servers on-site. Upon signup with the provider, each website’s logical partition/space is created on the Web server, which houses data for that website only. Other websites are also present on the same Web server, simultaneously sharing the storage, computing power, network and other resources. Because it is a shared service, shared hosting is a cheaper alternate to dedicated hosting.
Shared hosting is recommended for websites that are smaller in size, don’t have a large amount of Web traffic, have considerably lower security concerns and require cost-effective solutions for website hosting.

IP-based

In IP-based virtual hosting, also called dedicated IP hosting, each virtual host has a different IP address. The webserver is configured with multiple physical network interfaces or virtual network interfaces on the same physical interface. The web server software uses the IP address the client connects to in order to determine which website to show the user. The issue of IPv4 address exhaustion means that IP addresses are an increasingly scarce resource, so the primary justification for a site to use a dedicated IP is to be able to use its own SSL certificate rather than a shared certificate

Name-based

In name-based virtual hosting, also called shared IP hosting, the virtual hosts serve multiple hostnames on a single machine with a single IP address. This is possible because when a web browser requests a resource from a web server using HTTP/1.1 it includes the requested hostname as part of the request. The server uses this information to determine which website to show the user.

Understanding DNS and Name Servers

DNS stands for "Domain Name System." The domain name system acts like a large telephone directory and in that it's the master database, which associates a domain name such as www.wikipedia.org with the appropriate IP number. Consider the IP number something similar to a phone number: When someone calls www.wikipedia.org, the ISP looks at the DNS server, and asks "how do I contact www.wikipedia.org?" The DNS server responds, for example, "it can be found at: 216.198.221.66.". As the Internet understands it, this can be considered the phone number for the server, which houses the website. When the domain name is registered/purchased on a particular registrar's "name server", the DNS settings are kept on their server, and in most cases point the domain to the Name Server of your hosting provider. This Name Server is where the IP number (currently associated with your domain name) reside.