query

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Command query resolves a single name against a recursive resolver over UDP and prints the response.

It demonstrates the complete client half of the dnsmsg package: building a query with dnsmsg.Message.SetQuestion, advertising an EDNS(0) buffer size, encoding with dnsmsg.Message.Pack, writing the result to a UDP socket as one datagram, decoding the reply with dnsmsg.Unpack, and reading the answer section through a type switch on dnsmsg.RData.

Two details in here are easy to leave out and expensive to leave out. The query ID comes from crypto/rand rather than a counter, and every datagram that arrives is checked against both that ID and the question that was asked before it is accepted. A resolver that skips either check accepts the first forged packet an off-path attacker sends.

Usage:

query [flags] <name>

query example.com
query -type MX -server 9.9.9.9 example.com
query -type HTTPS -dnssec cloudflare.com
query -hex -type CAA google.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL