Authors Top

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Overview

In this tutorial, we’ll present a general overview of hostname in the computer network. We’ll also discuss the characters that are allowed to be used in a hostname. With its help, we can uniquely identify a device on the Internet.

2. Introduction to Hostnames

A hostname is a name assigned to any networking device. The main purpose of setting a hostname is to give them an identity on the Internet so that the networking devices can communicate and exchange data with each other. It’s a part of a fully qualified domain name (FQDN). An FQDN uses the Domain Name System (DNS) in order to be identified uniquely over the local network.

Let’s look at the structure of the FQDN:

szfafsd.drawio

An FQDN starts with a hostname followed by a domain and a top-level domain (TLD).

The most common use of the hostname is when we open a website using the URL or name of the website. We can also open a website using an IP address, but it’s challenging to remember. Therefore, we use a hostname to avoid using an IP address that connects to the DNS to access a website.

In a real-time operating system like Windows OS, we can easily find the hostname by entering the command “hostname” or “ipconfig /all” in the command prompt. Additionally, the command “ipconfig /all” displays the hostname of the computer along with the IP configurations of the system.

3. Guidelines for Hostnames

The syntax for the hostname was first standardized and documented in DoD Internet Host Table Specification. A hostname contains a text string. Each element in a hostname is limited to \mathbf{63} characters. There’s a limitation in the size of a hostname as well. A hostname can contain a maximum of \mathbf{253} characters, including the dots.

The text string in a hostname must be from ASCII characters. It includes the upper or lower case (A to Z or a to z), digits (\mathsf{0} to \mathsf{9}), the dot symbol (.), and the hyphen symbol (-). Hence, generally, we use an alphabet as the first letter of a hostname. In some cases, we can also use a digit as the first letter. Finally, we can’t use the dot or hyphen symbol as the first character.

A hostname also shouldn’t end with a period or a dot symbol. When a hostname is an FQDN, we may use the dot symbol as the last character. Finally, there’s no provision of spaces in the hostname.

A good hostname contains theme names and real words in order to increase readability. It’s not a good practice to use a lengthy text or some person’s name for the hostname.

4. Examples of Hostnames

Let’s now see some examples of hostnames. In the URL “drafts.baeldung.com”, “drafts” is the hostname. We can observe it contains all lower case alphabet and follows the rules we discussed.

We’re taking a second example where the hostname is very conventional. In the URL “www.baeldung.com”, the hostname is “www”.

In modern day-to-day life, we mostly use our mobile devices to open web pages. An example of a web address specifically designed to browse via a mobile phone is “m.fxbkex.com”. Here, “m” is the hostname, and it denotes a mobile device-friendly web address.

Various mail servers use the protocol name as their hostname. For example, “smtp.gmail.com” represents Gmail. Here, “SMTP” is the hostname as well as the name of the protocol used in sending emails by Gmail.

5. Conclusion

In this short article, we discussed the basic concept of hostname in networking. We presented the standard rules we need to follow when setting a hostname with some examples.

Authors Bottom

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!