netbirdio/netbird · error

add v4 address

Error message

add v4 address: %s: %w

What it means

The ifconfig command that assigns the IPv4 address to the macOS utun interface failed; the combined command output is embedded in the message. Raised from assignAddr, used by both Create and UpdateAddr.

Solutions

  1. Read the embedded ifconfig output for the kernel reason
  2. Verify the IP is valid and not already assigned
  3. Retry the address assignment
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at client/iface/device/device_darwin.go:135 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/9de9e40a48ed14f6. Report an issue: GitHub.

Appendix: source

Thrown at client/iface/device/device_darwin.go:135

}

func (t *TunDevice) DeviceName() string {
	return t.name
}

func (t *TunDevice) FilteredDevice() *FilteredDevice {
	return t.filteredDevice
}

// Device returns the wireguard device
func (t *TunDevice) Device() *device.Device {
	return t.device
}

// assignAddr Adds IP address to the tunnel interface and network route based on the range provided
func (t *TunDevice) assignAddr() error {
	if out, err := exec.Command("ifconfig", t.name, "inet", t.address.IP.String(), t.address.IP.String()).CombinedOutput(); err != nil {
		return fmt.Errorf("add v4 address: %s: %w", string(out), err)
	}

	// Assign a dummy link-local so macOS enables IPv6 on the tun device.
	// When a real overlay v6 is present, use that instead.
	v6Addr := "fe80::/64"
	if t.address.HasIPv6() {
		v6Addr = t.address.IPv6String()
	}
	if out, err := exec.Command("ifconfig", t.name, "inet6", v6Addr).CombinedOutput(); err != nil {
		log.Warnf("failed to assign IPv6 address %s, continuing v4-only: %s: %v", v6Addr, string(out), err)
		t.address.ClearIPv6()
	}

	if out, err := exec.Command("route", "add", "-net", t.address.Network.String(), "-interface", t.name).CombinedOutput(); err != nil {
		return fmt.Errorf("add route %s via %s: %s: %w", t.address.Network, t.name, string(out), err)
	}

	if t.address.HasIPv6() {

View on GitHub (pinned to 93e97f4bf1)