Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an existing tool or a cool or interesting way to find all items in DNS zone file, which are "resolving" to given IP? (not using any DNS server at all)

For instance, we might have following not very well organised DNS config: 60 IN A 60 IN A        60 IN CNAME 60 IN CNAME 60 IN CNAME 60 IN A 60 IN A

The tool's answer to the question: should be the set,,,,

UPDATE: to be clear: we HAVE that zone file for the domain available

UPDATE: the following script which i've just kludged does almost exactly what i wanted (expects dns zone file on stdin) (no IPv6 support yet :-P) :

#! /usr/bin/env python

import re
import sys

cols = (0, 4)
type_col = 3
types = ('A', 'CNAME')

if len(sys.argv) != 2:
    sys.exit('query not given (IP or hostname)')

query = sys.argv[1]

rex_not = re.compile(r'^\s*;')

relations = []
found = set([query])

def filter_pairs(l, f):
    for itm in l:
        if itm[1] in f: yield itm

in_pairs = []
for line in sys.stdin:
    if rex_not.match(line): continue
    itms = re.split(r'\s+', line.strip())
        typ = itms[type_col]
        if typ not in types: continue
        a, b = (itms[cols[0]], itms[cols[1]])
    except IndexError: continue
    if a and b: in_pairs.append((a, b))

oldpairs = in_pairs[:]

while True:
    pairs = list(filter_pairs(in_pairs, found))
    for itm in pairs: found.add(itm[0])
    if len(pairs) == len(oldpairs): break
    oldpairs = pairs

found = found.difference(set([query]))

for x in found: print(x)
share|improve this question

closed as not a real question by John Gardeniers, freiheit, Sven, MadHatter, Scott Pack Nov 13 '12 at 18:28

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

I'd say grep "10\.0\.0\.1" zonefile but maybe i misunderstood the question – user130370 Aug 10 '12 at 12:29
Eric DANNIELOU: did you try actually grepping it and comparing with the expexted result ? – mykhal Aug 10 '12 at 12:31
No. I guess there will be some issues. But did I understand the question correctly? I was afraid you have no direct access to zonefile – user130370 Aug 10 '12 at 12:36
Eric DANNIELOU: yes, we have that zone file.. how it could be done with following the condition not using any DNS server at all ? – mykhal Aug 10 '12 at 12:38
What's missing you (except ipv6) in the script you posted? I got the expected result (5 hosts) – user130370 Aug 10 '12 at 13:51

It can't be done unless there's a reverse DNS entry for each one. Sure some people will tell you that it can be done and will even point you to a bunch of web sites that claim to do it but the fact is that it's just not possible.

share|improve this answer
err, in t he meantime, i've made little script, which does it (can't handle wildcards yet) - it's about text processing and relation evaluation.. maybe i should have formulated the question better – mykhal Aug 10 '12 at 12:25
@mykhal, No you haven't. All you've created is a script that for some tests will appear to be successful. That's like the weather office getting it right one day. It doesn't mean they'll get it right every day. – John Gardeniers Aug 10 '12 at 12:31
John Gardeniers: ok, what if i don't want REAL reverse lookup, but to find hostnames, which would resolve to given IP? – mykhal Aug 10 '12 at 12:33
Do you have any idea how many hostnames there are? No. It can't be done. It really is that simple. – John Gardeniers Aug 10 '12 at 12:37
John Gardeniers: this one is only 7 lines long, as you can see. the question is dealing single 1st level domain, with zone file available (i have updated the question, for clarity) – mykhal Aug 10 '12 at 12:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.