Tips for /etc/hosts
“The computer file hosts is an operating system file that maps hostnames to IP addresses. It is a plain text file. Originally a file named HOSTS.TXT was manually maintained and made available via file sharing by Stanford Research Institute for the ARPANET membership, containing the hostnames and address of hosts as contributed for inclusion by member organizations. The Domain Name System, first described in 1983 and implemented in 1984, automated the publication process and provided instantaneous and dynamic hostname resolution in the rapidly growing network. In modern operating systems, the hosts file remains an alternative name resolution mechanism, configurable often as part of facilities such as the Name Service Switch as either the primary method or as a fallback method.”
Administrators can use an /etc/hosts file to enable a specific network host to be able to perform the necessary task of mapping Internet Domain Names (such as Google.com ) to Internet Protocol address numbers (such as 142.250.186.142) without having to delegate that name resolution request to a Domain Name Server.
CentOS 7 and CentOS 8 provide VM, disk, and container images where /etc/hosts files are configured with routine entries for packet routing within the network host itself, with the loopback addresses for IP v4 and IP v6 protocols. These are commonly known as the loopback or localhost addresses.
Organizations can also inject into these /etc/hosts files additional entries that give the host human-friendly nickname aliases, such as my-host.example.com
, and for other peer systems such as virtualization host servers.
When an /etc/hosts file includes IP / Domain Name entries which are incorrect or which give priority to IP v6 protocols, then applications that rely on proper networking will be blocked from properly communicating or may even fail to launch when they cannot establish their socket binding responsibilities.
To view the /etc/hosts file on the Syndeia server(s):
sudo cat /etc/hosts
A typical and succinct /etc/hosts file for a CentOS system supporting Syndeia will look like:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Notice here that:
the IP v4 loopback address of 127.0.0.1 comes before any for IP v6
the hostname of localhost is mapped to 127.0.0.1
localhost is also mapped to the IP v6 loopback address of ::1 - but only after the IP v4 assignment
there are no private, non-routing IP address aliases here for the host
Private, non-routing IPs are those within
Class A:
10.0.0.0
to10.255.255.255
Class B:
172.16.0.0
to172.31.255.255
Class C:
192.168.0.0
to192.168.255.255
there are no public, routing IP addresses here for the host
When this simplicity is preserved, Syndeia’s microservices can be configured to use hostnames values like “localhost” or “127.0.0.1” and they will operate properly.
When there is intentional or errant customization of the /etc/hosts file, Syndeia may likely fail to come up properly if configured with the choice of “localhost” for hostname property settings.
Consult the CentOS documentation for details on how CentOS operates and for additional commands to reverse changes made, to make additional changes, or to configure additional /etc/hosts entries for systems other than Syndeia.