Hostname reverting

Posted January 14, 2019 1.3k views
CentOSGetting Started

I’m running some centos7 droplets. I’ve followed other posts saying to update hosts and hostname to change the hostname of the droplet and that works fine. A reboot to two later however and the hostname file has reverted back to its original content. How do I stop that from happening?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Are you running NetworkManager? Here are a few more places to check if you haven’t already:

hostnamectl set-hostname
/etc/sysconfig/network # set variable HOSTNAME=""



To change the hostname and preserve changes after a reboot you have to do two things:

1- Change the hostname in /etc/hostname file.

2- Execute this command: hostname <new_host_name> replace <new_host_name> with your desired hostname also you need to update /etc/hosts with an entry for the new hostname and your droplet’s IP address.

Hope this helps.