{"record":{"id":"348eedd3e14e8a72","repo":"netbirdio/netbird","slug":"get-rules-from-nat-table-w","errorCode":null,"errorMessage":"get rules from nat table: %w","messagePattern":"get rules from nat table: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/nftables/router_linux.go","lineNumber":168,"sourceCode":"\n\treturn nberrors.FormatErrorOrNil(merr)\n}\n\nfunc (r *router) removeNatPreroutingRules() error {\n\ttable := &nftables.Table{\n\t\tName:   tableNat,\n\t\tFamily: r.af.tableFamily,\n\t}\n\tchain := &nftables.Chain{\n\t\tName:     chainNameNatPrerouting,\n\t\tTable:    table,\n\t\tHooknum:  nftables.ChainHookPrerouting,\n\t\tPriority: nftables.ChainPriorityNATDest,\n\t\tType:     nftables.ChainTypeNAT,\n\t}\n\trules, err := r.conn.GetRules(table, chain)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get rules from nat table: %w\", err)\n\t}\n\n\tvar merr *multierror.Error\n\n\t// Delete rules that have our UserData suffix\n\tfor _, rule := range rules {\n\t\tif len(rule.UserData) == 0 || !strings.HasSuffix(string(rule.UserData), dnatSuffix) {\n\t\t\tcontinue\n\t\t}\n\t\tif err := r.conn.DelRule(rule); err != nil {\n\t\t\tmerr = multierror.Append(merr, fmt.Errorf(\"delete rule %s: %w\", rule.UserData, err))\n\t\t}\n\t}\n\n\tif err := r.conn.Flush(); err != nil {\n\t\tmerr = multierror.Append(merr, fmt.Errorf(flushError, err))\n\t}\n\treturn nberrors.FormatErrorOrNil(merr)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/nftables/router_linux.go#L150-L186","documentation":"GetRules on the nat-table prerouting chain failed while removeNatPreroutingRules was inspecting existing rules to delete the ones carrying NetBird's UserData suffix. Without the rule list the cleanup cannot distinguish NetBird rules from foreign ones, so it aborts rather than deleting unrelated rules.","triggerScenarios":"Thrown at client/firewall/nftables/router_linux.go:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the operation","Verify the nat table/chain exist on the host","Check nftables connection health"],"exampleFix":null,"handlingStrategy":"retry","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"}