{"record":{"id":"67bc10cf4b4dc372","repo":"netbirdio/netbird","slug":"set-interface-addr-w","errorCode":null,"errorMessage":"set interface addr: %w","messagePattern":"set interface addr: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/freebsd/link.go","lineNumber":203,"sourceCode":"\tif err := cmd.Run(); err != nil {\n\t\tlog.Debugf(\"ifconfig out: %s\", stderr.String())\n\n\t\treturn fmt.Errorf(\"set interface mtu: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (l *Link) setAddr(ip, netmask string) error {\n\tvar stderr bytes.Buffer\n\n\tcmd := exec.Command(\"ifconfig\", l.name, \"inet\", ip, \"netmask\", netmask)\n\tcmd.Stderr = &stderr\n\n\tif err := cmd.Run(); err != nil {\n\t\tlog.Debugf(\"ifconfig out: %s\", stderr.String())\n\n\t\treturn fmt.Errorf(\"set interface addr: %w\", err)\n\t}\n\n\tcmd = exec.Command(\"ifconfig\", l.name, \"inet6\", \"fe80::/64\")\n\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\tlog.Debugf(\"adding address command '%v' failed with output: %s\", cmd.String(), out)\n\t}\n\n\treturn nil\n}\n\nfunc (l *Link) up(name string) error {\n\tvar stderr bytes.Buffer\n\n\tcmd := exec.Command(\"ifconfig\", name, \"up\")\n\tcmd.Stderr = &stderr\n\n\terr := cmd.Run()\n\tif err != nil {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/freebsd/link.go#L185-L221","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect current assignments with `ifconfig <name>` and remove stale aliases with `sudo ifconfig <name> inet <old-ip> -alias`","Parse ip and netmask (netip/net.ParseIP) before applying","Choose an overlay range that does not overlap existing subnets","Restart the agent so Recreate() builds a clean interface"],"exampleFix":"# before\n$ ifconfig wt0 inet 100.96.0.1 netmask 255.255.255.0\nifconfig: ioctl (SIOCAIFADDR): File exists\n\n# after\n$ sudo ifconfig wt0 inet 100.96.0.1 -alias 2>/dev/null || true\n$ sudo ifconfig wt0 inet 100.96.0.1 netmask 255.255.255.0","handlingStrategy":"validation","validationCode":"if net.ParseIP(ip) == nil {\n    return fmt.Errorf(\"invalid ip %q\", ip)\n}\nif m := net.IPMask(net.ParseIP(netmask).To4()); m == nil {\n    return fmt.Errorf(\"invalid netmask %q\", netmask)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate address and netmask at configuration load","Prefer Recreate() over reuse after unclean shutdowns so stale aliases cannot collide","Choose overlay ranges that do not overlap existing subnets on the host"],"tags":["go","freebsd","ifconfig","ip-address","configuration"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}