V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MuJian
V2EX  ›  宽带症候群

Win10 多个 IPV6 地址源地址的选择还是搞不明白,求指点!

  •  
  •   MuJian · 182 天前 · 1083 次点击
    这是一个创建于 182 天前的主题,其中的信息可能已经有所发展或是发生改变。
    默认情况下,Win10 获取到 ipv6 前缀后,生成一个临时和一个公用地址,先禁用临时地址 netsh interface ipv6 set privacy state=disable 。

    这时 Win10 有一个公用 ipv6 地址 2408:xxxx:xxxx:xxxx:a:b:c:d ;手动指定一个 IPV6 地址 2408:xxxx:xxxx:xxxx::9
    现在虽然 win10 有了 2 个 ipv6 地址,一个公用,一个手动,但是 win10 默认使用公用 ipv6 作为源地址通讯,希望是用手动 ipv6 地址作为源地址。

    搜索知道这个源地址选择受 RFC3484 控制,规则有 8 条;
    Rule 1: 优选与目标地址相同的地址
    Rule 2: 优选其 scope 与目标地址 scope 相比更接近且 scope 更大的地址
    Rule 3: 优选"preferred" 地址
    Rule 4: 优选 home 地址
    Rule 5: 优选和路由出口在同一块网卡上配置的地址
    Rule 6: 优选 Label 匹配的地址
    Rule 7: 优选非临时/临时地址(可配置)
    Rule 8: 优选和目标地址最长前缀匹配的地址


    在当前情况下规则 1 不适用;
    规则 2 没看太明白,scope 应该是范围的意思吧?感觉当前情况下,同前缀的 2 个 ipv6 地址范围应该是一样的吧?
    规则 3 ,两个地址都是首选地址,应该是一样的;
    规则 4 ,优选 home 地址 我查了很久也没明白啥是 home 地址?

    英文规范里貌似说这是移动设备的?

    1. Introduction

    The IPv6 addressing architecture [1] allows multiple unicast
    addresses to be assigned to interfaces. These addresses may have
    different reachability scopes (link-local, site-local, or global).
    These addresses may also be "preferred" or "deprecated" [2]. Privacy
    considerations have introduced the concepts of "public addresses" and
    "temporary addresses" [3]. The mobility architecture introduces
    "home addresses" and "care-of addresses" [8]. In addition, multi-
    homing situations will result in more addresses per node. For
    example, a node may have multiple interfaces, some of them tunnels or
    virtual interfaces, or a site may have multiple ISP attachments with
    a global prefix per ISP.

    The end result is that IPv6 implementations will very often be faced
    with multiple possible source and destination addresses when
    initiating communication. It is desirable to have default

    3.5. Mobility Addresses

    Some nodes may support mobility using the concepts of a home address
    and a care-of address (for example see [8]). Conceptually, a home
    address is an IP address assigned to a mobile node and used as the
    permanent address of the mobile node. A care-of address is an IP
    address associated with a mobile node while visiting a foreign link.
    When a mobile node is on its home link, it may have an address that
    is simultaneously a home address and a care-of address.

    For the purposes of this document, it is sufficient to know whether
    or not one's own addresses are designated as home addresses or care-
    of addresses. Whether or not an address should be designated a home
    address or care-of address is outside the scope of this document.

    还给了例子
    Destination: 2001::1
    Candidate Source Addresses: 2001::2 (care-of address) or 3ffe::2
    (home address)
    Result: 3ffe::2 (prefer home address)

    Destination: 2002:836b:2179::1
    Candidate Source Addresses: 2002:836b:2179::d5e3:7953:13eb:22e8
    (temporary) or 2001::2
    Result: 2002:836b:2179::d5e3:7953:13eb:22e8 (prefer matching label)

    Destination: 2001::d5e3:0:0:1
    Candidate Source Addresses: 2001::2 or 2001::d5e3:7953:13eb:22e8
    (temporary)
    Result: 2001::2 (prefer public address)


    规则 5: 优选和路由出口在同一块网卡上配置的地址,这都是一个网卡上的地址,应该一样;

    规则 6: 优选 Label 匹配的地址
    网上搜索的信息,貌似都是在这个上做文章

    netsh interface ipv6 show prefixpolicies 显示

    优先顺序 标签 前缀
    ---------- ----- --------------------------------
    50 0 ::1/128
    45 1 2408:821b:2221:6dd0::9/128
    40 1 ::/0
    35 4 ::ffff:0:0/96
    30 2 2002::/16
    5 5 2001::/32
    3 13 fc00::/7
    1 3 ::/96
    1 12 3ffe::/16
    1 11 fec0::/10

    手动添加一个 netsh interface ipv6 add prefixpolicy prefix=2408:xxxx:xxxx:xxxx::9/128 precedence=45 label=1 store=persistent

    理论上同 label 应该优先
    实际上这规则不生效,win10 还是使用公用 ipv6 地址作为源地址

    规则 7 ,已经禁用了临时地址,这个不适用吧?
    规则 8 优选和目标地址最长前缀匹配的地址
    这两个 ipv6 地址应该是一样的前缀

    研究了半天,一头雾水,不知道怎么搞,主要是我英文还是太差……

    PS:看到有人用 netsh interface ipv6 set interface "WLAN" routerdiscovery=disable store=persistent
    禁用 ipv6 自动配置,这样就只剩下我们配置的手动 ipv6 地址,这样确实能够实现使用手动 ipv6 地址的目的,但是上有 ipv6 前缀变化的时候,win10 也就感知不到了,还是不完美,所以没用这个。

    求高人指点!
    4 条回复    2024-05-17 13:22:20 +08:00
    jqknono
        1
    jqknono  
       182 天前
    提炼下问题重点
    MuJian
        2
    MuJian  
    OP
       182 天前
    @jqknono 重点是如何让 Win10 用 手动 ipv6 地址 作为源地址访问网络。
    jqknono
        3
    jqknono  
       182 天前
    @MuJian
    把手动 ipv6 的 route metric 改小一点, 小于自动 ipv6 就行

    ```ps1
    # 查看
    netsh interface ipv6 show route
    # 修改
    netsh interface ipv6 set route {ipv6}/128 interface=29 metric=256
    ```
    MuJian
        4
    MuJian  
    OP
       182 天前
    @jqknono 这个没用的,早就试过,刚又测试了一下,无效的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1039 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 22:42 · PVG 06:42 · LAX 14:42 · JFK 17:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.