Set Permanant hostname on AWS EC2 CentOS 7 server

On AWS EC2 when you boot, hostname set something like ip-172-31-41-172.eu-central-1.compute.internal

To chaneg this, run

hostnamectl set-hostname --static HOSTNAME_HERE

Example

hostnamectl set-hostname --static server1.serverok.in

To disable change of hostname, run

echo "preserve_hostname: true" > /etc/cloud/cloud.cfg.d/99_hostname.cfg

Now reboot your server with

reboot

Back to hostname

Need help with Linux Server or WordPress? We can help!

Leave a Reply

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