Skip to main content

DNS querying through libc libresolv.so using ctypes

Project description

Provides access to res_query (resolver(3)) and friends for very basic DNS querying (beyond gethostbyname).

Right now, it only supports MX record lookups.

This is not a replacement for fully featured DNS libraries like dnspython or pycares, but rather a small wrapper to provide a bare minimal lookup capability. Additionally, it serves as an example of how to use -lresolv routines.

Most common usage

from pylresolv import ns_parse, ns_type, res_query

answer = res_query('gmail.com', rr_type=ns_type.ns_t_mx)
ret = ns_parse(answer, handler=ns_type.handle_mx)
print(ret)

Will produce something like:

[(10, 'alt1.gmail-smtp-in.l.google.com'),
 (5, 'gmail-smtp-in.l.google.com'),
 (40, 'alt4.gmail-smtp-in.l.google.com'),
 (30, 'alt3.gmail-smtp-in.l.google.com'),
 (20, 'alt2.gmail-smtp-in.l.google.com')]

2019-03-17: 0.1

  • Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylresolv-0.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page