in reply to DNS aliases

A domain might have a "A" tag pointing to an address, so we can go from name to address:
jupiter.sun.csd.unb.ca. A 131.202.3.8

We can do a reverse lookup on an IP address, because IP addresses are also located in the DNS tree:
8.3.202.131.in-addr.arpa. PTR jupiter.sun.csd.unb.ca

Aliases have a "CNAME" tag pointing to a domain:
unix.unb.ca. CNAME jupiter.sun.csd.unb.ca

However, there's no equivalent to PTR for aliases -- there's nothing under jupiter.sun.csd.unb.ca that points back to unix.unb.ca -- so doing a reverse CNAME lookup is impossible.

You need to either get the zone file from the DNS server (which you said you couldn't) or from the file system.

Replies are listed 'Best First'.
Re^2: DNS aliases
by UberGeek (Scribe) on Dec 21, 2004 at 17:43 UTC
    Not quite - when you do a gethostbyaddr, it returns a few different things... from perldoc:

    ($name,$aliases,$addrtype,$length,@addrs) = gethost*

    if I gethostbyname, however, it populates $aliases with the same name you specified in the initial call to gethostbyname...


    No freaking way it compiled on the first try...

      Did you try those commands? They support what I said.

      gethostbyname("unix.unb.ca") (an alias) returns jupiter.sun.csd.unb.ca for name, unix.unb.ca for alias and 131.202.3.8 for address.

      gethostbyname("jupiter.sun.csd.unb.ca") returns jupiter.sun.csd.unb.ca for name, nothing for alias (even though it has unix.unb.ca for alias) and 131.202.3.8 for address.

      gethostbyaddr(inet_aton("131.202.3.8"), AF_INET)) returns jupiter.sun.csd.unb.ca for name, nothing for alias (even though it has unix.unb.ca for alias) and 131.202.3.8 for address.

      DNS simply does not provide the means to specify or query the information needed. You could parse the zone file if you had access to it, but the OP indicated he does not (at least, not via DNS).

      There's also the scenario where domains from different zone files point to the same address:
      cosplay.ca.  A 63.111.28.139
      adaelis.com. A 63.111.28.139
      Unless you had the zone files for every domain out in existance -- and no machine ever does or ever could -- you'd never be sure that you knew all the domains that point to an address. However, this paragraph is probably beyond the scope of the OP's question.