{"record":{"id":"e62e122266adb655","repo":"v2rayA/v2rayA","slug":"default-interfaces-not-found","errorCode":null,"errorMessage":"default interfaces not found","messagePattern":"default interfaces not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"service/common/netTools/interface.go","lineNumber":9,"sourceCode":"package netTools\n\nimport (\n\t\"fmt\"\n\t\"os/exec\"\n\t\"strings\"\n)\n\nvar NoDefaultInterface = fmt.Errorf(\"default interfaces not found\")\n\n// only for linux\nfunc GetDefaultInterfaceName() ([]string, error) {\n\tb, err := exec.Command(\"sh\", \"-c\", \"awk '$2 == 00000000 { print $1 }' /proc/net/route\").Output()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tifnames := strings.Split(strings.TrimSpace(string(b)), \"\\n\")\n\tif len(ifnames) == 1 && ifnames[0] == \"\" {\n\t\treturn nil, NoDefaultInterface\n\t}\n\treturn ifnames, nil\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/common/netTools/interface.go#L1-L23","documentation":"NoDefaultInterface is a sentinel error returned by GetDefaultInterfaceName (Linux only). It parses /proc/net/route for routes whose destination is 00000000 (the default route); if none are found the resulting interface list is empty and the sentinel is returned.","triggerScenarios":"Calling GetDefaultInterfaceName on a Linux system with no default route in /proc/net/route.","commonSituations":"Container or VM without a default gateway; machine with only link-local networking; interface down or DHCP not yet completed at startup.","solutions":["Bring up the network interface and ensure a default route exists (dhclient / ip route add default via <gw>)","Wait/retry until the network is up before calling (common at boot in containers)","Add a default route manually if static networking is intended","Verify with `awk '$2 == 00000000 {print $1}' /proc/net/route` locally"],"exampleFix":"// before (docker run)\ndocker run --network none myimage\n// after\ndocker run --network bridge myimage","handlingStrategy":"retry","validationCode":"b, _ := os.ReadFile(\"/proc/net/route\")\nif !strings.Contains(string(b), \"00000000\") {\n    return fmt.Errorf(\"no default route yet; wait for network\")\n}","typeGuard":"func hasDefaultRoute() bool {\n    b, err := os.ReadFile(\"/proc/net/route\")\n    return err == nil && strings.Contains(string(b), \"00000000\")\n}","tryCatchPattern":"ifnames, err := netTools.GetDefaultInterfaceName()\nif errors.Is(err, netTools.NoDefaultInterface) {\n    // wait/retry until network is up\n    time.Sleep(2 * time.Second)\n    return retry()\n}","preventionTips":["Retry with backoff at boot before network is ready","Ensure the container has a network mode providing a gateway","Check /proc/net/route manually when debugging"],"tags":["linux","network","routing"],"backgroundTag":"no-default-route","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}