Skip to content

Setup Hostname without DNS Server on CentOS 7

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. buhpc1 buhpc2 buhpc3 buhpc4 buhpc5 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!


If I am on buhpc1, and I do:

ping buhpc2

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