{"record":{"id":"986fdd1dc7b03e17","repo":"netbirdio/netbird","slug":"add-inbound-dnat-rule-w","errorCode":null,"errorMessage":"add inbound DNAT rule: %w","messagePattern":"add inbound DNAT rule: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/iptables/router_linux.go","lineNumber":1019,"sourceCode":"\n\tdnatRule := []string{\n\t\t\"-i\", r.wgIface.Name(),\n\t\t\"-p\", strings.ToLower(protoForFamily(protocol, r.v6)),\n\t\t\"--dport\", strconv.Itoa(int(originalPort)),\n\t\t\"-d\", localAddr.String(),\n\t\t\"-m\", \"addrtype\", \"--dst-type\", \"LOCAL\",\n\t\t\"-j\", \"DNAT\",\n\t\t\"--to-destination\", \":\" + strconv.Itoa(int(translatedPort)),\n\t}\n\n\truleInfo := ruleInfo{\n\t\ttable: tableNat,\n\t\tchain: chainRTRDR,\n\t\trule:  dnatRule,\n\t}\n\n\tif err := r.iptablesClient.Append(ruleInfo.table, ruleInfo.chain, ruleInfo.rule...); err != nil {\n\t\treturn fmt.Errorf(\"add inbound DNAT rule: %w\", err)\n\t}\n\tr.rules[ruleID] = ruleInfo.rule\n\n\tr.updateState()\n\treturn nil\n}\n\n// RemoveInboundDNAT removes an inbound DNAT rule.\nfunc (r *router) RemoveInboundDNAT(localAddr netip.Addr, protocol firewall.Protocol, originalPort, translatedPort uint16) error {\n\truleID := fmt.Sprintf(\"inbound-dnat-%s-%s-%d-%d\", localAddr.String(), protocol, originalPort, translatedPort)\n\n\tif dnatRule, exists := r.rules[ruleID]; exists {\n\t\tif err := r.iptablesClient.Delete(tableNat, chainRTRDR, dnatRule...); err != nil {\n\t\t\treturn fmt.Errorf(\"delete inbound DNAT rule: %w\", err)\n\t\t}\n\t\tdelete(r.rules, ruleID)\n\t}\n","sourceCodeStart":1001,"sourceCodeEnd":1037,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/iptables/router_linux.go#L1001-L1037","documentation":"Error \"add inbound DNAT rule: %w\" thrown in netbirdio/netbird.","triggerScenarios":"Thrown at client/firewall/iptables/router_linux.go:1019 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}