[CentOS] How to set the hostname alias in DNS server

Thu Apr 7 02:05:12 UTC 2011
Les Mikesell <lesmikesell at gmail.com>

On 4/6/11 8:43 PM, sync wrote:
>
>
> On Thu, Apr 7, 2011 at 9:33 AM, Les Mikesell <lesmikesell at gmail.com
> <mailto:lesmikesell at gmail.com>> wrote:
>
>     On 4/6/11 8:18 PM, sync wrote:
>      > Hi ,all:
>      >
>      >
>      > There has a problem which confused me for a long time . The problem is the
>      > following:
>      >
>      > Would I can set the hostname alias in DNS server?
>      >
>      > That's to say,  for example , if  my hostname is called server,  that it's ip
>      > address is 127.0.0.1
>      > and I want to alias another name called aaa
>
>     First, 127.0.0.1 is a special case that always refers to the same host where the
>     connection originates, so you can't really use that from another machine
>     regardless of how you resolve the name.
>
>      > Gernerally, I can edit the /etc/hosts file to modify it, but the another
>      > computer did not recognise it.
>      > How could I do it ?
>
>     That is up to your DNS server type.  If it is BIND/named you'll have a zone file
>     for each domain it is serving with an 'A' record entry for a name and IP, and
>     you would add CNAME entries for aliases or additional names.
>
>
>
> Like this ?
>
> Add the following line in localdomain zone file :
>
> "
> server IN  A      127.0.0.1
> aaa   IN CNAME  server "
>
> then reload the named service .
>
>
> But when I run this command "ping aaa" , it has no result .
> And it print "Unkown host aaa" message.
>
> By the way , aaa is not the domain name, it maybe the hostname alias.

You probably don't want to use the localdomain zone, or 127.0.0.1 as the 
address, and the right hand side of the CNAME should be a fully-qualified domain 
name, but otherwise you are close.  Are you actually using this DNS server? 
The client side will use whatever servers are listed in your /etc/resolv.conf 
file for lookups and only search the domains specified there for names that 
aren't fully qualified.

-- 
    Les Mikesell
     lesmikesell at gmail.com