opnsense_diag_dns_lookup
Resolve a hostname by performing a DNS lookup directly from the OPNsense firewall. Returns DNS records for troubleshooting network issues.
Instructions
Perform a DNS lookup from the OPNsense firewall
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hostname | Yes | Hostname to look up |
Implementation Reference
- src/tools/diagnostics.ts:92-105 (registration)Tool registration definition in the diagnosticsToolDefinitions array. Defines the tool name, description, and input schema (hostname required).
{ name: "opnsense_diag_dns_lookup", description: "Perform a DNS lookup from the OPNsense firewall", inputSchema: { type: "object" as const, properties: { hostname: { type: "string", description: "Hostname to look up", }, }, required: ["hostname"], }, }, - src/tools/diagnostics.ts:23-25 (schema)Zod schema for DNS lookup input validation. Requires a non-empty 'hostname' field.
const DnsLookupSchema = z.object({ hostname: z.string().min(1, "Hostname or IP address is required"), }); - src/tools/diagnostics.ts:372-381 (handler)Handler case within handleDiagnosticsTool function. Parses args via DnsLookupSchema, then makes a GET request to the OPNsense reverse_lookup API endpoint. Returns the result as formatted JSON.
case "opnsense_diag_dns_lookup": { const parsed = DnsLookupSchema.parse(args); // OPNsense 24.7+: use reverse_lookup for IP→hostname resolution // Forward lookup (hostname→IP) is not available via API in 24.7 const result = await client.get( `/diagnostics/dns/reverse_lookup?address=${encodeURIComponent(parsed.hostname)}`, ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/index.ts:61-61 (registration)Registration in the MCP server: maps all diagnostics tool names (including opnsense_diag_dns_lookup) to the handleDiagnosticsTool handler function.
for (const def of diagnosticsToolDefinitions) toolHandlers.set(def.name, handleDiagnosticsTool);