netbirdio/netbird · error

create or get ipset

Error message

create or get ipset: %w

What it means

While building an iptables rule that references a network set, incrementing the ipset reference counter (which creates the ipset or updates its membership for the given prefixes) failed. Without the ipset the generated rule would match nothing or iptables would reject the set reference, so rule construction is aborted and the caller must not append the partially built rule.

Solutions

  1. Verify ipset kernel module and tooling are available
  2. Check daemon capabilities
  3. Retry after restarting the daemon
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

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

		rule = append(rule, applyPort("--sport", params.SPort)...)
		rule = append(rule, applyPort("--dport", params.DPort)...)
	}

	rule = append(rule, "-j", actionToStr(params.Action))

	return rule, nil
}

func (r *router) applyNetwork(flag string, network firewall.Network, prefixes []netip.Prefix) ([]string, error) {
	direction := "src"
	if flag == "-d" {
		direction = "dst"
	}

	if network.IsSet() {
		name := r.ipsetName(network.Set.HashedName())
		if _, err := r.ipsetCounter.Increment(name, prefixes); err != nil {
			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))

View on GitHub (pinned to 93e97f4bf1)