DNS Command

The buddy dns command queries DNS records for domains, providing a developer-friendly interface for DNS debugging and verification.

Basic Usage

# Query DNS for your app domain
buddy dns

# Query specific domain
buddy dns example.com

Command Syntax

buddy dns [domain] [options]

Arguments

ArgumentDescription
domainDomain to query (defaults to APP_URL)

Options

OptionDescription
-q, --query <query>Host name or IP address to query
-t, --type <type>DNS record type (A, MX, NS, CNAME, etc.)
-n, --nameserver <nameserver>Nameserver to query
--class <class>Network class (IN, CH, HS)
-U, --udpUse DNS over UDP
-T, --tcpUse DNS over TCP
-S, --tlsUse DNS-over-TLS
-H, --httpsUse DNS-over-HTTPS
-1, --shortShort mode - display only first result
-J, --jsonDisplay output as JSON
-p, --prettyPretty-print JSON output
--verboseEnable verbose output

Record Types

Query specific DNS record types:

TypeDescription
AIPv4 address
AAAAIPv6 address
CNAMECanonical name (alias)
MXMail exchange server
NSNameserver
TXTText records
SOAStart of authority
SRVService record
CAACertificate authority authorization
ANYAll records (default)

Examples

Query All Records

buddy dns example.com

Query A Records

buddy dns example.com --type A

Query MX Records

buddy dns example.com --type MX

Output:

MX example.com.  300  IN  MX  10 mail.example.com.
MX example.com.  300  IN  MX  20 mail2.example.com.

Query NS Records

buddy dns example.com --type NS

Query TXT Records

buddy dns example.com --type TXT

Short Output

buddy dns example.com --type A --short

Output:

93.184.216.34

JSON Output

buddy dns example.com --type A --json

Use Specific Nameserver

buddy dns example.com --nameserver 8.8.8.8

DNS over HTTPS

buddy dns example.com --https

DNS over TLS

buddy dns example.com --tls

Use Cases

Verify Domain Configuration

Before deployment:

# Check A record points to correct IP
buddy dns myapp.com --type A

# Check CNAME for www
buddy dns www.myapp.com --type CNAME

# Verify MX records for email
buddy dns myapp.com --type MX

Debug DNS Propagation

Check if DNS changes have propagated:

# Check with Google DNS
buddy dns myapp.com --type A --nameserver 8.8.8.8

# Check with Cloudflare DNS
buddy dns myapp.com --type A --nameserver 1.1.1.1

# Check with authoritative nameserver
buddy dns myapp.com --type NS
buddy dns myapp.com --type A --nameserver ns1.example.com

Verify SSL/TLS Setup

Check CAA records for SSL certificates:

buddy dns myapp.com --type CAA

Email Configuration

Verify email DNS records:

# MX records
buddy dns myapp.com --type MX

# SPF record
buddy dns myapp.com --type TXT

# DKIM record
buddy dns selector._domainkey.myapp.com --type TXT

# DMARC record
buddy dns _dmarc.myapp.com --type TXT

Subdomain Configuration

# Check subdomain
buddy dns api.myapp.com --type A

# Check wildcard
buddy dns *.myapp.com --type A

DNS Record Verification

CloudFront Distribution

# Should return CloudFront CNAME
buddy dns myapp.com --type CNAME

AWS Load Balancer

# Should return ALB DNS name
buddy dns api.myapp.com --type CNAME

Route 53 Alias

# Check alias target
buddy dns myapp.com --type A

Troubleshooting

No Records Found

Error: No records found

Solutions:

  1. Verify the domain name is correct
  2. Check if the record type exists
  3. Try a different nameserver

Timeout

Error: Query timed out

Solutions:

  1. Try a different nameserver: --nameserver 8.8.8.8
  2. Use TCP: --tcp
  3. Check network connectivity

NXDOMAIN

NXDOMAIN (domain does not exist)

Solutions:

  1. Verify domain spelling
  2. Check if domain is registered
  3. Verify DNS configuration at registrar

Inconsistent Results

Different results from different nameservers indicate propagation in progress:

# Compare results
buddy dns myapp.com --nameserver 8.8.8.8
buddy dns myapp.com --nameserver 1.1.1.1

Wait for DNS propagation (typically 1-48 hours).

DNS Best Practices

Before Deployment

  1. Verify current DNS configuration
  2. Plan changes carefully
  3. Note existing TTL values

During Changes

  1. Lower TTL before making changes
  2. Make changes
  3. Verify propagation

After Deployment

  1. Verify all records are correct
  2. Restore normal TTL values
  3. Monitor for issues

Common DNS Configurations

Static Website

A     @     93.184.216.34
CNAME www   example.com.

API Endpoint

CNAME api   api.example.cloudfront.net.

Email

MX    @     10 mail.example.com.
TXT   @     "v=spf1 include:_spf.example.com ~all"