{"record":{"id":"59f0243519a20595","repo":"XTLS/Xray-core","slug":"unable-to-set-ips","errorCode":null,"errorMessage":"unable to set ips","messagePattern":"unable to set ips","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/tun/tun_windows.go","lineNumber":126,"sourceCode":"\t}\n\troutesData := make([]*winipcfg.RouteData, 0, len(routesMap))\n\tfor route := range routesMap {\n\t\tr := route\n\t\troutesData = append(routesData, &r)\n\t}\n\terr := t.luid.SetRoutes(routesData)\n\tif err != nil {\n\t\treturn errors.New(\"unable to set routes\").Base(err)\n\t}\n\n\tif len(t.options.Gateway) > 0 {\n\t\taddresses := make([]netip.Prefix, 0, len(t.options.Gateway))\n\t\tfor _, address := range t.options.Gateway {\n\t\t\taddresses = append(addresses, netip.MustParsePrefix(address))\n\t\t}\n\t\terr := t.luid.SetIPAddresses(addresses)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"unable to set ips\").Base(err)\n\t\t}\n\t}\n\n\tif has4 {\n\t\tipif, err := t.luid.IPInterface(windows.AF_INET)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tipif.RouterDiscoveryBehavior = winipcfg.RouterDiscoveryDisabled\n\t\tipif.DadTransmits = 0\n\t\tipif.ManagedAddressConfigurationSupported = false\n\t\tipif.OtherStatefulConfigurationSupported = false\n\t\tipif.NLMTU = t.options.MTU\n\t\tipif.UseAutomaticMetric = false\n\t\tipif.Metric = 0\n\t\terr = ipif.Set()\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/tun/tun_windows.go#L108-L144","documentation":"On Windows, after routes are set, gateway addresses are applied via LUID.SetIPAddresses. Failure wraps into this error. Note the addresses are built with netip.MustParsePrefix, so invalid gateway strings panic rather than reach this error; this error specifically means the winipcfg call itself failed — usually privileges, an invalid address family for the adapter, or the adapter disappearing.","triggerScenarios":"Non-elevated process; mixing IPv4 and IPv6 gateway prefixes when the adapter has only one family enabled; adapter removed/racing during setup; duplicate address already assigned by another process.","commonSituations":"Running without admin rights; IPv6 disabled system-wide but IPv6 gateways configured; another service (ICS, VPN) assigning addresses to the adapter.","solutions":["Run elevated (Administrator/SYSTEM)","Ensure gateway prefixes are valid and match enabled address families","Remove addresses other tools put on the adapter, or stop those tools","Enable IPv6 components if using IPv6 gateway prefixes"],"exampleFix":"// before\n\"gateway\": [\"172.19.0.1/30\", \"fd00::1/128\"]  // system IPv6 disabled\n\n// after\n\"gateway\": [\"172.19.0.1/30\"]","handlingStrategy":"validation","validationCode":"for _, gw := range cfg.Gateway {\n\tif _, err := netip.ParsePrefix(gw); err != nil {\n\t\tlog.Fatalf(\"invalid gateway %q (must be valid prefix; invalid values panic)\", gw)\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run elevated","Validate every gateway string before start (MustParsePrefix panics otherwise)","Match gateway families to enabled protocol stacks"],"tags":["tun","windows","winipcfg","address","permissions"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}