{"record":{"id":"344db1b3c59f3409","repo":"docmirror/dev-sidecar","slug":"ipv6-ip-enetunreach-ipv6-dns","errorCode":null,"errorMessage":"IPv6 地址 ${ip} 多次不可达（ENETUNREACH），已自动禁用 IPv6 DNS 解析","messagePattern":"IPv6 地址 (.+?) 多次不可达（ENETUNREACH），已自动禁用 IPv6 DNS 解析","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mitmproxy/src/lib/dns/base.js","lineNumber":30,"sourceCode":"  for (const name of Object.keys(nets)) {\n    for (const info of nets[name]) {\n      if (!info.internal && info.family === 'IPv6' && !info.address.startsWith('fe80:')) {\n        return false\n      }\n    }\n  }\n  log.info('未检测到可用的 IPv6 网络接口，将过滤所有 IPv6 DNS 解析结果')\n  return true\n})()\n\n// 运行时兜底：累计 3 次 IPv6 ENETUNREACH 后，认为上游 IPv6 不可达\nlet ipv6ErrCount = 0\nfunction reportIPv6Error (ip) {\n  if (!isIPv6(ip) || ipv6Unavailable) return\n  ipv6ErrCount++\n  if (ipv6ErrCount >= 3) {\n    ipv6Unavailable = true\n    log.warn(`IPv6 地址 ${ip} 多次不可达（ENETUNREACH），已自动禁用 IPv6 DNS 解析`)\n  }\n}\nmodule.exports.reportIPv6Error = reportIPv6Error\n\nfunction mapToList (ipMap) {\n  const ipList = []\n  for (const key in ipMap) {\n    const value = ipMap[key]\n    if (value && value !== 'false' && value !== '0') { // 配置为 ture 时才生效\n      ipList.push(key)\n    }\n  }\n  return ipList\n}\n\nconst defaultCacheSize = 1024\n\nclass IpCache extends DynamicChoice {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/mitmproxy/src/lib/dns/base.js#L12-L48","documentation":"The DNS subsystem tracks failures to reach IPv6 addresses. After 3 reported IPv6 errors (typically ENETUNREACH from connect attempts), the module sets a module-level flag `ipv6Unavailable = true` and permanently stops selecting IPv6 DNS addresses for the lifetime of the process, logging this warning once.","triggerScenarios":"Any DNS lookup path calling reportIPv6Error(ip) from onFree/connect failover when a preset or resolved AAAA address fails with ENETUNREACH three times, on a host/stack with no working IPv6 route.","commonSituations":"Machines or VPNs with IPv6 disabled at the kernel or router level while DNS config (e.g. pre-set ip lists) still contains AAAA addresses; Docker default bridge (no IPv6); corporate networks without IPv6.","solutions":["Remove IPv6 addresses (AAAA entries) from the DNS pre-set ip lists in config so only IPv4 servers are tried.","Enable IPv6 connectivity on the host/network, or accept the auto-disable (it is the intended mitigation and speeds up lookups).","Restart the proxy process after fixing IPv6 connectivity — the `ipv6Unavailable` flag is not reset at runtime."],"exampleFix":"// before (config)\n\"dnsMap\": { \"aliyun\": { \"ips\": [\"2400:3200::1\", \"223.5.5.5\"] } }\n// after\n\"dnsMap\": { \"aliyun\": { \"ips\": [\"223.5.5.5\"] } }","handlingStrategy":"validation","validationCode":"const ips = dnsConfig?.ips || []\nif (ips.some(ip => ip.includes(':'))) console.warn('IPv6 entries present; disable them if host has no IPv6 route')","typeGuard":"const isIPv6 = (s) => typeof s === 'string' && /^[0-9a-fA-F:]+$/.test(s) && s.includes(':')","tryCatchPattern":null,"preventionTips":["Only put AAAA/IPv6 addresses in DNS ip lists if the host has verified IPv6 connectivity","Test `curl -6 https://test-ipv6.com` style connectivity before enabling IPv6 DNS","Remember the disable flag is per-process; restart after network changes"],"tags":["dns","ipv6","enetunreach","network"],"backgroundTag":"ipv6-unreachable","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}