I'm having several
ec2 independent instances(staging and production). They do not talk to each other in any way.
Is is safe to modify
/etc/hostname for better clarity of what instance you've logged in?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
Short answer: Yes.
Whenever you need to resolve a hostname to an IP address, you use one of a group of options. This is configurable through
/etc/nsswitch.conf, but the defaults that are probably relevant for you are to check
The only name in
/etc/hosts is usually the local hostname with associated fully qualified domain name (FQDN). If one of your hosts contacts any other host, whether it be on the internet or locally within the EC2 cloud, it checks DNS to find the appropriate name-to-number mapping.
If you change the hostname on a machine, all you can do is change what name it thinks it has. Every other host will still get the same name-to-IP mapping. You can't change Amazon's DNS entries.
This is why if you want a valid name, you'll need to set up a CNAME in a DNS zone you control.
If you don't mind that you'll only see the change on the local host, go ahead and change that hostname. The only reason to make a machine's 'personal' hostname (what it thinks it's called) match its 'real' hostname (what everyone else thinks) is to reduce cases of sysadmin insanity.
The single-hostname thing breaks down somewhat when you get more complex setups, too: since a hostname corresponds to an IP, what do you do when you have load balancing or multihomed servers? In the end the whole concept of a local hostname is mainly for convenience and easy of administration.
P.S. You should probably change the hostname and FQDN through the distro's provided mechanism for doing so, as samarudge's linked question mentions. That'd be different for each distro, but happens to be
/etc/sysconfig/network for Amazon AMI, Red Hat, or CentOS.