netbirdio/netbird · error

add prefix to ipset

Error message

add prefix to ipset: %w

What it means

UpdateSet accumulated per-prefix failures while adding prefixes to an ipset. Multierror form: every prefix is attempted, failures are collected, and on success the set refcount is refreshed only when merr is nil.

Solutions

  1. Check inner errors for which prefixes failed (often family mismatch v4/v6)
  2. Ensure ipset supports the family being programmed
  3. Retry the route update after correction
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/firewall/iptables/router_linux.go:984 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/5cd9f800a2aebad4. Report an issue: GitHub.

Appendix: source

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

			return nil, fmt.Errorf("create or get ipset: %w", err)
		}

		return []string{"-m", "set", matchSet, name, direction}, nil
	}
	if network.IsPrefix() {
		return []string{flag, network.Prefix.String()}, nil
	}

	// nolint:nilnil
	return nil, nil
}

func (r *router) UpdateSet(set firewall.Set, prefixes []netip.Prefix) error {
	name := r.ipsetName(set.HashedName())
	var merr *multierror.Error
	for _, prefix := range prefixes {
		if err := r.addPrefixToIPSet(name, prefix); err != nil {
			merr = multierror.Append(merr, fmt.Errorf("add prefix to ipset: %w", err))
		}
	}
	if merr == nil {
		log.Debugf("updated set %s with prefixes %v", name, prefixes)
	}

	return nberrors.FormatErrorOrNil(merr)
}

// AddInboundDNAT adds an inbound DNAT rule redirecting traffic from NetBird peers to local services.
func (r *router) AddInboundDNAT(localAddr netip.Addr, protocol firewall.Protocol, originalPort, translatedPort uint16) error {
	ruleID := fmt.Sprintf("inbound-dnat-%s-%s-%d-%d", localAddr.String(), protocol, originalPort, translatedPort)

	if _, exists := r.rules[ruleID]; exists {
		return nil
	}

	dnatRule := []string{

View on GitHub (pinned to 93e97f4bf1)