Configuring Hostnames and /etc/hosts files.
After we have finished installing the three virtual machines to be used in our lab, the next thing is to make sure that the servers can talk to each other and communicate using their IP addresses and hostnames.
IP addresses are not user-friendly for everyday tasks. Instead, people prefer using hostnames rather than numerical strings. Linux provides name resolution mechanisms to map hostnames to IP addresses.
One approach is to manually define static entries for each hostname in the /etc/hosts
file of every system. However, this requires updating each server’s hosts file individually.
Alternatively, the Domain Name System (DNS) can be used for name resolution. DNS is a distributed network of servers that maps hostnames to IP addresses and vice versa. For this to function, a system must be configured to contact a nameserver. The nameserver does not need to be on the same subnet, but the system must be able to reach it. Nameserver settings are usually provided via DHCP or configured manually in the /etc/resolv.conf
file. Later sections of this chapter will cover the configuration of name resolution in more detail.