netbirdio/netbird · error

delete rule

Error message

delete rule %s: %w

What it means

Deleting a specific netbird-tagged DNAT rule from the nat prerouting chain failed. Each failure is accumulated into a multierror so sibling rules are still attempted; the named rule (UserData in the message) remains in the table.

Solutions

  1. Delete the reported rule manually with nft
  2. Retry after checking whether the rule handle went stale
  3. Flush the whole netbird prerouting chain if all rules are ours
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at client/firewall/nftables/router_linux.go:179 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/75859d4cd4605a19. Report an issue: GitHub.

Appendix: source

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

		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)
}

func (r *router) loadFilterTable() (*nftables.Table, error) {
	tables, err := r.conn.ListTablesOfFamily(r.af.tableFamily)
	if err != nil {
		return nil, fmt.Errorf("list tables: %w", err)
	}

	for _, table := range tables {
		if table.Name == "filter" {
			return table, nil

View on GitHub (pinned to 93e97f4bf1)