Skip to main content

Resolve list of DNS hostnames.

Project description

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"
            ]
        }
    ]
}

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

resolve-hosts-0.2.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resolve_hosts-0.2.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file resolve-hosts-0.2.2.tar.gz.

File metadata

  • Download URL: resolve-hosts-0.2.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for resolve-hosts-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3e983dcea0ac89cbe739012281b0b523d7703ea4eca8e825464f21d5bf0aba9c
MD5 854abddb614d2737487087f6437d111b
BLAKE2b-256 0bf1f1c5768f68ddb55822c0c51ed5b731ea9522f9452c3b8323bcd03a0cd825

See more details on using hashes here.

File details

Details for the file resolve_hosts-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: resolve_hosts-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for resolve_hosts-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7acbb31e00d497be30584ca46832109e8938cb1e60aaa98fb872b1d56c0174c1
MD5 6ff6f6818851595cdf6632de9ed4dd75
BLAKE2b-256 4429d8a0f7679019e624ff73e449847d02137f401f4ab64ece6bcdbba3dc38b5

See more details on using hashes here.

Supported by

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