[CentOS] 6.2 How to change hostname for each individual IP

Tue Apr 10 15:32:15 UTC 2012
Blake Hudson <blake at ispn.net>

Lamar Owen wrote the following on 4/9/2012 9:11 AM:
> On Friday, April 06, 2012 09:18:27 AM Jonathan Vomacka wrote:
>> No matter what I do when I connect to the application it read
>> "example.example.org" which is the hostname of the machine rather then
>> the hostname I want it to read on a particular IP. Is this possible to
>> change?
> Well, it probably isn't.  Hostnames should not be confused with FQDN's that map to IP addresses; they are different (even though CentOS will by default grab its hostname from reverse DNS if it gets its main interface's IP address by DHCP (in the case of multiple interfaces, there is a preferred interface that will assign the hostname)).
>
> Hostnames belong to the host OS.  FQDN's belong to their respective IP addresses; and IP addresses belong to their respective interfaces, not to the host.  I know that's splitting hairs, but you're hitting the very corner case that splits this particular hair.  The host itself does not have an IP address.  Even in the case of a non-localhost-addressed loopback, the IP address belongs to the loopback interface, not to the host.
>
> This has been true for a very long time;  I've run multiple alias interfaces since kernel 2.0 days on Red Hat Linux 4.1 (not RHEL, but old RHL), and this has been the behavior for at least that long.
>
> A host can only have one name (this is true for basically any IP host, whether it's a Linux system, a BSD system, a Windows system, or a Cisco router.  Especially on a router with a lot of interfaces (broadband aggregation routers, for instance, can have thousands of interfaces with each one having a unique IP) you don't want the name of the IP associated with the interface to override the hostname.  And the hostname does not have to match what DNS says about the FQDN that belongs to any interface on the system (I have a few of those, too).
>
> Now, I can't quote RFC 'chapter and verse' on this, but I have never seen a system where you could do what you're describing.  (that doesn't mean they don't exist, just that I've not seen one in my limited experience of AT&T Unix SVR2, Xenix V7 and SIII, Apollo DomainOS, and Solaris).

Lamar is correct that the system only allows one hostname. However, many 
server applications can identify themselves with a user configurable 
name instead of the machine hostname - the hostname is often a fallback 
when nothing else has been configured.

For example, Apache allows you to use the name of the virtualhost 
instead of the server hostname. We run postfix on multiple IPs and it 
allows you to specify a hostname per listener; proftpd, cyrus, and 
several others allow the same. Check your application to see if it 
allows a per host or ip configuration. This may involve defining 
multiple instances if you want to listen on different IP addresses and 
have a unique configuration per IP.

--Blake