reverse_dns_lookup
Find hostnames associated with IP addresses using reverse DNS lookups. Supports batch queries for multiple IPs and returns all known hostnames or indicates when none are found.
Instructions
Perform reverse DNS lookups to find hostnames associated with IP addresses. Supports batch lookups of multiple IP addresses in a single query. Returns all known hostnames for each IP address, with clear indication when no hostnames are found.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ips | Yes | List of IP addresses to perform reverse DNS lookup on. |
Implementation Reference
- src/index.ts:746-780 (handler)The handler function for the 'reverse_dns_lookup' tool within the switch statement in CallToolRequestSchema handler. It validates input using the schema, calls the Shodan reverse DNS API, formats the response mapping IPs to hostnames, and returns a structured text content.case "reverse_dns_lookup": { const parsedArgs = ReverseDnsLookupArgsSchema.safeParse(args); if (!parsedArgs.success) { throw new Error("Invalid reverse_dns_lookup arguments"); } // Join IPs with commas for the API request const ipsString = parsedArgs.data.ips.join(","); const result: ReverseDnsResponse = await queryShodan("/dns/reverse", { ips: ipsString }); // Format the response in a user-friendly way const formattedResult = { "Reverse DNS Resolutions": Object.entries(result).map(([ip, hostnames]) => ({ "IP Address": ip, "Hostnames": hostnames.length > 0 ? hostnames : ["No hostnames found"] })), "Summary": { "Total IPs Queried": parsedArgs.data.ips.length, "IPs with Results": Object.keys(result).length, "Queried IP Addresses": parsedArgs.data.ips } }; return { content: [ { type: "text", text: JSON.stringify(formattedResult, null, 2) }, ], }; }
- src/index.ts:169-171 (schema)Zod schema defining the input for reverse_dns_lookup: an array of IP address strings.const ReverseDnsLookupArgsSchema = z.object({ ips: z.array(z.string()).describe("List of IP addresses to perform reverse DNS lookup on."), });
- src/index.ts:346-350 (registration)Tool registration in the ListToolsRequestSchema handler, providing name, description, and JSON schema derived from Zod schema.{ name: "reverse_dns_lookup", description: "Perform reverse DNS lookups to find hostnames associated with IP addresses. Supports batch lookups of multiple IP addresses in a single query. Returns all known hostnames for each IP address, with clear indication when no hostnames are found.", inputSchema: zodToJsonSchema(ReverseDnsLookupArgsSchema), },