{"record":{"id":"3722d5188874c056","repo":"XTLS/Xray-core","slug":"fail-to-get-system-interface-information-w","errorCode":null,"errorMessage":"fail to get system interface information: %w","messagePattern":"fail to get system interface information: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/tun.go","lineNumber":67,"sourceCode":"\tif config.Desc == \"\" {\n\t\tconfig.Desc = \"Wintun\"\n\t}\n\tif config.MTU == 0 {\n\t\tconfig.MTU = 1500\n\t}\n\treturn config, nil\n}\n\nconst (\n\ttunNamePrefix = \"utun\"\n\tminTunIndex   = 10\n\tmaxTunIndex   = 1024\n)\n\nfunc GetAvailableTunName() (string, error) {\n\tinterfaces, err := net.Interfaces()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fail to get system interface information: %w\", err)\n\t}\n\n\tusedNames := make(map[string]struct{}, len(interfaces))\n\tfor _, iface := range interfaces {\n\t\tusedNames[iface.Name] = struct{}{}\n\t}\n\n\tstartIndex, err := randomInt(minTunIndex, maxTunIndex)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"fail to generate valid tun name: %w\", err)\n\t}\n\n\trangeSize := maxTunIndex - minTunIndex + 1\n\n\tfor offset := 0; offset < rangeSize; offset++ {\n\t\tindex := minTunIndex + (startIndex-minTunIndex+offset)%rangeSize\n\t\tname := tunNamePrefix + strconv.Itoa(index)\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/tun.go#L49-L85","documentation":"GetAvailableTunName enumerates system network interfaces with net.Interfaces() to find a free utun name; failure at the syscall/OS level is wrapped here. It means the process could not even list interfaces, before any name allocation is attempted.","triggerScenarios":"Running with tun inbound enabled on a system where interface enumeration fails: restricted containers/sandboxes without netlink or sysctl access, broken /proc or /sys mounts, or unusual capability drops.","commonSituations":"Docker with an overly restrictive seccomp/capabilities profile; minimal rootfs containers (no /sys/class/net); chroot environments; macOS sandbox-exec profiles denying network syscalls.","solutions":["Check the wrapped err for the OS-level cause","In containers: run with host network namespace or ensure /sys and netlink are available; add NET_ADMIN capability if creating TUN","On hosts: verify `ip link` or `ifconfig` works as the same user","If TUN is not needed, remove the tun inbound from the config"],"exampleFix":"# before: docker run --security-opt seccomp=strict ...\n# after: allow interface enumeration and TUN creation\ndocker run --cap-add NET_ADMIN --sysfs /sys ... xray","handlingStrategy":"try-catch","validationCode":"// pre-flight: confirm interface enumeration works in this environment\nif _, err := net.Interfaces(); err != nil {\n    return fmt.Errorf(\"environment cannot enumerate interfaces; TUN inbound unsupported here: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"name, err := conf.GetAvailableTunName()\nif err != nil {\n    if strings.Contains(err.Error(), \"fail to get system interface information\") {\n        // environment problem, not name exhaustion: surface ops action\n        log.Fatal(\"cannot enumerate network interfaces — check container caps / /sys mounts: \", err)\n    }\n    log.Fatal(err)\n}","preventionTips":["In containers, run with NET_ADMIN and a usable /sys","Smoke-test `ip link` as the xray user before enabling tun inbound"],"tags":["tun","network","os","permissions"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}