On OpenVZ VPS running Centos 7 with cPanel installed one of my friends had problem, he couldn’t keep his FQDN (Fully Qualified Domain Name) as his hostname.
Instead, after every reboot his hostname: scorpio.hisdomain.com changed just to scorpio.
This made him a lot of trouble because if hostname is not FQDN many mails go to spam.
To fix this I open crontab
added following line:
@reboot /usr/local/cpanel/bin/set_hostname scorpio.hisdomain.com
Now on every boot his hostname is just the way it is supposed to be.
If you are not running cPanel and have the same problem you can add this instead:
@reboot hostnamectl set-hostname scorpio.hisdomain.com
Another solution, and my least favorite is to execute this after changing hostname:
chattr +i /etc/hosts && chattr +i /etc/sysconfig/network
As far I figured it out this issue is probably related to CentOS 7 and/or CPanel.