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

My question revolves around querying a DNS Server. A zone file of DNS looks like

omega A 164.100.9.207
tempweb1 CNAME omega
tempweb2 CNAME omega
. . . etc.. i am in the web hosting dept. now, what i had to do is.. in case.. i give a site name in the ".nic.in" domain.. say "tempweb3".. i should get all the URLS with the same IP Address.. omega, tempweb4, tempweb5.. tempweb10.. i used "gethostbyaddr"..and all.. thats giving me the name of the primary URL of tempweb3 only.. not all.. i made another prog.. but that is giving me the different names.. of the same site.. eg .. mail.yahoo.com and login.yahoo.com .. both give the same page.. i need that..plus i need the names of URLs that r not referring to the same site.. you see.. like indiannavy.nic.in, indianarmy.nic.in have same IP address.. but refer to diff places.. I hope I am able to put across my point. I have tried snippets, Net::DNS::RR, NET::DNS::Resolver... no luck..
Thanks..
Yogi

Replies are listed 'Best First'.
Re: Reverse Recursive DNS Query
by gmishra (Sexton) on Feb 27, 2004 at 06:29 UTC
    had a similar doubt sometime back, and got some ideas from friends here. if you are working on only your name server, and you have the rights, then you can carry out an extensive search OR though this aint a very good approach, but run "nslookup ls -d nic.in " as a system command, direct the input to a text file and work on that file.
Re: Reverse Recursive DNS Query
by iburrell (Chaplain) on Feb 27, 2004 at 19:39 UTC
    First, there is no way for DNS to lookup all hostnames that point to an IP address. Or, all the aliases pointing to a canonical name. It can lookup the PTR records for an IP address. Usually, this is a single name, the primary name for a host. PTR records can not use aliases.

    If you have access to the complete zone files for the domains you care about, then you can search the zone files. There are some modules for parsing zone files. I find that grep works pretty well.

    Third, you need to distinguish between URLs, hosts, and web sites. URLs contain host names. You can make http URLs from hostnames if you assume that they all are used for web sites.

    Fourth, there is no way to know if two hostnames on the same IP address are the same web site without knowing the web server configuration. The server could be using IP addresses, names, or both to do virtual hosting. The same web site could be hosted on multiple IP addresses.