XTLS/Xray-core · error
unable to set ips
Error message
unable to set ips
What it means
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.
Source
Thrown at proxy/tun/tun_windows.go:126
}
routesData := make([]*winipcfg.RouteData, 0, len(routesMap))
for route := range routesMap {
r := route
routesData = append(routesData, &r)
}
err := t.luid.SetRoutes(routesData)
if err != nil {
return errors.New("unable to set routes").Base(err)
}
if len(t.options.Gateway) > 0 {
addresses := make([]netip.Prefix, 0, len(t.options.Gateway))
for _, address := range t.options.Gateway {
addresses = append(addresses, netip.MustParsePrefix(address))
}
err := t.luid.SetIPAddresses(addresses)
if err != nil {
return errors.New("unable to set ips").Base(err)
}
}
if has4 {
ipif, err := t.luid.IPInterface(windows.AF_INET)
if err != nil {
return err
}
ipif.RouterDiscoveryBehavior = winipcfg.RouterDiscoveryDisabled
ipif.DadTransmits = 0
ipif.ManagedAddressConfigurationSupported = false
ipif.OtherStatefulConfigurationSupported = false
ipif.NLMTU = t.options.MTU
ipif.UseAutomaticMetric = false
ipif.Metric = 0
err = ipif.Set()
if err != nil {
return errView on GitHub (pinned to 7d214f8b09)
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
Example fix
// before "gateway": ["172.19.0.1/30", "fd00::1/128"] // system IPv6 disabled // after "gateway": ["172.19.0.1/30"]
Defensive patterns
Strategy: validation
Validate before calling
for _, gw := range cfg.Gateway {
if _, err := netip.ParsePrefix(gw); err != nil {
log.Fatalf("invalid gateway %q (must be valid prefix; invalid values panic)", gw)
}
} Prevention
- Run elevated
- Validate every gateway string before start (MustParsePrefix panics otherwise)
- Match gateway families to enabled protocol stacks
When it happens
Trigger: 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.
Common situations: Running without admin rights; IPv6 disabled system-wide but IPv6 gateways configured; another service (ICS, VPN) assigning addresses to the adapter.
Related errors
- unable to set routes
- failed to add interface address {address}
- invalid interface address {address}
- failed to delete interface address {address}
- failed to add system route {cidr}
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/59f0243519a20595.
Report an issue: GitHub.