FAQ
Hello,

Has anyone used the pynds resolver libraries? I think I must be missing
something, because I'm just not getting out what I think that I should get.

I'm trying to get a call getIP(domain, nameserver) that will return the
IP of domain, (or at least what that nameserver thinks the IP is).

However, I'm instead getting nothing in the answers, just a bunch of
authority records.

For example:

import DNS
r = DNS.Request(name='yahoo.com', server='151.164.1.1', qtype='A')
a = r.req()
a.show()
; <<>> PDG.py 1.0 <<>> yahoo.com A
;; options: recurs
;; got answer:
;; ->>HEADER<<- opcode 0, status NOERROR, id 0
;; flags: qr rd; Ques: 1, Ans: 0, Auth: 5, Addit: 5
;; QUESTIONS:
;; yahoo.com, type = A, class = IN

;; ANSWERS:

;; AUTHORITY RECORDS:
yahoo.com 172800L NS ns1.yahoo.com
yahoo.com 172800L NS ns2.yahoo.com
yahoo.com 172800L NS ns3.yahoo.com
yahoo.com 172800L NS ns4.yahoo.com
yahoo.com 172800L NS ns5.yahoo.com

;; ADDITIONAL RECORDS:
ns1.yahoo.com 172800L A 66.218.71.63
ns2.yahoo.com 172800L A 209.132.1.28
ns3.yahoo.com 172800L A 217.12.4.104
ns4.yahoo.com 172800L A 63.250.206.138
ns5.yahoo.com 172800L A 64.58.77.85

;; Total query time: 48 msec
;; To SERVER: 151.164.1.1
;; WHEN: Mon Oct 14 11:19:37 2002


Notice that the ANSWERS section is empty. Not even the tests work:
test5 returns an IndexError for trying to access answers[0]['data'].

Any help? Should I try another library? If so, which one?

Thanks,

VanL

Search Discussions

  • Dave Brueck at Oct 14, 2002 at 7:13 pm

    On Mon, 14 Oct 2002, VanL wrote:

    Has anyone used the pynds resolver libraries? I think I must be missing
    something, because I'm just not getting out what I think that I should get.
    I've been using the version that is (was?) in the Demo directory (it has
    since become its own SF project, I think). I'm not using the highest-level
    interface though. Here's what I'm doing:

    m = dnslib.Mpacker()
    m.addHeader(0, 0, dnsopcode.QUERY, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
    m.addQuestion(hostname, dnstype.A, dnsclass.IN)
    sock.send(m.getbuf())

    (where sock is a UDP socket that has been "connected" to the DNS, hostname
    is the host you're looking up)

    To read the response I do:

    msg = dnslib.Munpacker(data)
    id, qr, opcode, aa, tc, rd, ra, z, rcode, qdcount, \
    ancount, nscount, arcount = msg.getHeader()
    ret = []
    minTTL = sys.maxint # We get back TTLs for each IP, but just use
    the minimum of them all

    if rcode == 0: # > 0 = error
    # Skip over questions
    for i in range(qdcount):
    msg.getQuestion()

    # Extract the IP addresses
    for i in range(ancount):
    name, rtype, klass, ttl, rdlength = msg.getRRheader()
    if rtype == dnstype.A and hasattr(msg, 'getAdata'):
    ret.append(msg.getAdata())
    if ttl < minTTL:
    minTTL = ttl
    else:
    # Just skip over it
    msg.getbytes(rdlength)

    The reason I'm not using the higher-level API is simply because of the
    socket framework I'm using - AFAIK that API works fine too so maybe the
    only difference is that I'm calling getAdata? Also, the above code is from
    a DNS cache module so that's why I'm worrying about TTL values.

    HTH,
    Dave
  • Hunj at Oct 15, 2002 at 6:33 am
    Could you tell me where to get the pydns package besides sourceforge?

    Thanks.

    hunj

    "VanL" <vlindberg at verio.net> wrote in message
    news:mailman.1034616412.13524.python-list at python.org...
    Hello,

    Has anyone used the pynds resolver libraries? I think I must be missing
    something, because I'm just not getting out what I think that I should get.
    I'm trying to get a call getIP(domain, nameserver) that will return the
    IP of domain, (or at least what that nameserver thinks the IP is).

    However, I'm instead getting nothing in the answers, just a bunch of
    authority records.

    For example:

    import DNS
    r = DNS.Request(name='yahoo.com', server='151.164.1.1', qtype='A')
    a = r.req()
    a.show()
    ; <<>> PDG.py 1.0 <<>> yahoo.com A
    ;; options: recurs
    ;; got answer:
    ;; ->>HEADER<<- opcode 0, status NOERROR, id 0
    ;; flags: qr rd; Ques: 1, Ans: 0, Auth: 5, Addit: 5
    ;; QUESTIONS:
    ;; yahoo.com, type = A, class = IN

    ;; ANSWERS:

    ;; AUTHORITY RECORDS:
    yahoo.com 172800L NS ns1.yahoo.com
    yahoo.com 172800L NS ns2.yahoo.com
    yahoo.com 172800L NS ns3.yahoo.com
    yahoo.com 172800L NS ns4.yahoo.com
    yahoo.com 172800L NS ns5.yahoo.com

    ;; ADDITIONAL RECORDS:
    ns1.yahoo.com 172800L A 66.218.71.63
    ns2.yahoo.com 172800L A 209.132.1.28
    ns3.yahoo.com 172800L A 217.12.4.104
    ns4.yahoo.com 172800L A 63.250.206.138
    ns5.yahoo.com 172800L A 64.58.77.85

    ;; Total query time: 48 msec
    ;; To SERVER: 151.164.1.1
    ;; WHEN: Mon Oct 14 11:19:37 2002


    Notice that the ANSWERS section is empty. Not even the tests work:
    test5 returns an IndexError for trying to access answers[0]['data'].

    Any help? Should I try another library? If so, which one?

    Thanks,

    VanL
  • Anthony Baxter at Oct 15, 2002 at 2:37 pm

    "hunj" wrote
    Could you tell me where to get the pydns package besides sourceforge?
    Don't know that it's available other than on SF. Why is this a problem?

    --
    Anthony Baxter <anthony at interlink.com.au>
    It's never too late to have a happy childhood.
  • Anthony Baxter at Oct 15, 2002 at 6:43 am

    VanL wrote
    Hello,

    Has anyone used the pynds resolver libraries? I think I must be missing
    something, because I'm just not getting out what I think that I should get.

    I'm trying to get a call getIP(domain, nameserver) that will return the
    IP of domain, (or at least what that nameserver thinks the IP is).

    However, I'm instead getting nothing in the answers, just a bunch of
    authority records.
    This means that the nameserver you asked isn't authoritative for the
    answer, and it's not willing to do the lookup for you. It's saying "I
    don't know, but these people do".



    --
    Anthony Baxter <anthony at interlink.com.au>
    It's never too late to have a happy childhood.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedOct 14, '02 at 5:32p
activeOct 15, '02 at 2:37p
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase