dns_lookup
Resolve domain names to IP addresses using Shodan's DNS service. Supports batch resolution of multiple hostnames in a single query.
Instructions
Resolve domain names to IP addresses using Shodan's DNS service. Supports batch resolution of multiple hostnames in a single query. Returns IP addresses mapped to their corresponding hostnames.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostnames | Yes | List of hostnames to resolve. |
Implementation Reference
- src/index.ts:559-592 (handler)Handler for the 'dns_lookup' tool. Parses input arguments using DnsLookupArgsSchema, performs batch DNS resolution via Shodan's /dns/resolve API by joining hostnames, formats the result mapping hostnames to IPs, and returns a structured JSON response.case "dns_lookup": { const parsedDnsArgs = DnsLookupArgsSchema.safeParse(args); if (!parsedDnsArgs.success) { throw new Error("Invalid dns_lookup arguments"); } // Join hostnames with commas for the API request const hostnamesString = parsedDnsArgs.data.hostnames.join(","); const result: DnsResponse = await queryShodan("/dns/resolve", { hostnames: hostnamesString }); // Format the response in a user-friendly way const formattedResult = { "DNS Resolutions": Object.entries(result).map(([hostname, ip]) => ({ "Hostname": hostname, "IP Address": ip })), "Summary": { "Total Lookups": Object.keys(result).length, "Queried Hostnames": parsedDnsArgs.data.hostnames } }; return { content: [ { type: "text", text: JSON.stringify(formattedResult, null, 2) }, ], }; }
- src/index.ts:165-167 (schema)Zod schema defining the input parameters for the dns_lookup tool: an array of strings representing hostnames to resolve.const DnsLookupArgsSchema = z.object({ hostnames: z.array(z.string()).describe("List of hostnames to resolve."), });
- src/index.ts:331-335 (registration)Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema (converted from Zod to JSON schema) for dns_lookup.{ name: "dns_lookup", description: "Resolve domain names to IP addresses using Shodan's DNS service. Supports batch resolution of multiple hostnames in a single query. Returns IP addresses mapped to their corresponding hostnames.", inputSchema: zodToJsonSchema(DnsLookupArgsSchema), },