By default, your server is started with the server’s given name as the hostname.

Change a server’s hostname

  1. Check existing hostname
hostname
  1. Modify the value to match your FQDN hostname, as shown in the following example:
hostnamectl set-hostname NEW-HOST
hostname
NEW-HOST
  1. Open the file at /etc/hosts. To update the information for internal networking, change the host that is associated with the main IP address for your server, as shown in the following example:

    sudo vi /etc/hosts
    127.0.0.1 localhost
    127.0.1.1 k8s-master
     
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
  2. Change the domain name (where required)

    $ sudo vi /etc/resolv.conf
    domain abc.com            <--- This would be the domain.
    nameserver 173.203.4.8
    nameserver 173.203.4.9
  3. Change networking configuration /etc/sysconfig/network

    boyang@k8s-worker2:/etc$ cat hostname
    k8s-master
  4. Restart syslog

$  service rsyslog restart
or
$  systemctl restart rsyslog

Reference List

  1. https://docs.rackspace.com/support/how-to/linux-hostname-change/