Hostname (formerly nodename) is a unique term that identifies individual devices such as computers or servers within networks. Both local area networks (LANs) and wide area networks (WANs), such as the internet, use hostnames. The assignment of unique hostnames helps users identify different devices on a network. The hostname consists* of a simple sequence of alphanumeric characters and optionally a hyphen.
In the context of websites, the domain name is appended to the actual hostname to ensure a unique assignment. A period separates the domain from the host-specific name. Thus, for the URL https://www.example.com the domain name would be example.com and the hostname would be www, which is the usual host for web servers. Another possible hostname would be m, for example, as the name for servers providing websites for mobile devices. Mail servers, on the other hand, often have the name mail.
If the domain name is complete, as above, including the top-level domain (.com), it is called a fully qualified domain name, FQDN.
FQDNs containing DNS domains are stored in the Domain Name System (DNS), along with the IP addresses of the host they represent to assign IP addresses to domains and vice versa.
How do hostnames work?
Since the early days of network technology, it has been considered user-friendly to assign a hostname to a computer or server while the computer maintained its internal host address (the host part of an IP address) or network address. The true "name" a computer needs to communicate within a network is actually just a set of numbers, the IP address. Early computers used small integers as their host address on the internet. One of the first internet “Request for Comments” (RFC), named "Standardization of host mnemonics”, lists the table with all associated host numbers and hostnames for the first computers connected to the internet. This table was stored in a file called HOST.TXT on each computer that wanted to communicate with other computers on the web.
While the original file was only 20 entries long, it quickly became clear that this solution was not scalable or flexible enough to handle the rapidly growing number of computers and servers connected to the Internet. Additionally, such a file would have to be created and maintained individually on each computer. To counteract these problems, the DNS was developed.
The Domain Name System is similar to a phone book. Each IP address required for communication between network computers is linked to a readable and memorable name in the DNS. For TCP/IP, the protocol family underlying the Internet, every computer has a network IP address that follows a certain syntax to ensure its uniqueness and validity. An IP address alone says nothing about the function of a computer within a network. To make it easier for users to assign them, each computer is given a host name.
Policies for hostname assignment
There is no standard format for local network hostnames; they can be assigned free of conventions. However, they may not contain spaces or special characters such as commas, periods, or apostrophes.
The rules for public hostnames were first standardized in the original hostname specification "DoD Internet Host Table Specification". This standard said that the name should be a text string consisting of the letters A through Z (case sensitive), the digits 0 through 9, the minus sign (-), and the period (.). To date, no spaces are allowed as part of a host name. The first character had to be a letter and the last character could not be a minus sign or a period. It was also recommended not to exceed 24 characters.
However, this protocol, known as RFC 953, was replaced in 1989 by the newer RFC 1123. Since then, the first character can be either a letter or a number, the domain name must not end with a hyphen, and it can be up to 255 characters long.