netbirdio/netbird · error

set interface addr: %w

Error message

set interface addr: %w

What it means

setAddr() assigns the overlay IPv4 with `ifconfig <name> inet <ip> netmask <mask>` and wraps a non-zero exit. The follow-up IPv6 link-local command (fe80::/64) is best-effort and only logged, so this error always means the IPv4 assignment failed: malformed address or netmask, the address is already assigned, or privilege denial.

Source

Thrown at client/iface/freebsd/link.go:203

	if err := cmd.Run(); err != nil {
		log.Debugf("ifconfig out: %s", stderr.String())

		return fmt.Errorf("set interface mtu: %w", err)
	}

	return nil
}

func (l *Link) setAddr(ip, netmask string) error {
	var stderr bytes.Buffer

	cmd := exec.Command("ifconfig", l.name, "inet", ip, "netmask", netmask)
	cmd.Stderr = &stderr

	if err := cmd.Run(); err != nil {
		log.Debugf("ifconfig out: %s", stderr.String())

		return fmt.Errorf("set interface addr: %w", err)
	}

	cmd = exec.Command("ifconfig", l.name, "inet6", "fe80::/64")
	if out, err := cmd.CombinedOutput(); err != nil {
		log.Debugf("adding address command '%v' failed with output: %s", cmd.String(), out)
	}

	return nil
}

func (l *Link) up(name string) error {
	var stderr bytes.Buffer

	cmd := exec.Command("ifconfig", name, "up")
	cmd.Stderr = &stderr

	err := cmd.Run()
	if err != nil {

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Inspect current assignments with `ifconfig <name>` and remove stale aliases with `sudo ifconfig <name> inet <old-ip> -alias`
  2. Parse ip and netmask (netip/net.ParseIP) before applying
  3. Choose an overlay range that does not overlap existing subnets
  4. Restart the agent so Recreate() builds a clean interface

Example fix

# before
$ ifconfig wt0 inet 100.96.0.1 netmask 255.255.255.0
ifconfig: ioctl (SIOCAIFADDR): File exists

# after
$ sudo ifconfig wt0 inet 100.96.0.1 -alias 2>/dev/null || true
$ sudo ifconfig wt0 inet 100.96.0.1 netmask 255.255.255.0
Defensive patterns

Strategy: validation

Validate before calling

if net.ParseIP(ip) == nil {
    return fmt.Errorf("invalid ip %q", ip)
}
if m := net.IPMask(net.ParseIP(netmask).To4()); m == nil {
    return fmt.Errorf("invalid netmask %q", netmask)
}

Prevention

When it happens

Trigger: Assigning an address that duplicates one already on the interface (stale address from a previous run), a netmask that does not parse, or a range overlapping another interface's subnet so the kernel refuses the SIOCAIFADDR.

Common situations: Unclean shutdown left the old address aliased on the interface; management network range overlaps the LAN or another VPN; corrupted address serialization in stored state.

Related errors


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