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
1 |
hostnamectl set-hostname --static HOSTNAME_HERE |
Example
1 |
hostnamectl set-hostname --static server1.serverok.in |
To disable change of hostname, run
1 |
echo "preserve_hostname: true" > /etc/cloud/cloud.cfg.d/99_hostname.cfg |
Now reboot your server with
1 |
reboot |