{"record":{"id":"d7b86b0c14d5da33","repo":"netbirdio/netbird","slug":"set-interface-mtu-w","errorCode":null,"errorMessage":"set interface mtu: %w","messagePattern":"set interface mtu: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/freebsd/link.go","lineNumber":188,"sourceCode":"\tif err != nil {\n\t\tlog.Debugf(\"ifconfig out: %s\", stderr.String())\n\n\t\treturn fmt.Errorf(\"destroy %s interface: %w\", name, err)\n\t}\n\n\treturn nil\n}\n\nfunc (l *Link) setMTU(mtu int) error {\n\tvar stderr bytes.Buffer\n\n\tcmd := exec.Command(\"ifconfig\", l.name, \"mtu\", strconv.Itoa(mtu))\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 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\")","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/freebsd/link.go#L170-L206","documentation":"setMTU() applies the MTU with `ifconfig <name> mtu <N>` and wraps a non-zero exit; stderr is logged at debug. It fails when the value is outside the range the kernel accepts for the interface (below the driver minimum or above 65535), when the interface no longer exists, or on privilege denial.","triggerScenarios":"Applying an MTU received from management/network config that the kernel refuses (0, negative, or below the wg driver minimum), or setting the MTU after the interface was destroyed concurrently.","commonSituations":"Misconfigured MTU pushed by management; stale interface after an unclean shutdown; unprivileged run; MTU below 1280 while IPv6 is in use.","solutions":["Validate the configured MTU is within 1280-65535 before applying (1280 is the IPv6-safe minimum)","Confirm the interface exists with `ifconfig <name>`","Apply manually `sudo ifconfig <name> mtu <N>` to see the kernel's refusal text","Run the agent as root"],"exampleFix":"// before\nw.SetMTU(mtu)\n\n// after\nif mtu < 1280 || mtu > 65535 {\n    return fmt.Errorf(\"mtu %d out of range\", mtu)\n}\nw.SetMTU(mtu)","handlingStrategy":"validation","validationCode":"const minMTU, maxMTU = 1280, 65535\nif mtu < minMTU || mtu > maxMTU {\n    return fmt.Errorf(\"invalid mtu %d: must be %d-%d\", mtu, minMTU, maxMTU)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp and validate MTU at configuration load time","Keep MTU at or above 1280 when the IPv6 overlay is enabled","Smoke-test MTU acceptance after driver or kernel upgrades"],"tags":["go","freebsd","ifconfig","mtu","configuration"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}