There're 3 files need to be modified in order to change hostname.
- The hostname file
- The interface configuration file.
- The hosts file
[root@localhost ~]# vi /etc/hostname
primary01.example.com
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="yes"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="eth0"
UUID="..."
ONBOOT="yes"
IPADDR0="10.12.13.123"
PREFIX0="8"
GATEWAY0="10.0.0.1"
DNS1="8.8.8.8"
DOMAIN="example.com"
HWADDR="..."
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
[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