Friday, May 15, 2015

CentOS 7 Hostname Resetting on Reboot - SOLVED

No comments:


Setting the hostname was working without problems in CentOS 7 (including latest updates), but the hostname would revent back to the old hostname on every reboot. Nothing I read about worked, and I see lots of other people with the same problems (although RackSpace could not reproduce the problem on a newly spun up CentOS 7).


Assumes you're running as root. Otherwise, sudo the commands
  • Backup /etc/hosts, /etc/sysconfig/network, /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/cloud/cloud.cfg
  • execute "hostnamectl set-hostname"
  • execute "hostnamectl set-hostname --static"
  • Change old hostname to in /etc/hosts
  • In /etc/sysconfig/network, add
  • In /etc/sysconfig/network-scripts/ifcfg-eth0, add
  • in /etc/cloud/cloud.cfg, set
  • Reboot
  • hostname and hostname -f should now correctly give