Python DNS Client Library
Python client library for sending DNS queries.
- null-dependency
- threadsafe
- type hints
- contains adapter for requests
Install:
# from pypi.org
pip install dns-client
# latest commit
pip install git+https://github.com/s3rgeym/python-dns-client.git
Examples:
In [1]: from dns_client import DNSClient, RecordType
In [2]: c = DNSClient('1.1.1.1')
In [3]: c.query('ya.ru', RecordType.AAAA)
Out[3]: [Record(name='ya.ru', qtype=<RecordType.AAAA: 28>, qclass=<RecordClass.IN: 1>, ttl=76, value='2a02:6b8::2:242')]
In [4]: c.query('ya.ru', RecordType.MX)
Out[4]: [Record(name='ya.ru', qtype=<RecordType.MX: 15>, qclass=<RecordClass.IN: 1>, ttl=2242, value=(10, 'mx.yandex.ru'))]
In [5]: c.get_query_response('ya.ru')
Out[5]: Packet(header=Header(id=47527, response=True, opcode=<OpCode.QUERY: 0>, authoritative=False, truncated=False, recursion_desired=True, recursion_available=True, reserved=False, authentic_data=False, check_disabled=False, rcode=<ResponseCode.NOERROR: 0>, num_questions=1, num_records=2, num_authorities=0, num_additionals=0), questions=[Question(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>)], records=[Record(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>, ttl=266, value='77.88.55.242'), Record(name='ya.ru', qtype=<RecordType.A: 1>, qclass=<RecordClass.IN: 1>, ttl=266, value='5.255.255.242')])
In [6]: c.get_all_records('ya.ru')
Out[6]:
[('A', '5.255.255.242'),
('A', '77.88.55.242'),
('AAAA', '2a02:6b8::2:242'),
('MX', (10, 'mx.yandex.ru')),
('NS', 'ns1.yandex.ru'),
('NS', 'ns2.yandex.ru'),
('TXT',
'_globalsign-domain-verification=eLi0_-xATuNmRfuTIX8VQIvgfyi7Od7Hph4V0yNisF'),
('TXT',
'_globalsign-domain-verification=xUUDG4u7Zo56EmmFewz7Y4UK3MfAU7QSjAgBsy0w6q'),
('TXT',
'google-site-verification=SVTEeUiCU4KV-5qGw4o4JPok7mfsP8NtQTIdN6tt6Nw'),
('TXT', 'v=spf1 redirect=_spf.yandex.ru'),
('TXT',
'_globalsign-domain-verification=dHoe580bPQ-lfi_vh-BEIwB4NAtUwURIzrzsivByVL'),
('TXT', 'e1c8e4dd3d13fad0dd9e8ed54a1813ececd3d5412fb16c4ed2c0612332950fe')]
You can use dns-client with requests:
from dns_client.adapters.requests import DNSClientSession
s = DNSClientSession('1.1.1.1')
s.get('https://google.com')
CLI Usage:
$ python -m dns_client ya.ru -t ns -H 127.0.0.1
Response Flags = 0x8180
1... .... .... .... = Response (True)
.000 0... .... .... = Opcode (<OpCode.QUERY: 0>)
.... .0.. .... .... = Authoritative (False)
.... ..0. .... .... = Truncated (False)
.... ...1 .... .... = Recursion Desired (True)
.... .... 1... .... = Recursion Available (True)
.... .... .0.. .... = Reserved (False)
.... .... ..0. .... = Authentic Data (False)
.... .... ...0 .... = Check Disabled (False)
.... .... .... 0000 = Rcode (<ResponseCode.NOERROR: 0>)
Number of Records: 2
ns2.yandex.ru
ns1.yandex.ru
Metadata
Release files for dns-client 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dns-client-0.1.9.tar.gz | 13.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dns_client-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.8 kB
Release files / dns-client-0.1.9.tar.gz
| Download URL | dns-client-0.1.9.tar.gz |
|---|---|
| Size | 13.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
782e8cd83de4b118a4f47ff4fdb6231e79ba97f57e2d71e25842fc22b374b252
|
|
BLAKE2b-256 checksum How to use checksums |
d966d59e6ec7bffb335fa607cdb0ed2a575bf609f920389bf1033e3ff572f477
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / dns_client-0.1.9-py3-none-any.whl
| Download URL | dns_client-0.1.9-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f15b20b5c642819c089c9db41084a6b8d365989110bca4c09e2d1a3fe61fd1ef
|
|
BLAKE2b-256 checksum How to use checksums |
cd60383c458361f12796d72c76649090071de83b8e9bb31671248e0b3f5f845f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for dns-client 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.