windows10 ipv6 测试 ipv4 优先级 发表于 2025-07-19 | 分类于 Windows | 暂无评论 直接访问 [ipw.cn](https://ipw.cn/ "ipw.cn") 会显示你的IPV4和IPV6地址,并提示哪个优先 ```shell # 查询本机外网IPv4地址 curl 4.ipw.cn # 查询本机外网IPv6地址 curl 6.ipw.cn # 测试网络是IPv4还是IPv6访问优先(访问IPv4/IPv6双栈站点,如果返回IPv6地址,则IPv6访问优先) curl test.ipw.cn ``` ipw.cn 是IPv4/IPv6 双栈站点,使用 ping 命令默认会访问到 IPv6站点,如果特别指定 IPv4(ping -4)才会解析到 IPv4 站点。 ```shell Microsoft Windows [版本 10.0.19044.1766] (c) Microsoft Corporation。保留所有权利。 C:\Windows\system32>ping ipw.cn 正在 Ping ipw.cn [2402:4e00:40:40::2:3b6] 具有 32 字节的数据: 来自 2402:4e00:40:40::2:3b6 的回复: 时间=13ms 来自 2402:4e00:40:40::2:3b6 的回复: 时间=18ms 来自 2402:4e00:40:40::2:3b6 的回复: 时间=10ms 来自 2402:4e00:40:40::2:3b6 的回复: 时间=16ms 2402:4e00:40:40::2:3b6 的 Ping 统计信息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 10ms,最长 = 18ms,平均 = 14ms C:\Windows\system32>ping -4 ipw.cn 正在 Ping ipw.cn [106.55.75.123] 具有 32 字节的数据: 来自 106.55.75.123 的回复: 字节=32 时间=8ms TTL=52 来自 106.55.75.123 的回复: 字节=32 时间=7ms TTL=52 来自 106.55.75.123 的回复: 字节=32 时间=9ms TTL=52 来自 106.55.75.123 的回复: 字节=32 时间=7ms TTL=52 106.55.75.123 的 Ping 统计信息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 7ms,最长 = 9ms,平均 = 7ms ``` 查看网络前缀访问优先级 ```shell C:\Windows\system32>netsh interface ipv6 show prefixpolicies 查询活动状态... 优先顺序 标签 前缀 ---------- ----- -------------------------------- 50 0 ::1/128 40 1 ::/0 35 4 ::ffff:0:0/96 ``` 首先 Windows10/11 中默认的访问前缀规则是参照 RFC6724: Default Address Selection for Internet Protocol Version 6 (IPv6) 实现的。 ```shell 在 IANA IPv6 Special-Purpose Address Registry 中我们可以找到这些前缀的分配归属。 ::1/128:本地回环地址,类似 IPv4 中的 127.0.0.1 ::/0: IPv6 单播地址 ::ffff:0:0/96: IPv4 地址范围 ``` 调整网络前缀优先级,让 IPv4 访问优先 ```shell C:\Windows\system32>netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 100 4 确定。 C:\Windows\system32>netsh interface ipv6 add prefixpolicy ::/0 40 1 确定。 C:\Windows\system32>netsh interface ipv6 show prefixpolicies 查询活动状态... 优先顺序 标签 前缀 ---------- ----- -------------------------------- 100 4 ::ffff:0:0/96 50 0 ::1/128 40 1 ::/0 执行 ping 、curl 命令验证,确实默认 IPv4 访问优先。 C:\Windows\system32>ping ipw.cn 正在 Ping ipw.cn [106.55.75.123] 具有 32 字节的数据: 来自 106.55.75.123 的回复: 字节=32 时间=14ms TTL=52 来自 106.55.75.123 的回复: 字节=32 时间=29ms TTL=52 来自 106.55.75.123 的回复: 字节=32 时间=14ms TTL=52 来自 106.55.75.123 的回复: 字节=32 时间=14ms TTL=52 106.55.75.123 的 Ping 统计信息: 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 14ms,最长 = 29ms,平均 = 17ms C:\Windows\system32>curl -v https://ipw.cn -I * Trying 106.55.75.123:443... 重置 IPv6 策略 C:\Windows\system32>netsh interface ipv6 reset ``` 转载地址: >https://ipw.cn/ >https://ipw.cn/doc/ipv6/user/ipv4_ipv6_prefix_precedence.html