{"record":{"id":"39b9f866edeec8b3","repo":"netbirdio/netbird","slug":"delete-forward-rule-w","errorCode":null,"errorMessage":"delete forward rule: %w","messagePattern":"delete forward rule: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/iptables/router_linux.go","lineNumber":911,"sourceCode":"\tif dnatRule, exists := r.rules[ruleKey+dnatSuffix]; exists {\n\t\tif err := r.iptablesClient.Delete(tableNat, chainRTRDR, dnatRule...); err != nil {\n\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"delete DNAT rule: %w\", err))\n\t\t} else {\n\t\t\tdelete(r.rules, ruleKey+dnatSuffix)\n\t\t}\n\t}\n\n\tif snatRule, exists := r.rules[ruleKey+snatSuffix]; exists {\n\t\tif err := r.iptablesClient.Delete(tableNat, chainRTNAT, snatRule...); err != nil {\n\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"delete SNAT rule: %w\", err))\n\t\t} else {\n\t\t\tdelete(r.rules, ruleKey+snatSuffix)\n\t\t}\n\t}\n\n\tif fwdRule, exists := r.rules[ruleKey+fwdSuffix]; exists {\n\t\tif err := r.iptablesClient.Delete(tableFilter, chainRTFWDOUT, fwdRule...); err != nil {\n\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"delete forward rule: %w\", err))\n\t\t} else {\n\t\t\tdelete(r.rules, ruleKey+fwdSuffix)\n\t\t}\n\t}\n\n\t// Release the refcount only once all rules are gone from the kernel. On\n\t// partial failure the failed entries stay in r.rules so a retry can remove\n\t// them and release then.\n\tif merr == nil {\n\t\tif err := r.ipFwdState.ReleaseForwarding(r.v6); err != nil {\n\t\t\tlog.Errorf(\"%v\", err)\n\t\t}\n\t}\n\n\tr.updateState()\n\treturn nberrors.FormatErrorOrNil(merr)\n}\n","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/iptables/router_linux.go#L893-L929","documentation":"Deleting the NAT-table FORWARD/forwarding rule associated with a routing rule failed while removing that routing rule's iptables entries. The failure is accumulated into a multierror (DNAT and SNAT deletions continue) so the caller gets a combined report; the rule's in-memory entry is only dropped on successful deletion, keeping the state consistent with the kernel.","triggerScenarios":"Thrown at client/firewall/iptables/router_linux.go:911 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the leftover FORWARD accept rule manually","Restart the daemon to resync","Check the inner error for why iptables delete failed"],"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"}