Skip to main content

Python3 - DNS Resolver

This is a simple script to resolve DNS A/AAAA records.

It only uses builtin modules.

Install

python3 -m pip install python3-resolver

See: PyPI

Usage

Shell

If ran from the shell - use the following parameters:

  • -n/--hostname => The hostname/DNS-record to resolve
  • -p/--protocol => IP-Protocol to return (optional; one of '4/6/46')
python3 dns_resolver.py -h
> usage: DNS Resolver [-h] -n HOSTNAME [-p {4,6,46}]
> 
> Script to resolve A/AAAA DNS records
> 
> options:
>   -h, --help            show this help message and exit
>   -n HOSTNAME, --hostname HOSTNAME
>                         The hostname/DNS-record to resolve
>   -p {4,6,46}, --protocol {4,6,46}
>                         IP-Protocol to return

python3 dns_resolver.py -n superstes.eu
> ['89.43.33.99', '2a05:8280:f:42ea::3']

python3 dns_resolver.py -n superstes.eu -p 4
> ['89.43.33.99']

python3 dns_resolver.py -n unsetdomain.com
> []

Programmatically

You can import the resolver from other python modules/scripts.

Installed via PIP

from dns_resolver import resolve, resolve_ipv4, resolve_ipv6

resolve('superstes.eu')
# list(['89.43.33.99', '2a05:8280:f:42ea::3'])

resolve_ipv4('superstes.eu')
# list(['89.43.33.99'])

resolve_ipv6('superstes.eu')
# list(['2a05:8280:f:42ea::3'])

Copied

Per example if the scripts are saved in the same directory.

ls .
> dns_resolver.py
> program.py
from dns_resolver import resolve, resolve_ipv4, resolve_ipv6

resolve('superstes.eu')
# list(['89.43.33.99', '2a05:8280:f:42ea::3'])

resolve_ipv4('superstes.eu')
# list(['89.43.33.99'])

resolve_ipv6('superstes.eu')
# list(['2a05:8280:f:42ea::3'])

Release files for python3-resolver 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python3-resolver 1.0.3
File Size Uploaded
python3-resolver-1.0.3.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python3-resolver 1.0.3
File Interpreter ABI Platform
python3_resolver-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size:28.6 kB

Release files / python3-resolver-1.0.3.tar.gz

Download URL python3-resolver-1.0.3.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
866da8966b23b5ec34630febb3b9407595ae9172fc7236cdd1ad255a544f096e
BLAKE2b-256 checksum
How to use checksums
abd4d33f2c417743981abf9471757a9d7cdc68b6d2e4a8b6e74252c60339c07b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / python3_resolver-1.0.3-py3-none-any.whl

Download URL python3_resolver-1.0.3-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
613f1db80f4d41535aac59ba15f25ae6a195e98c9c4be6db27ee0582abb2a064
BLAKE2b-256 checksum
How to use checksums
4e6ebf8e32e360e77c6646437c33fa371a724b527e419e035a29f07f65329701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

1 release file

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page