{"record":{"id":"3c093e31b3d444e2","repo":"netbirdio/netbird","slug":"set-ipv4-interface-mtu-s","errorCode":null,"errorMessage":"set IPv4 interface MTU: %s","messagePattern":"set IPv4 interface MTU: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/device/device_windows.go","lineNumber":90,"sourceCode":"\t\tt.filteredDevice,\n\t\tt.iceBind,\n\t\tdevice.NewLogger(wgLogLevel(), \"[netbird] \"),\n\t)\n\n\tluid := winipcfg.LUID(t.nativeTunDevice.LUID())\n\n\tnbiface, err := luid.IPInterface(windows.AF_INET)\n\tif err != nil {\n\t\tt.device.Close()\n\t\treturn nil, fmt.Errorf(\"got error when getting ip interface %s\", err)\n\t}\n\n\tnbiface.NLMTU = uint32(t.mtu)\n\n\terr = nbiface.Set()\n\tif err != nil {\n\t\tt.device.Close()\n\t\treturn nil, fmt.Errorf(\"set IPv4 interface MTU: %s\", err)\n\t}\n\n\tif t.address.HasIPv6() {\n\t\tnbiface6, err := luid.IPInterface(windows.AF_INET6)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"failed to get IPv6 interface for MTU, continuing v4-only: %v\", err)\n\t\t\tt.address.ClearIPv6()\n\t\t} else {\n\t\t\tnbiface6.NLMTU = uint32(t.mtu)\n\t\t\tif err := nbiface6.Set(); err != nil {\n\t\t\t\tlog.Warnf(\"failed to set IPv6 interface MTU, continuing v4-only: %v\", err)\n\t\t\t\tt.address.ClearIPv6()\n\t\t\t}\n\t\t}\n\t}\n\terr = t.assignAddr()\n\tif err != nil {\n\t\tt.device.Close()","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/device/device_windows.go#L72-L108","documentation":"Windows Create() sets NLMTU on the MIB_IPINTERFACE_ROW returned by the previous query and applies it via Set() (SetIpInterfaceEntry). Failure of that call is wrapped here and the device is closed. This is the IPv4 MTU apply; the later IPv6 MTU apply is deliberately soft (warn plus ClearIPv6), so only IPv4 MTU problems abort creation.","triggerScenarios":"MTU outside the accepted IPv4 range (below ~576 or above 65535), the interface row in a transient/invalid state, or SetIpInterfaceEntry returning an API error.","commonSituations":"An MDM policy or management config pushing an invalid MTU, default MTU misconfiguration, driver state issues after adapter churn.","solutions":["Clamp the configured MTU into the 1280-65535 range (WireGuard minimum is 1280)","Retry with the default MTU to confirm the value is the cause","Update wintun/client if Set fails even with a valid MTU"],"exampleFix":"// before\nnbiface.NLMTU = uint32(t.mtu)\nerr = nbiface.Set()\n\n// after\nmtu := int(t.mtu)\nif mtu < 1280 {\n    mtu = 1280\n}\nif mtu > 65535 {\n    mtu = 65535\n}\nnbiface.NLMTU = uint32(mtu)\nerr = nbiface.Set()","handlingStrategy":"validation","validationCode":"const (\n    minWGMTU = 1280\n    maxWGMTU = 65535\n)\nif mtu < minWGMTU || mtu > maxWGMTU {\n    return fmt.Errorf(\"mtu %d out of range [%d, %d]\", mtu, minWGMTU, maxWGMTU)\n}","typeGuard":null,"tryCatchPattern":"if err := nbiface.Set(); err != nil {\n    if nbiface.NLMTU < 576 {\n        // MTU below IPv4 minimum: clamp and retry Set once\n    }\n    return fmt.Errorf(\"set IPv4 interface MTU: %w\", err)\n}","preventionTips":["Clamp configured MTU into 1280-65535 at the config boundary","Validate MDM/pushed MTU values before they reach the device layer","Test MTU changes on one host before fleet-wide rollout"],"tags":["windows","mtu","winipcfg","configuration"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}