Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EC2 Hostname Keeps Getting Reset [closed]

Tags:

amazon-ec2

I have several amazon ec2 instances running Linux AMIs based on fedora and even though I set the hostname using the command:

hostname example.com

whenever I have to reboot any of them this hostname gets reset to something ip***, how can I make my hostname stick and make it permanent??

like image 229
MikeGA Avatar asked Dec 23 '11 02:12

MikeGA


People also ask

Why did my EC2 instance reboot or restart itself?

The following are the most common reasons: The instance failed one or both of its status checks. The underlying hardware hosting your instance was faulty and Amazon EC2 restarted the instance to move it to new, healthy hardware. Scheduled maintenance occurred on your instance that required a reboot.

What is the hostname of my EC2 instance?

You can see the hostname values for an existing EC2 instance in the Details tab for the EC2 instance: Hostname type: The hostname in IP name or resource name format. Private IP DNS name (IPv4 only): The IP name that will always resolve to the private IPv4 address of the instance.

Can we change hostname of EC2 instance?

How do I change the Amazon Linux Lightsail or EC2 cloud server instance? You can use the hostname command or hostnamectl command to see or set the Amazon Linux EC2 instance's host name. Open the terminal application and type the following commands to set or change hostname or computer name on Amazon Linux EC2 Instance.

Why did auto scaling terminate my instance?

Amazon EC2 Auto Scaling terminates Spot instances when either of the following occurs: Capacity is no longer available. Spot price exceeds the maximum price that you specified for the instances.


1 Answers

Calling hostname doesn't make the change permanent, it's only for the current 'boot' session. To make it permanent, you have to change /etc/sysconfig/network. There's a HOSTNAME line in there which is read by the boot scripts to set the hostname at startup.

like image 111
Marc B Avatar answered Oct 24 '22 10:10

Marc B