ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
Back to cheatsheets
Privacy

DNS-over-HTTPS Queries

Query DNS records with encrypted DoH lookups and DNSSEC validation.

3 snippets Intermediate dns-lookup
DoHDNSSECCloudflareQuad9encrypted DNS

What you'll learn

  • DoH lookup
  • Multi-resolver with fallback
  • Record types reference

How to use these snippets

  1. Click the Copy button next to any snippet to copy it to your clipboard.
  2. Paste the code into your project, IDE, or terminal.
  3. Replace placeholder values (like example.com or your-secret) with your actual data.
  4. Review the code comments for important security notes and caveats.
  5. Try the interactive related tool to see the concept in action.
Code Snippets

Copy-paste code snippets

3 ready-to-use snippets for dns-over-https queries. Click copy and paste into your project.

DoH lookup
                async function dohLookup(domain, type = 'A') {
  const url = `https://cloudflare-dns.com/dns-query?name=${domain}&type=${type}`;
  const res = await fetch(url, {
    headers: { 'Accept': 'application/dns-json' }
  });
  const json = await res.json();
  return json.Answer || [];
}
              
Multi-resolver with fallback
                const RESOLVERS = [
  'https://cloudflare-dns.com/dns-query',
  'https://dns.quad9.net:5053/dns-query',
  'https://dns.google/resolve',
];

async function dohWithFallback(domain, type = 'A') {
  for (const resolver of RESOLVERS) {
    try {
      const url = `${resolver}?name=${domain}&type=${type}`;
      const res = await fetch(url, {
        headers: { 'Accept': 'application/dns-json' }
      });
      const json = await res.json();
      if (json.Answer) return json.Answer;
    } catch (e) { continue; }
  }
  throw new Error('All resolvers failed');
}
              
Record types reference
                // Common DNS record types:
// A     — IPv4 address
// AAAA  — IPv6 address
// CNAME — Canonical name (alias)
// MX    — Mail exchange
// TXT   — Text (SPF, DKIM, verification)
// NS    — Name server
// SOA   — Start of authority
// CAA   — Certificate Authority Authorization
// SRV   — Service record
// PTR   — Reverse lookup (IP → domain)
// DS    — Delegation signer (DNSSEC)
              
Tool

Try this concept hands-on with the interactive tool.

100% Free · No signup · No cost

Generate something unguessable right now

148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.

Open the toolkit

Part of the Toolly ecosystem · secure.toolly.site