Problem
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).
Solution
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 yourdomain.com"
- execute "hostnamectl set-hostname --static yourdomain.com"
- Change old hostname to yourdomain.com in /etc/hosts
- In /etc/sysconfig/network, add
HOSTNAME=yourdomain.com - In /etc/sysconfig/network-scripts/ifcfg-eth0, add
HOSTNAME=yourdomain.com
DHCP_HOSTNAME=yourdomain.com - in /etc/cloud/cloud.cfg, set
preserve_hostname=true - Reboot
- hostname and hostname -f should now correctly give yourdomain.com
No comments:
Post a Comment