npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bobfrankston/dnslookup

v1.0.4

Published

Raw DNS query CLI - sends UDP packets directly for debugging DNS servers

Downloads

188

Readme

dnslookup

Raw DNS query CLI and Node.js library that builds and sends UDP packets directly per RFC 1035. No dependencies beyond Node.js. Useful for debugging DNS servers (e.g., Unifi, Pi-hole) by seeing exactly what's happening at the protocol level.

By design this is a thin wrapper over the wire protocol: no caching, no retries, no fallback chains. v4 transport only (the DNS server endpoint must be IPv4), but AAAA records are fully supported.

Install

npm install -g @bobfrankston/dnslookup

Usage

dnslookup <hostname> [hostname2 ...] [options]

Options

| Flag | Description | |------|-------------| | -t <type> | Record type: A, NS, CNAME, SOA, PTR, MX, TXT, AAAA, ANY (default: A) | | -s <server> | DNS server IP (default: system DNS) | | -x | Hex dump of query and response packets | | -v | Verbose: show authority and additional sections | | -detail | Force detailed output (default for single name) | | -table | Force table output (default for multiple names) | | --timeout <ms> | Query timeout in ms (default: 5000) |

Single name (detail mode)

$ dnslookup rmf39.aaz.lt

── DNS Query ──
  Server:   172.20.0.1:53
  Name:     rmf39.aaz.lt
  Type:     A (1)

  RTT:      9.67ms
  Response: 46 bytes

── Response Header ──
  ID:       0x37bf
  Flags:    0x8180 [QR RD RA]
  Status:   NoError
  Counts:   Questions=1 Answers=1 Authority=0 Additional=0

── Answers (1) ──
  rmf39.aaz.lt                   43m28s     A      108.26.220.160

── Result ──
  A   108.26.220.160

Multiple names (table mode)

$ dnslookup rmf39 rmf39.aaz.lt example.com google.com

Name                 Server      Type       RTT       TTL  Status
rmf39                172.20.0.1  A       10.1ms         -  NXDOMAIN
rmf39.aaz.lt         172.20.0.1  A        1.6ms    43m36s  Found       108.26.220.160
example.com          172.20.0.1  A       25.6ms      5m0s  Found       104.18.26.120
                                                                       104.18.27.120
google.com           172.20.0.1  A       20.1ms     3m10s  Found       142.250.217.14

Compare DNS servers

dnslookup myhost -s 172.20.0.1
dnslookup myhost -s 8.8.8.8
dnslookup myhost -s 10.255.255.254   # WSL DNS proxy

Hex dump for packet inspection

dnslookup example.com -x

API

Install as a regular dependency and import:

npm install @bobfrankston/dnslookup
import { lookup, lookupx, runQuery, QType } from "@bobfrankston/dnslookup";

lookup(hostname, options?)Promise<string[]>

Simplest case. Returns an array of address strings (DNS may legitimately return multiple). Throws on transport failure or DNS error (NXDOMAIN, ServerFailure, …).

await lookup("google.com");                              // ["142.250.190.238"]
await lookup("google.com", { type: "AAAA" });            // ["2607:f8b0:..."]
await lookup("example.com", { server: "8.8.8.8", timeout: 2000 });

lookupx(hostname, options?)Promise<LookupExtended>

Extended form: returns the same address list plus the diagnostic detail you'd see in the CLI's detail view (server, RTT, response size, header ID/flags/status, section counts, full record arrays). Throws only on transport failure; DNS errors come back as status (e.g. "NXDOMAIN") with addresses: [].

const r = await lookupx("google.com");
// r.addresses     -> ["142.250.190.238"]
// r.server        -> "172.20.0.1"
// r.type          -> "A"
// r.rtt           -> 17.28
// r.flagNames     -> ["QR", "RD", "RA"]
// r.status        -> "NoError"
// r.counts        -> { questions: 1, answers: 1, authority: 0, additional: 1 }
// r.answers       -> [{ name, type, typeName, ttl, rdata, rdataRaw, ... }]

runQuery(hostname, server, qtype, timeout)Promise<QueryResult>

Lowest-level entry point. Returns the full parsed response (header, answers, authority, additional, RTT, raw query/response packets). Does not throw on DNS errors — failures are reported via the status and error fields. Use QType.A / QType.AAAA / etc. for qtype.

Options (LookupOptions)

| Field | Type | Default | Notes | |---|---|---|---| | server | string | first system resolver (dns.getServers()[0]) | Must be an IPv4 address | | type | "A" \| "AAAA" \| "NS" \| "CNAME" \| "SOA" \| "PTR" \| "MX" \| "TXT" \| "ANY" | "A" | Same set as the -t CLI flag | | timeout | number (ms) | 5000 | |

Exports

lookup, lookupx, runQuery, QType, QTypeName, and the types LookupOptions, LookupExtended, QueryResult, DnsRecord, DnsHeader.

How it works

  • Constructs raw DNS query packets per RFC 1035
  • Sends via UDP to port 53 using node:dgram
  • Parses response including DNS name compression (pointer offsets)
  • Supports record types: A, AAAA, MX, CNAME, NS, SOA, TXT, PTR
  • Zero runtime dependencies

License

MIT