Python Forum

Full Version: DNS qery library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i recall seeing a library suitable for very specific DNS queries. i can't find it, now. looking in pypi i find tons of stuff for dns. but, i can't find a core library. does anyone know which library i might have seen?

edit:

this would not use a command like "dig". instead, it could be use to implement a replica "dig" command in Python.
(Feb-25-2022, 12:29 AM)Larz60+ Wrote: [ -> ]This one?
possibly.

Ubuntu (apt-get) installs an older version (1.1.2 instead of 1.1.6) and also installs a package named python3-dnspython. after cleaning that up i let pip do its thing and i don't get python3-dnspython. i have no idea. at first it looked like a dependency. i install python3-dnspython and it does not bring in dnsq (python3-dnsq in the Ubuntu world and maybe also Debian. going back to pip's version. then i need to investigate python3-dnspython.

it looks like pip did that because i already have dnspython installed. i have both an Ubuntu version an a PyPI version. so i uninstalled both and installed with pip. i did an upgrade earlier but that did not work. previously i had version 1.1.16 (or 1.16.1) but with a fresh install i get version 2.2.0. upgade i not work

i now wonder if dnspython is the package i saw. while digging around i notice i have a DNS package for Pike. i wonder if that is what i saw. i don't do any Pike development any more, but i leave it all installed for a few scripts i still use. it's just Python and C for me, and not much C.
from linux command line, use nslookup

A few examples:
Output:
larz$ nslookup yahoo.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: yahoo.com Address: 74.6.231.21 Name: yahoo.com Address: 98.137.11.163 Name: yahoo.com Address: 98.137.11.164 Name: yahoo.com Address: 74.6.231.20 Name: yahoo.com Address: 74.6.143.25 Name: yahoo.com Address: 74.6.143.26 Name: yahoo.com Address: 2001:4998:124:1507::f001 Name: yahoo.com Address: 2001:4998:124:1507::f000 Name: yahoo.com Address: 2001:4998:44:3507::8001 Name: yahoo.com Address: 2001:4998:24:120d::1:0 Name: yahoo.com Address: 2001:4998:24:120d::1:1 Name: yahoo.com Address: 2001:4998:44:3507::8000
Output:
larz$ nslookup 98.137.11.163 163.11.137.98.in-addr.arpa name = media-router-fp74.prod.media.vip.gq1.yahoo.com. Authoritative answers can be found from:
Output:
larz$ nslookup 2001:4998:124:1507::f001 1.0.0.f.0.0.0.0.0.0.0.0.0.0.0.0.7.0.5.1.4.2.1.0.8.9.9.4.1.0.0.2.ip6.arpa name = media-router-fp74.prod.media.vip.bf1.yahoo.com. Authoritative answers can be found from:
what i want to use is the tool suitable to build a replica of nslookup, or any other command, such as dig, in Python.

my real goal is a tool to look for domain configuration errors. it needs to send specific queries and get raw answers mostly at the UDP port 53 level.
I write some very complicated code, and am able (in almost every case) to satisfy all of my processing needs with the tools made available by others.
Not big on reinventing the wheel.
i'm not re-inventing. i used those as examples. i am creating something new at the same lower level. in most cases i do use higher level tools. but this is one of those cases where i do need a lower level. i have seen such a tool so i know it exists and is available. i just did not need it then, so i didn't concentrate on it enough to remember the name.
(Feb-26-2022, 10:46 AM)Larz60+ Wrote: [ -> ]I write some very complicated code, and am able (in almost every case) to satisfy all of my processing needs with the tools made available by others.
Not big on reinventing the wheel.
does that mean any such tool is expected to be usable?

one project i want to do is a DNS recursion tool that queries all name servers in parallel. when an NS query has 2 or more answers, query all of them in parallel for the next question. when the recursion has this at 2 or more levels, each expands the number of query threads. this could be done in sequence, but that could be very slow and stall on dead servers. parallel is better as long as you can do a broad timeout over the whole bunch of threads. a library incompatible with threads is unusable.

there are also other projects.