DNS

Difference Between a Hostname and a Domain Name

Many people are confused about the concept of Hostname and Domain Name. A good understanding of the basics of DNS or Domain Name System is needed to properly distinguish the two. This will help network administrators to design and secure the network of their organization in the best manner.

In the following sections, we will explore the concept of Domain Name and Hostname.

Review of History

In the early days of the internet (the ARPANET era), there was a file called “hosts.txt” that had the names and IP addresses of all the computers on a network. This file was maintained by a site from where all other network computers would get the update about all other computers. This approach was good for at most a few hundreds of computers on a network. It was clear that the size of the “hosts.txt” file would eventually rise with more devices being added in the future. Thus, it would become practically cumbersome to maintain this file. This meant that this method will ultimately fail to survive. Hostname conflict was another issue while maintaining this huge file. To overcome these problems, DNS (Domain Name System) was introduced in 1983. When a host wants to connect with another host on a network using Hostname, DNS maps the name of the host to its IP address. Besides resolving a Hostname to an IP address, DNS performs many other operations.

DNS Hierarchy and Domain Name

DNS uses a distributed database system and employs a hierarchical scheme to manage them. The DNS hierarchy is actually an inverted tree structure, the top of which is called the root domain. The root domain is further divided into top-level domains like .com, .net, .edu, .org, etc. The top-level domain can be further categorized as countries and generics.

The country’s domains are two-bit codes that represent each country in the world. For example, .jp is used to represent Japan, .uk for the United Kingdom, etc. The generics domains are mostly three or more character TLDs. The TLD can further contain many second-level domains, then second-level domains can include more third-level domains, and so on. These domains are separated by a period or .dot character. E.g., contact.amazon.com, support.amazon.com have “.com” as TLD, “amazon” is a second-level domain, “contact” and “support” are third-level domains.

Figure 1: DNS Hierarchy

The management of top-level domains like naming is governed by ICANN (Internet Corporation for Assigned Names and Numbers). The second level domains are distributed by the registrars assigned by ICANN. To get a new domain name, e.g., with .com TLD, go to the corresponding “.com” registrar and check if the second-level domain or simply the domain name is available or not. You can register a new and unique domain by paying a small fee or for free in case of some TLDs (.tk, .ml, etc.).

There are two types of domain names: absolute and relative. Absolute domains are those which end with a period notation like “cs.mit.edu.”. Relative domains do not end with a period.

Domains are named in a bottom-to-top manner, covering all the entities from the domain itself up to the root. Conventionally, they are interpreted from left to right, with the left entity being most specific and the right entity being least specific.

Domain names can be used with any case as they are case insensitive. Navigating to GOOGLE.COM is equivalent to google.com. Domain names must begin with an alphabetic letter but can end with a character or digit. In between these two ends, it can contain hyphens. The length of a domain name is restricted to less than or equal to 63 characters.

Hostname or Fully Qualified Domain Name (FQDN)

The terms FQDN and Hostname are used in different ways by some text, but the core meaning remains the same. FQDN and Hostname are used interchangeably [1], whereas [2], FQDN is considered to be composed of Domain Name and Hostname separately. However, in both terminologies, there is a unique Hostname (with domain name included) or Fully Qualified Domain Name (FQDN) for every host on the internet.

Hostnames (with domain names included) for end-systems are based on the DNS hierarchy of an organization. As an example, consider a host machine, host1, within the cs.mit.edu domain. The FQDN or Hostname for this host will be “host1.cs.mit.edu”, which will be unique on the internet. In the same way, if it is a web URL, like www.mit.edu, we can interpret “www” as the Hostname and “mit.edu” as the Domain name.

FQDN or fully qualified domain name is absolutely unambiguous as it requires to be unique for every host on the internet. The best practice for naming hosts (without domain name) on a network is to use different identifiers for each. However, local Hostname (or Hostname without complete domain information) need not be unique, but this approach may create errors like network connectivity issues.

Usually, a host has only one hostname, but it can take multiple hostnames. The local host’s file can be used to resolve IP addresses or hostnames on a local computer. While resolving a hostname, the contents of the “/etc/hosts” file are checked first. If an entry for the hostname is not found here, the stub uses the DNS nameserver.

A static hostname may be specified in the file “/etc/hostname” on a Linux system. Using the “hostnamectl” utility, we can view the FQDN of the system and modify this file as well. It is shown in the picture below:

Figure 2: Configuring Hostname

Conclusion

Network administrators should have good knowledge of properly configuring Domain name and Hostname. This will help them in troubleshooting many networking issues on their organization’s network. What you can do next is to explore different tools for system and networking monitoring.

References:

1. Red Hat Enterprise Linux 4: Reference Guide. (n.d.). MIT – Massachusetts Institute of Technology. https://web.mit.edu/rhel-doc/4/RH-DOCS/rhel-rg-en-4/ch-bind.html

2. About fully qualified domain names (FQDNs). (2018, May 14). Indiana University Knowledge Base. https://kb.iu.edu/d/aiuv

About the author

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn
.