{"record":{"id":"2bd9f892df12a49d","repo":"netbirdio/netbird","slug":"delete-inbound-dnat-rule-w","errorCode":null,"errorMessage":"delete inbound DNAT rule: %w","messagePattern":"delete inbound DNAT rule: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/iptables/router_linux.go","lineNumber":1033,"sourceCode":"\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\n\tr.updateState()\n\treturn nil\n}\n\n// ensureNATOutputChain lazily creates the OUTPUT NAT chain and jump rule on first use.\nfunc (r *router) ensureNATOutputChain() error {\n\tif _, exists := r.rules[jumpNatOutput]; exists {\n\t\treturn nil\n\t}\n\n\tchainExists, err := r.iptablesClient.ChainExists(tableNat, chainNATOutput)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"check chain %s: %w\", chainNATOutput, err)\n\t}","sourceCodeStart":1015,"sourceCodeEnd":1051,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/iptables/router_linux.go#L1015-L1051","documentation":"Deleting the inbound DNAT rule from the nat table failed in RemoveInboundDNAT. The bookkeeping entry is removed only on successful delete, so the kernel rule may outlive the manager's knowledge of it if this persists.","triggerScenarios":"Thrown at client/firewall/iptables/router_linux.go:1033 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Manually delete the matching PREROUTING DNAT rule","Restart the daemon to reconcile kernel state","Address the underlying iptables failure"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","contentChangedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}