dnspython
dnspython is a comprehensive DNS toolkit for Python, currently at version 2.8.0, supporting Python 3.10 and above. It is actively maintained and follows a regular release cadence.
Warnings
- breaking In dnspython 2.0.0, the 'dns.query' module was refactored, leading to changes in function signatures and behavior. Review the changelog for detailed migration steps.
- gotcha Avoid naming your script 'dns.py' to prevent import conflicts with the dnspython library.
Install
-
pip install dnspython
Imports
- dns.resolver
import dns.resolver
- dns.query
import dns.query
Quickstart
import dns.resolver
# Query for A records of 'example.com'
result = dns.resolver.resolve('example.com', 'A')
for ipval in result:
print('IP', ipval.to_text())