{"record":{"id":"969cd24dc88d9662","repo":"netbirdio/netbird","slug":"invalid-translated-port-v","errorCode":null,"errorMessage":"invalid translated port: %v","messagePattern":"invalid translated port: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/firewall/iptables/router_linux.go","lineNumber":788,"sourceCode":"}\n\nfunc (r *router) AddDNATRule(rule firewall.ForwardRule) (firewall.Rule, error) {\n\truleKey := rule.ID()\n\tif _, exists := r.rules[ruleKey+dnatSuffix]; exists {\n\t\treturn rule, nil\n\t}\n\n\ttoDestination := rule.TranslatedAddress.String()\n\tswitch {\n\tcase len(rule.TranslatedPort.Values) == 0:\n\t\t// no translated port, use original port\n\tcase len(rule.TranslatedPort.Values) == 1:\n\t\ttoDestination += fmt.Sprintf(\":%d\", rule.TranslatedPort.Values[0])\n\tcase rule.TranslatedPort.IsRange && len(rule.TranslatedPort.Values) == 2:\n\t\t// need the \"/originalport\" suffix to avoid dnat port randomization\n\t\ttoDestination += fmt.Sprintf(\":%d-%d/%d\", rule.TranslatedPort.Values[0], rule.TranslatedPort.Values[1], rule.DestinationPort.Values[0])\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid translated port: %v\", rule.TranslatedPort)\n\t}\n\n\tproto := strings.ToLower(string(rule.Protocol))\n\n\trules := make(map[string]ruleInfo, 3)\n\n\t// DNAT rule\n\tdnatRule := []string{\n\t\t\"!\", \"-i\", r.wgIface.Name(),\n\t\t\"-p\", proto,\n\t\t\"-j\", \"DNAT\",\n\t\t\"--to-destination\", toDestination,\n\t}\n\tdnatRule = append(dnatRule, applyPort(\"--dport\", &rule.DestinationPort)...)\n\trules[ruleKey+dnatSuffix] = ruleInfo{\n\t\ttable: tableNat,\n\t\tchain: chainRTRDR,\n\t\trule:  dnatRule,","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/firewall/iptables/router_linux.go#L770-L806","documentation":"Error \"invalid translated port: %v\" thrown in netbirdio/netbird.","triggerScenarios":"Thrown at client/firewall/iptables/router_linux.go:788 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"}