Mike's answer sounds better and will likely work, but if it gives you trouble, you can always use a sledgehammer. :)
Add
/bin/hostname HOSTNAME
To
/etc/rc.local
:)
I would choose a consistent approach across the entire environment. Both solutions work fine and will remain compatible with most applications. There is a difference in manageability, though.
I go with the short name as the HOSTNAME setting, and set the FQDN as the first column in /etc/hosts
for the server's IP, followed by the short name.
I have not encountered many software packages that enforce or display a preference between the two. I find the short name to be cleaner for some applications, specifically logging. Maybe I've been unlucky in seeing internal domains like server.northside.chicago.rizzomanufacturing.com
. Who wants to see that in the logs or a shell prompt?
Sometimes, I'm involved in company acquisitions or restructuring where internal domains and/or subdomains change. I like using the short hostname in these cases because logging, kickstarts, printing, systems monitoring, etc. do not need full reconfiguration to account for the new domain names.
A typical RHEL/CentOS server setup for a server named "rizzo" with internal domain "ifp.com", would look like:
/etc/sysconfig/network:
HOSTNAME=rizzo
...
-
/etc/hosts:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.100.13 rizzo.ifp.com rizzo
-
[root@rizzo ~]# hostname
rizzo
-
/var/log/messages snippet:
Dec 15 10:10:13 rizzo proftpd[19675]: 172.16.100.13 (::ffff:206.15.236.182[::ffff:206.15.236.182]) - Preparing to
chroot to directory '/app/upload/GREEK'
Dec 15 10:10:51 rizzo proftpd[20660]: 172.16.100.13 (::ffff:12.28.170.2[::ffff:12.28.170.2]) - FTP session opened.
Dec 15 10:10:51 rizzo proftpd[20660]: 172.16.100.13 (::ffff:12.28.170.2[::ffff:12.28.170.2]) - Preparing to chroot
to directory '/app/upload/ftp/SRRID'
Best Answer
Changing your hostname should not affect your internal IP nor how your EC2 internal traffic is routed.
I'm not sure what AMI you're using, but ubuntu apparently says that changing the hostname on their public cloud AMIs via the usual linux tools (/bin/hostname, /etc/hostname) is the recommended way and thus should not affect your internal AWS traffic routing.
http://ubuntuforums.org/showthread.php?t=1672335
(the responder's profile in that thread states "Occupation Ubuntu Cloud Community Manager", so it looks to me like this is officially supported.)
There is also a thread here that outlines some of the problems that can happen when changing your hostname such as errors like 'unable to lookup via gethostbyname()':
https://forums.aws.amazon.com/message.jspa?messageID=45806
I've been using the Ubuntu Public AMIs as base AMIs and haven't yet had any problems caused by changing the hostnames locally on the instances via /bin/hostname and writing to /etc/hostname. Good question though. I actually never thought about it before. I just tried it and it worked.