netbirdio/netbird · error

get rules from nat table

Error message

get rules from nat table: %w

What it means

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.

Solutions

  1. Retry the operation
  2. Verify the nat table/chain exist on the host
  3. Check nftables connection health
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/firewall/nftables/router_linux.go:168 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/348eedd3e14e8a72. Report an issue: GitHub.

Appendix: source

Thrown at client/firewall/nftables/router_linux.go:168

	return nberrors.FormatErrorOrNil(merr)
}

func (r *router) removeNatPreroutingRules() error {
	table := &nftables.Table{
		Name:   tableNat,
		Family: r.af.tableFamily,
	}
	chain := &nftables.Chain{
		Name:     chainNameNatPrerouting,
		Table:    table,
		Hooknum:  nftables.ChainHookPrerouting,
		Priority: nftables.ChainPriorityNATDest,
		Type:     nftables.ChainTypeNAT,
	}
	rules, err := r.conn.GetRules(table, chain)
	if err != nil {
		return fmt.Errorf("get rules from nat table: %w", err)
	}

	var merr *multierror.Error

	// Delete rules that have our UserData suffix
	for _, rule := range rules {
		if len(rule.UserData) == 0 || !strings.HasSuffix(string(rule.UserData), dnatSuffix) {
			continue
		}
		if err := r.conn.DelRule(rule); err != nil {
			merr = multierror.Append(merr, fmt.Errorf("delete rule %s: %w", rule.UserData, err))
		}
	}

	if err := r.conn.Flush(); err != nil {
		merr = multierror.Append(merr, fmt.Errorf(flushError, err))
	}
	return nberrors.FormatErrorOrNil(merr)

View on GitHub (pinned to 93e97f4bf1)