{"record":{"id":"723999464ac3ea3c","repo":"netbirdio/netbird","slug":"enable-forwarding-w","errorCode":null,"errorMessage":"enable forwarding: %w","messagePattern":"enable forwarding: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/iptables/router_linux.go","lineNumber":847,"sourceCode":"\t}\n\tforwardRule = append(forwardRule, applyPort(\"--dport\", &rule.TranslatedPort)...)\n\trules[ruleKey+fwdSuffix] = ruleInfo{\n\t\ttable: tableFilter,\n\t\tchain: chainRTFWDOUT,\n\t\trule:  forwardRule,\n\t}\n\n\tfor key, ruleInfo := range rules {\n\t\tif err := r.iptablesClient.Append(ruleInfo.table, ruleInfo.chain, ruleInfo.rule...); err != nil {\n\t\t\tr.cleanupFailedDNATAdd(rules)\n\t\t\treturn nil, fmt.Errorf(\"add rule %s: %w\", key, err)\n\t\t}\n\t\tr.rules[key] = ruleInfo.rule\n\t}\n\n\tif err := r.ipFwdState.RequestForwarding(r.v6); err != nil {\n\t\tr.cleanupFailedDNATAdd(rules)\n\t\treturn nil, fmt.Errorf(\"enable forwarding: %w\", err)\n\t}\n\n\tr.updateState()\n\treturn rule, nil\n}\n\n// cleanupFailedDNATAdd removes the bookkeeping written by a partially applied\n// AddDNATRule before rolling back the kernel rules, so no entries remain that\n// never got a forwarding refcount. rollbackRules re-adds entries it failed to\n// remove from the kernel.\nfunc (r *router) cleanupFailedDNATAdd(rules map[string]ruleInfo) {\n\tfor key := range rules {\n\t\tdelete(r.rules, key)\n\t}\n\tif err := r.rollbackRules(rules); err != nil {\n\t\tlog.Errorf(\"rollback failed: %v\", err)\n\t}\n}","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/iptables/router_linux.go#L829-L865","documentation":"Error \"enable forwarding: %w\" thrown in netbirdio/netbird.","triggerScenarios":"Thrown at client/firewall/iptables/router_linux.go:847 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"}