reverse_dns_lookup
Find hostnames associated with IP addresses using reverse DNS lookup. Supports batch processing of multiple IPs in a single query and returns all known hostnames for each address.
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 switch case handler for the 'reverse_dns_lookup' tool. Parses input arguments, calls Shodan /dns/reverse API with comma-joined IPs, formats results mapping IPs to hostnames (or 'No hostnames found'), and returns formatted JSON as 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)Registration of the reverse_dns_lookup tool in the ListToolsRequestSchema handler, including name, description, and converted input 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), },
- src/index.ts:22-24 (helper)TypeScript interface for the Shodan reverse DNS API response structure, mapping IP strings to arrays of hostnames.interface ReverseDnsResponse { [ip: string]: string[]; // Maps IP address to array of hostnames }