gmishra has asked for the wisdom of the Perl Monks concerning the following question:

I have to write a script that takes a DNS as input.. and outputs all the DNSs with the same IP address. Of course, i am able to get IP address of the DNS. I am able to get the only the primary DNS on that IP address. I need help on how i can retrievs other domain names on the same IP address. Any Clue? waiting.. Garry

Replies are listed 'Best First'.
Re: Get all aliases of a DNS
by arden (Curate) on Feb 26, 2004 at 05:38 UTC
    Sorry, the RFCs for DNS only allow for the reverse lookup of the Primary name for an IP. Unless you have access to the server's records flat database files, you can't lookup anything else. Even though www.perlmonks.org maps to 66.39.54.27 (and 209.197.123.153), 66.39.54.27 maps back to ads.perlmonks.org. Unless I have access to the perlmonks.org zone file, I don't know that it also maps back to www.perlmonks.org. The same holds true for the perlmonks.com and perlmonks.net zone files. Finally, if I own the xyz.info domain, I can assign pm.xyz.info to 66.39.54.27 without needing (technically, not ethically) permission from The Monastery.

    Basically, what I'm saying is that there is no way (unless you want to try every single possible permutation of every top-level domain and do a query to see if it returns your IP#, there is no way to determine every name that will correspond to a specific IP#.

    - - arden.
    p.s. this thread has nothing to do with perl and a bit to do with DNS.

      hey, thanks for the response. I guess, i will work on the flat file that i get by "nslookup ls -t CNAME $mynameserver". Though that is quite a raw method.
        Most domains don't allow downloading the entire zone file for security reasons. If you are using your nameserver and your domain, then it might allow it. In that case, you probably have access to the original file.

        Also, you need to distinguish between names pointing to the name IP address, and aliases pointing to the same name. A records map name to IP address; you can have multiple names with the same IP address. CNAME records map names to other names. There can be multiple CNAME records with the same destination name.

        Finally, this will only find names in the domain you are looking at. It will not search other domains or all the domains in the world. For example, there are a couple of domains that say they are hosted on our nameservers but are not. There is no way to search for these.

Re: Get all aliases of a DNS
by MidLifeXis (Monsignor) on Feb 26, 2004 at 04:39 UTC

    Since I, as the administrator of my own DNS domain, can define any old IP address within my namespace, the only solution to this problem is an exhaustive search. Only the owner of the IP address space can set up the RDNS (well, sort of :), and that, IIRC, is the only way to look up a reverse address (DNS address from IP address).

    --MidLifeXis