Monday, April 9, 2018

CentOS 6 - Change hostname

To check the host name of CentOS 6,

hostname
hostname -f

To change the host name on CentOS 6,
  1. sudo vi /etc/sysconfig/network
    1. Update HOSTNAME=[hostname.domain.com] to match the FQDN.
    2. For example,
      1. HOSTNAME=cent6.contoso.edu
  2. :wq
  3. If necessary, update /etc/hosts file for internal networking. Change the host that is associated with the IP address.
    1. sudo vi /etc/hosts
    2. change the host name as needed.
  4. Run the hostname command to change the hostname on the server. For example,
    1. sudo hostname cent6.contoso.edu
  5. Restart network 
    1. sudo /etc/init.d/network restart


No comments: