Let’s say that you have a cluster of 6 nodes and you do not have a DNS server.

How do you map the IPs to their perspective hostnames properly so that every node in the cluster can detect the other node’s hostname? We need to bypass the automatic lookup.

I have 6 nodes with the following IPs and hostnames.

128.197.115.158 buhpc1
128.197.115.7 buhpc2
128.197.115.176 buhpc3
128.197.115.17 buhpc4
128.197.115.9 buhpc5
128.197.115.15 buhpc6

Now, we edit every node’s /etc/hosts file.

For all nodes

vi /etc/hosts

The original files look like this:

We change the files to look like this:

Restart the network.
systemctl restart network

Make sure that the /etc/hosts file is exactly the same on all 6 nodes! Then, after restarting all the networks with the above command, the /etc/hosts file with bypass the automatic DNS lookup and relate those hostnames to those IP addresses!

Testing

If I am on buhpc1, and I do:

ping buhpc2

I will be pinging 128.197.115.7. In the /etc/hosts file, we have defined 128.197.115.7 as buhpc2.