Skip to main content
4 of 5
edited title
hellcode
  • 772
  • 2
  • 8
  • 17

Avoid overwriting of hostname by transient hostname at reboot

My server is CentOS 7.1. After reboot the hostname is overwritten by the transient hostname (mail) and I can't find a way to avoid that. Maybe AutoDNS and the MX record mail causes that?

  • /etc/hostname contains the correct value
  • hostnamectl --transient set-hostname my.desired.name is working but only until next reboot

So, after reboot:

  • hostnamectl status shows the correct static hostname but the wrong transient hostname (mail).
  • hostname -s or hostname -f shows the wrong hostname.

The file /etc/sysconfig/network is overwritten “by anaconda” and has the line HOSTNAME="mail". I tried to edit this file to configure the correct name but it's overwritten after reboot.

How can I prevent the transient hostname being set to mail after restarting?


EDIT:
I already tried to add DHCP_HOSTNAME="my.desired.name" to my /etc/sysconfig/network-scripts/ifcfg-e..... but with no success (line was removed after reboot) and I tried to add execution of hostnamectl set-hostname "" --transient (which will set the transient to the value of static hostname) at reboot which failed either with activated /etc/rc.local and also as a service with chkconfig on (with # chkconfig: - 11 91 so that it should run after all other services).

Any further suggestions are welcome.

hellcode
  • 772
  • 2
  • 8
  • 17