Change hostname for your Centos 7

In order to change your system’s hostname if you are running Centos 7, follow these steps:

  1. Update the following file /etc/sysconfig/network by replacing or adding the variable HOSTNAME with the following format:
    HOSTNAME=your.hostname.com
  2. After that, ensure your main server IP address (see it with hostname -i) is pointing to the new hostname by updating or replacing if needed, inside the file /etc/hosts, so you should leave it as the following example (assuming you are running with the IP address 192.168.50.20):
    192.168.50.20    your.hostname.com
  3. After that, it is only needed to restart the network (BEWARE: do not do it remotely via ssh or similar, otherwise you will lose your connection):
    /etc/init.d/network restart
  4. Then, log off and log in and run the following command to check the new value:
    hostname -f

After these steps, your system’s hostname is now changed. However, it is possible you’ll have to restart some services that cache this value (or even restart the system to ensure a fresh start with the new value).

0
  Entradas relacionadas
  • No related posts found.