A modern application such as web browser, Apps, mail servers, FTP servers, etc… lets you connect to them using a user-friendly domain name such as www.somedomain.com. However, machines can only connect via IP address using a set standard of protocols (TCP or UDP). These user-friendly names (also known as a default hostname) are resolved into an IP address through a process known as Domain Name Resolution (DNS). Domain name resolution is typically done by a Name Server (NS).
DNS is a standard domain name resolution service used on the Internet. Most operating systems (OS) resolve domain names using a DNS server, this can either be a local network DNS or a web of connected DNS servers provided by your ISP. These servers map/(query for) the IP using the domain name.
Most Operating systems that communicate using TCP/IP have a host file. This file allows you to set your local domain name and IP mappings – acting as a private local DNS. When a requested domain matches that in your host the mapped IP is returned, else it queries ISP’s DNS servers. The location of a Windows host file:
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost NNN.NNN.N.N my.domain1 NNN.NNN.N.N my.domain2
Generally, host files are used for testing. You can also speed up internet browsing by adding frequently used sites to your DNS (not advised!)- reducing the overhead of querying domain names.
Domain & Host name & CNAME
The hostname is the real name of the host server such as www.mydomain.com. The Conical name (CNAME) is a name that the host server is known by, but is not the hostname. A server can have multiple CNAMEs that refers to the same hostname, for example, a server with hostname ‘mydomain.com’ can host a mail and web server on the same IP. It could have CNAMEs of ‘mail.mydomain.com‘ and ‘anything.mydomain.com‘
A domain such as www.mydomain.com is the default hostname for the domain ‘mydomain.com’. The ‘www’ part refers to the world-wide-web and is the hostname segment and the ‘mydomain.com’ is the domain. By convention, www is reserved for web servers.
Since ‘www’ is the default hostname for web servers, then the domain is used in the context of an internet browser the domain has no host segment. The two parts together form a qualified hostname (domain name qualified hostname), also known as a subdomain. Therefore ‘anything.mydomain.com’, ‘any.any.mydomain.com’, etc… are all subdomains.