Skip to main content

resolve-hosts

Resolve list of DNS hostnames.

This is a Python module designed to fit the need of a simple app that can query an input list of DNS names and output their resolved IP addresses. It defaults to using the local system resolver for lookups, but can instead use a list of one or more custom DNS resolvers supplied on the command line.

Installation

This is a setuptools package; install using pip:

pip install resolve-hosts

It's recommended to use pipx for easy setup and isolation:

pipx install resolve-hosts

Usage

The module installs a command line tool called resolve-hosts that should be in your PATH. For a usage overview, see the output of resolve-hosts -h.

Feed it a newline-separated list of names as a parameter. To read from standard input, omit the parameter or use - for the input.

A file with a few sample names to resolve is in the tests/ folder.

Example using the local system resolver:

$ resolve-hosts tests/testnames.txt 
www.example.com             93.184.216.34
blocked.test.on.quad9.net   NXDOMAIN
mxs.mail.ru                 94.100.180.31 217.69.139.150
magnolia.ns.cloudflare.com  172.64.34.214 108.162.194.214 162.159.38.214

The above system is clearly configured to use Quad9 resolvers, as the local resolver returned NXDOMAIN for the test FQDN.

Using specified resolvers and debug output enabled:

$ resolve-hosts -s 8.8.4.4 -s 8.8.8.8 -d tests/testnames.txt 
[DEBUG] configured to use resolver(s): ['8.8.4.4', '8.8.8.8']
[DEBUG] effective resolver address(es): ['8.8.4.4', '8.8.8.8']
www.example.com             93.184.216.34
blocked.test.on.quad9.net   127.0.0.1
mxs.mail.ru                 217.69.139.150 94.100.180.31
magnolia.ns.cloudflare.com  172.64.34.214 108.162.194.214 162.159.38.214

JSON output from data on stdin:

$ resolve-hosts -j < tests/testnames.txt 
{
    "data": [
        {
            "www.example.com": [
                "93.184.216.34"
            ]
        },
        {
            "blocked.test.on.quad9.net": [
                "NXDOMAIN"
            ]
        },
        {
            "mxs.mail.ru": [
                "217.69.139.150",
                "94.100.180.31"
            ]
        },
        {
            "magnolia.ns.cloudflare.com": [
                "162.159.38.214",
                "108.162.194.214",
                "172.64.34.214"
            ]
        }
    ]
}

Metadata

Release files for resolve-hosts 0.3.2

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

Source distribution (sdist)

Source distribution for resolve-hosts 0.3.2
File Size Uploaded
resolve_hosts-0.3.2.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for resolve-hosts 0.3.2
File Interpreter ABI Platform
resolve_hosts-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / resolve_hosts-0.3.2.tar.gz

Download URL resolve_hosts-0.3.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
245f68c4eae30c7e86e4ad699019df14bc9f636c6ab59e2b30c0dd8aa4dec46e
BLAKE2b-256 checksum
How to use checksums
eb0846de22540282bd50531c6dca774f2aeb1023856d599f5aecdd9891c67e6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / resolve_hosts-0.3.2-py3-none-any.whl

Download URL resolve_hosts-0.3.2-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05ab34c438a307cb95179414e2608cf733ce4d77bc4c997e7e6d2f397405f239
BLAKE2b-256 checksum
How to use checksums
176d8a6f5a493ec73709d7febf77117615a2fccf526256064c6e780fc0ebe182
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

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