<p align="center"<img src="https://github.com/stacksjs/dnsx/blob/main/.github/art/cover.jpg?raw=true" alt="Social Card of this repo"</p
dnsx
A dependency-free & minimal DNS client. For the CLI, JavaScript & TypeScript.
Features
- 🌐 Simple, lightweight DNS client
- 🔎 Query any DNS record type (A, AAAA, MX, TXT, etc.)
- 🔀 Multiple transport protocols (UDP, TCP, TLS, HTTPS)
- 🎨 Colorized output with optional JSON format
- 🤖 CLI and Library Support
- 0️⃣ Zero runtime dependencies
<p align="center"<img src="https://github.com/stacksjs/dnsx/blob/main/.github/art/screenshot.png?raw=true" alt="Screenshot of dnsx"</p
Install
bun install -d @stacksjs/dnsxGet Started
There are two ways of using this DNS client: as a library or as a CLI.
Library
Given the npm package is installed:
import { DnsClient } from '@stacksjs/dnsx'
// Simple query
const client = new DnsClient({
domains: ['example.com'],
type: 'A',
nameserver: '1.1.1.1'
})
const responses = await client.query()
console.log(responses)
const client = new DnsClient({ domains: ['example.com'], type: ['A', 'MX', 'TXT'], nameserver: '1.1.1.1', udp: true, // use UDP transport edns: 'show', // show EDNS records txid: 1234, // set specific transaction ID tweaks: ['aa', 'bufsize=4096'] // protocol tweaks })
const responses = await client.query()
### CLI
Simple queries
dnsx example.com # Query A record dnsx example.com MX # Query MX record dnsx example.com MX @1.1.1.1 # Use specific nameserver dnsx example.com MX @1.1.1.1 -T # Use TCP transport