Edit the Host File and Set the Hostname
To edit the host file and set the hostname, perform the following steps:
Edit the Host File
- Using a text editor, open the host's file on every host in your cluster.
For example: vi /etc/hosts
- Add a line for each host in your cluster. The line must consist of the IP address and the FQDN.
For example:
1.2.3.4 <fully.qualified.domain.name>Do not remove the following two lines from your host file. Removing or editing the following lines may cause various programs that require network functionality to fail.
127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6Set the Hostname
- Confirm that the hostname is set by running the
hostname -fcommand.
This must return the <fully.qualified.domain.name> you just set.
- To set the hostname on each host in your cluster, use the following command:
hostnamectl set-hostname <fully.qualified.domain.name>Was this page helpful?