Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sahilsk/3ab82ee4e0e805308be2d83d94da09ec to your computer and use it in GitHub Desktop.
Save sahilsk/3ab82ee4e0e805308be2d83d94da09ec 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
hostname 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