1

Let us say that I want to count the number of hosts that match a simple pattern. For example:

host1.example.com host2.example.com ... host42.example.com

where I don't know ahead of time that there are 42 of these. What I would like to do is something like:

answers = dns.resolver.query('host*.example.com', 'A')

and then be able to get the length of answers for the count or iterate over answers for the actual hostnames.

Thanks,

Glenn

coyot
  • 418
  • 1
  • 3
  • 12
  • Any library to enable DNS lookups is unlikely to implement such a feature, since this could easily result in a massive amount of DNS queries, which are often limited by registrars / WHOIS servers. You need to implement this yourself by creating a list of hostnames and looping over them. – Lukas Graf May 21 '14 at 19:24
  • 1
    Or in other words: DNS does not support or allow any sort of wildcard queries. Without knowing the exact hostname to query for in advance, there's no way of discovering records, short of a zone transfer. – Lukas Graf May 21 '14 at 19:31
  • Effectively, that's what I wound up doing: dumping the xfr into a local file or a dict and greping/iterating over that. – coyot May 22 '14 at 14:09
  • 1
    Oh, you're allowed to do zone transfers? Yeah, then that's probably the way to go. – Lukas Graf May 22 '14 at 14:11

0 Answers0