Rancher created EC2 instance loses hostname after reboot

I used Rancher to create some new hosts. I had to reboot 1 of the hosts and I noticed that when I ssh’d back into the host, that it’s hostname was now the private dns name “ip-172-31-1-39.ec2.internal”

The OS of the host is CentOS 7 - CentOS Linux 7 x86_64 HVM EBS 1602-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d7e1d2bd.3 (ami-6d1c2007)

CentOS 7 does seem to have some reqs for persisting the hostname, the following gets it set correctly in EC2 -

sudo hostnamectl set-hostname --static “someservername”

Add “preserve_hostname: true” to the file “/etc/cloud/cloud.cfg”


Hey @Phillip_Ulberg, to persist hostnames in AWS instances try following this procedure:


let me know if that helps.

i had tried that previously, and didn’t play well with CentOS 7. Here is what I have found works -

sudo hostnamectl set-hostname --static "someservername"

then add preserve_hostname: true to the file /etc/cloud/cloud.cfg

1 Like

Awesome… good to know. Hopefully others find this useful!