Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active May 20, 2020 18:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save diegopacheco/56a0fd87626406337caea0ff15f49850 to your computer and use it in GitHub Desktop.
Save diegopacheco/56a0fd87626406337caea0ff15f49850 to your computer and use it in GitHub Desktop.
How to change Hostname on Amazon Linux - EC2 AWS?

Summary

  1. Change file /etc/sysconfig/network
  2. Change file /etc/hostname
  3. Chnage file /etc/hosts
sudo vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=MY_HOSTNAME_BOX_GOES_HERE
NOZEROCONF=yes
NETWORKING_IPV6=no
IPV6INIT=no
IPV6_ROUTER=no
IPV6_AUTOCONF=no
IPV6FORWARDING=no
IPV6TO4INIT=no
IPV6_CONTROL_RADVD=no
vim /etc/hostname
MY_HOSTNAME_BOX_GOES_HERE
sudo vim /etc/hosts
127.0.0.1   localhost localhost.localdomain MY_HOSTNAME_BOX_GOES_HERE
sudo reboot
# ssh to the box
hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment