Skip to content
Home » Linux » How to Change HostName on Enterprise Linux 6.5

How to Change HostName on Enterprise Linux 6.5

In Enterprise Linux 6, it is slightly different from previous versions on changing hostname. You don't have to modify /etc/resolv.conf anymore, the interface configuration file (i.e. eth0) will reflect its search domain to /etc/resolv.conf automatically.

By default, modifying /etc/resolv.conf may take effect within the instance, but it will be reset by NIC configuration after reboots. Why is /etc/resolv.conf unable to be persistent after reboots? You may refer to my post for more information: How to Change DNS on Enterprise Linux 6.5.

There're 3 files need to be modified in order to change hostname.

  1. The basic network configuration
  2. [root@localhost ~]# vi /etc/sysconfig/network
    NETWORKING=yes
    HOSTNAME=primary01.example.com
    #HOSTNAME=localhost.localdomain
    GATEWAY=192.168.15.1
  3. The interface configuration file, it's usually eth0
  4. [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=Ethernet
    UUID= ...
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=none
    HWADDR= ...
    IPADDR=10.12.13.123
    PREFIX=8
    GATEWAY=10.0.0.1
    DNS1=8.8.8.8
    DOMAIN=example.com
    #DOMAIN=localdomain
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=yes
    IPV6INIT=no
    NAME="System eth0"
  5. The hosts file
  6. [root@localhost ~]# vi /etc/hosts
    127.0.0.1   primary01 primary01.example.com localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         primary01 primary01.example.com localhost localhost.localdomain localhost6 localhost6.localdomain6

Now, you can restart your server to verify the results.

Further reading: How to Change DNS on Enterprise Linux 6.5.

Leave a Reply

Your email address will not be published. Required fields are marked *