{"record":{"id":"f4dc8a739111abd4","repo":"txthinking/brook","slug":"no-ipv6-from-nic","errorCode":null,"errorMessage":"no ipv6 from nic","messagePattern":"no ipv6 from nic","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/dialwithnic/dialwithnic.go","lineNumber":49,"sourceCode":"\treturn d\n}\n\nfunc (p *DialWithNIC) IP(v46 string) (net.IP, error) {\n\tief, err := net.InterfaceByName(p.NIC)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\taddrs, err := ief.Addrs()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif v46 == \"6\" {\n\t\tfor _, v := range addrs {\n\t\t\tif v.(*net.IPNet).IP.IsGlobalUnicast() && v.(*net.IPNet).IP.To4() == nil {\n\t\t\t\treturn v.(*net.IPNet).IP, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, errors.New(\"no ipv6 from nic\")\n\t}\n\tif v46 == \"4\" {\n\t\tfor _, v := range addrs {\n\t\t\tif v.(*net.IPNet).IP.IsGlobalUnicast() && !v.(*net.IPNet).IP.IsPrivate() && v.(*net.IPNet).IP.To4() != nil {\n\t\t\t\treturn v.(*net.IPNet).IP, nil\n\t\t\t}\n\t\t}\n\t\tfor _, v := range addrs {\n\t\t\tif v.(*net.IPNet).IP.IsGlobalUnicast() && v.(*net.IPNet).IP.IsPrivate() && v.(*net.IPNet).IP.To4() != nil {\n\t\t\t\treturn v.(*net.IPNet).IP, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, errors.New(\"no ipv4 from nic\")\n\t}\n\treturn nil, errors.New(\"black hole\")\n}\n\nfunc (p *DialWithNIC) TouchBrook() {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/plugins/dialwithnic/dialwithnic.go#L31-L67","documentation":"The DialWithNIC plugin's IP method enumerates the local interface's addresses (addrs) to pick a source IP for dialing. When v46 == \"6\", it scans the list for a globally-unicast, non-IPv4 (IPv6) address; this error means no address in the list matched, so no usable global IPv6 source address exists on the selected NIC. The library throws it instead of dialing with a link-local or absent IPv6 address.","triggerScenarios":"Calling IP(v46=\"6\") (directly or via DialWithNIC's TouchBrook wiring) when the interface's addr list contains no global unicast IPv6 address — e.g. only IPv4 or only link-local fe80:: addresses — typically because the host/NIC has no global IPv6 connectivity.","commonSituations":"Running on an IPv4-only host, VM, or container; IPv6 disabled via kernel sysctls (disable_ipv6=1) or missing router advertisement; Docker/Kubernetes pods without IPv6 enabled; the chosen NIC has IPv6 but only link-local addresses.","solutions":["Enable global IPv6 on the host/interface (check `ip -6 addr`, router advertisements, SLAAC/DHCPv6) so a global unicast address exists.","If IPv6 is unavailable, configure the plugin for IPv4 instead (pass v46=\"4\") or use the plain dialer without a source-NIC constraint.","Inspect interface addresses with net.InterfaceAddrs() to confirm which families are present before selecting v46.","Fall back gracefully in the caller: treat this error as 'no IPv6 connectivity' and retry over IPv4."],"exampleFix":"// before\nip, err := plugin.IP(\"6\") // fails on IPv4-only host\n// after\nip, err := plugin.IP(\"6\")\nif err != nil {\n    ip, err = plugin.IP(\"4\") // fall back to IPv4\n}","handlingStrategy":"fallback","validationCode":"func hasGlobalIPv6() bool {\n    for _, a := range interfaceAddrs() {\n        if ipnet, ok := a.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() && ipnet.IP.To4() == nil {\n            return true\n        }\n    }\n    return false\n}\n// only call plugin.IP(\"6\") if hasGlobalIPv6()","typeGuard":"func isGlobalIPv6(ip net.IP) bool {\n    return ip.IsGlobalUnicast() && ip.To4() == nil\n}","tryCatchPattern":"ip, err := plugin.IP(\"6\")\nif err != nil && err.Error() == \"no ipv6 from nic\" {\n    log.Println(\"no global IPv6 on NIC, falling back to IPv4\")\n    ip, err = plugin.IP(\"4\")\n}","preventionTips":["Probe net.InterfaceAddrs() for a global unicast IPv6 address before requesting IPv6 dialing.","Ensure hosts/containers have IPv6 enabled (sysctl net.ipv6.conf.all.disable_ipv6=0, RA/SLAAC working).","Treat this error as 'no IPv6 connectivity' and design callers to degrade to IPv4 (Happy Eyeballs style).","In Kubernetes/Docker, enable IPv6 in the network stack if IPv6 egress is required."],"tags":["go","network","ipv6","nic"],"backgroundTag":"resource-not-found","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}