netbirdio/netbird · error

generate route rule spec

Error message

generate route rule spec: %w

What it means

genRouteRuleSpec could not build an iptables rule spec from the given route-filtering parameters — for example a network that is neither a set nor a prefix, or port parameters that cannot be expressed. A rule-construction bug or unsupported combination, not an iptables failure.

Solutions

  1. Check the route's source/destination and port definitions for unsupported shapes
  2. Update the client; rule-spec generation gaps are fixed in releases
  3. Report the route definition if the error reproduces
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at client/firewall/iptables/router_linux.go:172 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/af8f97147034444c. Report an issue: GitHub.

Appendix: source

Thrown at client/firewall/iptables/router_linux.go:172

	var source firewall.Network
	if len(sources) > 1 {
		source.Set = firewall.NewPrefixSet(sources)
	} else if len(sources) > 0 {
		source.Prefix = sources[0]
	}

	params := routeFilteringRuleParams{
		Source:      source,
		Destination: destination,
		Proto:       proto,
		SPort:       sPort,
		DPort:       dPort,
		Action:      action,
	}

	rule, err := r.genRouteRuleSpec(params, sources)
	if err != nil {
		return nil, fmt.Errorf("generate route rule spec: %w", err)
	}

	// Insert DROP rules at the beginning, append ACCEPT rules at the end
	if action == firewall.ActionDrop {
		// after the established rule
		err = r.iptablesClient.Insert(tableFilter, chainRTFWDIN, 2, rule...)
	} else {
		err = r.iptablesClient.Append(tableFilter, chainRTFWDIN, rule...)
	}

	if err != nil {
		return nil, fmt.Errorf("add route rule: %v", err)
	}

	r.rules[string(ruleKey)] = rule

	r.updateState()

View on GitHub (pinned to 93e97f4bf1)