How should the /etc/hosts file be set up on RHEL cluster nodes?

Solution Verified - Updated -


  • Red Hat Enterprise Linux (RHEL) with the High Availability Add-On


  • Should cluster node names and fence device host names be defined in /etc/hosts, or can I just rely on DNS to do lookups?
  • What is the /etc/hosts file used for, and how should it be set up?
  • How can I avoid fencing failing and/or nodes being unable to join a cluster when DNS lookups are not functioning?
  • How to configure /etc/hosts file when configuring a two node Red Hat High Availability cluster?


  • In Red Hat Enterprise Linux with the High Availability Add-On, the /etc/hosts file should be used to define the IP address and host names for all cluster nodes and fence devices. This is recommended to eliminate DNS as a single point of failure. Configuring the cluster software to use the preferred network interface often involves specifying the correct fully qualified name in the configuration, and so /etc/hosts should also list nodes in this format whenever possible:
    <IP>               <Fully Qualified Domain Name>    <Short Name>                node1                node2

If only shortnames are desired to differentiate a specific node's address, they can be specified in /etc/hosts in place of a fully qualified name:

    <IP>               <Short Name>        node1        node2
  • Below is a complete example /etc/hosts for a three-node cluster with a single fence device per node:
    # Do not remove the following line, or various programs
    # that require network functionality will fail.               localhost.localdomain    localhost
    ::1                     localhost6.localdomain6    localhost6
    # cluster nodes.    cluster-1    cluster-2    cluster-3
    # fence devices.        node1-fence        node2-fence        node3-fence
  • Note: In the place of hostnames, the cluster configuration can use IP addresses for node names and fence device ipaddr values. If no hostnames are used to specify a node in the cluster configuration, then /etc/hosts does not need to contain any specific entries for the cluster nodes.

  • Note: The use of DHCP for obtaining an ip address on an interface being used by corosync for heartbeat communication is unsupported

Root Cause

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.