netbirdio/netbird · error

add route via

Error message

add route %s via %s: %s: %w

What it means

Adding the IPv6 address (or dummy link-local) and its route to the macOS utun via ifconfig failed. The command output in the message explains the rejection; assignAddr aborts leaving v4 configured only.

Solutions

  1. Check the embedded ifconfig output
  2. Verify the v6 address and prefix length
  3. Retry or skip v6 if the overlay is v4-only
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

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

// 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() {
		if out, err := exec.Command("route", "add", "-inet6", "-net", t.address.IPv6Net.String(), "-interface", t.name).CombinedOutput(); err != nil {
			log.Warnf("failed to add route %s via %s, continuing v4-only: %s: %v", t.address.IPv6Net, t.name, string(out), err)
			t.address.ClearIPv6()
		}
	}

	return nil
}

func (t *TunDevice) GetNet() *netstack.Net {
	return nil
}

// GetICEBind returns the ICEBind instance
func (t *TunDevice) GetICEBind() EndpointManager {

View on GitHub (pinned to 93e97f4bf1)