Not understanding the need of \# in dns.rdata.from_text()

139 views
Skip to first unread message

Paul Hoffman

unread,
Jan 9, 2014, 8:21:30 PM1/9/14
to dnspyth...@googlegroups.com
Greetings again. I am trying to create an RR that uses EDNS0. I set the RRname to \x40 (the single byte 0b01000000, which is the root domain with a "01" label, the RRtype to OPT, and an RDATA of <some stuff goes here>. When I do so, I get the error "generic rdata does not start with \#". Why is dnspython preventing me from creating this rdata? What (possibly obvious) clue am I missing?

Bob Halley

unread,
Jan 9, 2014, 8:33:13 PM1/9/14
to Paul Hoffman, dnspyth...@googlegroups.com

On Jan 9, 2014, at 17:21, Paul Hoffman <paul.h...@gmail.com> wrote:

> Greetings again. I am trying to create an RR that uses EDNS0. I set the RRname to \x40 (the single byte 0b01000000, which is the root domain with a "01" label, the RRtype to OPT, and an RDATA of <some stuff goes here>. When I do so, I get the error "generic rdata does not start with \#". Why is dnspython preventing me from creating this rdata? What (possibly obvious) clue am I missing?

OPT RRs not being "real" RRs are handled differently. In particular, there is no text format for OPT or other type-specific stuff like there is for say A or MX, so you're getting the "generic rdata" implementation which uses the generic rdata text format, which is \# followed by a length followed by a hex string.

You're better off working with EDNS0 at the message level where there is some structure.

Check out dns.message.Message.use_edns

It takes (self, edns=0, ednsflags=0, payload=1280, request_payload=None, options=None)

Also, dns.edns provides an "Option" object to make options lists out of and to subclass. (If you subclass, you must add your option type-to-class to the dns.edns._type_to_class map.)

Things are done this way because EDNS requires special treatment in rendering, and because OPT isn't a proper RR type in many other ways too.

/Bob


Reply all
Reply to author
Forward
0 new messages