Using pyunbound with chaos

Hi

The command `dig +short @::1 version.bind. chaos txt` outputs "9.6.1". The following python script however outputs "None":-

import unbound
ctx = unbound.ub_ctx()
ctx.set_fwd("::1")
status, result = ctx.resolve("version.bind", unbound.RR_TYPE_TXT, unbound.RR_CLASS_CH)
print result.rawdata

I am using Unbound 1.3.0 on GNU/Linux with Python 2.5.2.

Regards,

Chris

Do you run bind9 on same machine? 9.6.1 is bind9 version...

Ondrej.

Just to clarify, dig gives the output I expect, wheras pyunbound does not return any result whatsoever.

Hi Chris,

if you print result.rcode you can see it has rcode=5 (REFUSED).
This is because your unbound resolver does not have any means to contact
DNS servers in the chaos class. The forward config you set with set_fwd
is for class IN.

Best regards,
   Wouter

Chris Hills wrote:

Wouter

My problem is that I wish to query several servers directly using a non-recursive query. Doing a recursive query would only return the value of "version.bind" (or "version.server") on the resolver.

Regards,

Chris

Hi Chris,

But if you set_fwd the forwarder is sent a recursive query.

If you want to do nonrecursive queries you should set a stub-zone for
that domain.

If you want to send class CH queries there you need to set it for class
CH. However, the config file statements all default to class IN.
Except trustanchor statements and root-hints file, where a DNS file is
read in with class declarations inside.

Chris Hills wrote:

My problem is that I wish to query several servers directly using a
non-recursive query. Doing a recursive query would only return the value
of "version.bind" (or "version.server") on the resolver.

Best regards,
   Wouter

Wouter

I am using the unbound library, but not the server.

I think you misunderstand my objective.

Whilst the normal operation of DNS is to discover a record recursively, there are some special records that are not part of the normal hierarchy and exist uniquely on each DNS server - for example, version.bind., version.server., hostname.bind. and id.server. (all chaos txt). Basically, I am trying to find the python code using pyunbound that does the equivalent the following command:-

dig @[dns-server] version.server. chaos txt

This will return the version of the software that is running on the dns server.

Regards,

Chris

Hi Chris,

Chris Hills wrote:

Wouter

I am using the unbound library, but not the server.

right

I think you misunderstand my objective.

Tell me more :slight_smile:

Whilst the normal operation of DNS is to discover a record recursively,
there are some special records that are not part of the normal hierarchy
and exist uniquely on each DNS server - for example, version.bind.,
version.server., hostname.bind. and id.server. (all chaos txt).
Basically, I am trying to find the python code using pyunbound that does
the equivalent the following command:-

dig @[dns-server] version.server. chaos txt

Unbound can do this sort of thing, as a server with root hints for class
chaos. However, the config syntax and libunbound functions all have a
default of class IN, and there is no way that I see to tell libunbound
where to send queries for class CHAOS.

This will return the version of the software that is running on the dns
server.

Or, well, whatever the operator configured, see the unbound options
'version' and 'hide-version'.

Perhaps you want this piece of python? :
  (cin, cout) = os.popen2("dig @" + dnsserver + " version.bind chaos txt")
  result = cout.readlines()
  cin.close()
  cout.close()
  print result

Best regards,
   Wouter

Or, well, whatever the operator configured, see the unbound options

> 'version' and 'hide-version'.

Indeed, I thought that went without saying.

> Perhaps you want this piece of python? :
> (cin, cout) = os.popen2("dig @" + dnsserver + " version.bind chaos txt")
> result = cout.readlines()
> cin.close()
> cout.close()
> print result

I specifically wanted to use a library for this because spawning dig is inefficient, which makes a big difference when you are looking up a few million records :slight_smile: Also, dig has the nasty habit of stalling when it gets stuck trying to locate the dns name. Although you can specify +tries=1 and +timeout=1, it still blocks whilst resolving the A/AAAA address of the target dns name (for example, if the target is ns1.something.example.com., and the two dns servers for something.example.com. are unavailable, it will hang for a lot longer than 2 seconds).

I have looked at several libraries for this, and so far none have met all my needs (multiple target servers, IPv6, chaos and asynchronous), and from your reply I can only infer that Unbound will not be suitable either :frowning: Back to the drawing board! Thanks for your replies.

Regards,

Chris

Chris,

you may try LDNS python bindings http://www.fit.vutbr.cz/~slany/nic-vip/pyldns/

These binding should give you more flexibility… (I guess)

It’s not integrated with LDNS yet, I have to poke Jelte bit more :slight_smile:

Ondrej

I specifically wanted to use a library for this because spawning dig is inefficient, which makes a big difference when you are looking up a few million records :slight_smile:

Why do you need to query all the nameservers on the internet for their version? :slight_smile:
Doesn't Caida.org already provide that ?

I have looked at several libraries for this, and so far none have met all my needs (multiple target servers, IPv6, chaos and asynchronous), and from your reply I can only infer that Unbound will not be suitable either :frowning: Back to the drawing board! Thanks for your replies.

What about python-dns? http://www.dnspython.org/

If your python code uses threads, do you really need an async interface?

Paul

a message of 23 lines which said:

What about python-dns? http://www.dnspython.org/

If your python code uses threads, do you really need an async interface?

I agree on both points and this is what we use for DNSdelve
<http://www.dnsdelve.net/&gt;\. And parameter rdclass seems to allow
Python-DNS to query other classes than IN.