{"record":{"id":"d22774add00ccd2e","repo":"projectdiscovery/nuclei","slug":"cannot-use-ip-address-as-dns-input","errorCode":null,"errorMessage":"cannot use IP address as DNS input","messagePattern":"cannot use IP address as DNS input","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/protocols/dns/request.go","lineNumber":226,"sourceCode":"\t\tdumpTraceData(event, request.options, traceToString(traceData, true), question)\n\t}\n\n\tcallback(event)\n\treturn err\n}\n\nfunc (request *Request) parseDNSInput(host string) (string, error) {\n\tisIP := iputil.IsIP(host)\n\tswitch {\n\tcase request.question == dns.TypePTR && isIP:\n\t\tvar err error\n\t\thost, err = dns.ReverseAddr(host)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\tdefault:\n\t\tif isIP {\n\t\t\treturn \"\", errors.New(\"cannot use IP address as DNS input\")\n\t\t}\n\t\thost = dns.Fqdn(host)\n\t}\n\treturn host, nil\n}\n\nfunc dumpResponse(event *output.InternalWrappedEvent, request *Request, _ *protocols.ExecutorOptions, response, domain string) {\n\tcliOptions := request.options.Options\n\tif cliOptions.Debug || cliOptions.DebugResponse || cliOptions.StoreResponse {\n\t\thexDump := false\n\t\tif responsehighlighter.HasBinaryContent(response) {\n\t\t\thexDump = true\n\t\t\tresponse = hex.Dump([]byte(response))\n\t\t}\n\t\thighlightedResponse := responsehighlighter.Highlight(event.OperatorsResult, response, cliOptions.NoColor, hexDump)\n\t\tmsg := fmt.Sprintf(\"[%s] Dumped DNS response for %s\\n\\n%s\", request.options.TemplateID, domain, highlightedResponse)\n\t\tif cliOptions.Debug || cliOptions.DebugResponse {\n\t\t\tgologger.Debug().Msg(msg)","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/dns/request.go#L208-L244","documentation":"Thrown by parseDNSInput in the DNS protocol when the target input is an IP literal but the DNS question type is not PTR. Nuclei only accepts IP inputs for PTR (reverse) queries, where it converts the address to an in-addr.arpa/ip6.arpa name via dns.ReverseAddr; every other question type (A, AAAA, CNAME, NS, MX, TXT, SOA) needs a hostname, since asking a resolver for an A record of '1.2.3.4' is meaningless.","triggerScenarios":"Running a DNS template whose requests block has `type: A` (or any non-PTR type) against an IP target, e.g. `echo 192.168.1.1 | nuclei -t dns-template.yaml`. Feeding a mixed list of hostnames and IPs to a DNS workflow without routing IPs to a PTR-only template.","commonSituations":"Scanning CIDR ranges or IP lists with DNS templates copied from hostname-oriented templates; forgetting that reverse lookups need `type: PTR`; input lists produced by subdomain-to-IP resolution pipelines.","solutions":["Use a hostname as the target when the template queries non-PTR record types","Switch the template to `type: PTR` when you must feed IP inputs (nuclei then builds the reverse name automatically)","Pre-filter IP literals out of the target list: grep -vE '^[0-9.]+$|^[0-9a-fA-F:]+$' targets.txt","In workflows, split inputs so IPs go to a PTR template and hostnames go to forward-query templates"],"exampleFix":"# before\nrequests:\n  - - type: A\n# run: echo 192.168.1.1 | nuclei -t tpl.yaml  -> error\n\n# after\nrequests:\n  - - type: PTR\n# run: echo 192.168.1.1 | nuclei -t tpl.yaml  -> reverse lookup","handlingStrategy":"validation","validationCode":"import \"github.com/projectdiscovery/utils/ip\"\n\nfunc usableForDNS(input string, isPTR bool) bool {\n\tif ip.IsIP(input) {\n\t\treturn isPTR // only PTR questions accept IP inputs\n\t}\n\treturn true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep separate target lists for IP ranges vs hostnames and match them to the right DNS templates","Before scanning, filter IP literals out of inputs destined for forward-DNS templates","In workflows, branch on iputil.IsIP and route IPs to a `type: PTR` template"],"tags":["dns","input-validation","template","ip-address"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}