CentOS 7 / RHEL 7 – AWS ec2 – how to set hostname persistent across reboots

07. February 2016 AWS, RHEL, SysAdmin 0
CentOS 7 / RHEL 7 – AWS ec2 – how to set hostname persistent across reboots

Issue

  • how to set hostname persistent across reboots in CentOS 7 / RHEL 7 on AWS ec2
  • CentOS 7 / RHEL 7 Hostname changes after reboots in aws ec2

Solution

  • Set the hostname with the below command
    hostnamectl set-hostname hostname.yourdomainname.com
  • Now run the below to change the cloud.cfg
    echo "preserve_hostname: true" >> /etc/cloud/cloud.cfg
  • Reboot the server with reboot command
    reboot
    Now the server will be running with the persistent hostname after reboots.

Leave a Reply

Your email address will not be published. Required fields are marked *