首页 文章

IPv6地址分配

提问于
浏览
6

我刚开始使用IPv6,所以在过去的几天里我做了很多阅读 . 不幸的是,我的一些问题在我的研究中没有得到解答 .

我的目标是跟踪分配的地址以及分配的接口 . 根据我的阅读,接口可以通过几种方式获取IPv6地址,我在下面的子部分中列出了这些方法 . 我已经突出了我到目前为止所发现的内容,并在这些部分提出了一些问题 . 如果有人可以对我学到的内容进行任何更正,或者对问题有答案,请这样做 . 如果有人知道某个地方我可以找到更多信息,我不介意自己研究它 .

Edit: 我发现Prefix Delegation实际上并没有导致地址分配 . DHCP服务器使用它来获取要从其他DHCP服务器使用的前缀 .


获取IPv6地址的方法有:

  • StateLess地址自动配置(SLAAC)

  • 有状态DHCPv6

SLAAC

SLAAC用于小型网络,为接口生成IPv6地址 . 它需要(几乎)没有配置,基本上如下工作:

  • 当接口联机时,客户端将使用其接口ID地址和链接本地前缀( FE80::/10 )生成链路本地IPv6地址 .

  • 要验证此地址是唯一的,会向该地址发送Neighbor Solicitation( NS )消息 . 如果有回复,则该地址正在使用中且无法使用 . 自动配置中止,配置应手动进行 . Question 1a: Is there really no fall back here?

  • 假设在超时时间段结束时没有收到回复,则假定该地址是唯一的,并将其指定为接口的链路本地地址 .

Now the node has connectivity to all other nodes on this link

  • 节点等待接收路由器通告( RA ),或者向所有路由器的多播组发送路由器请求( RS )消息 . 当路由器收到 RS 时,它将以 RA 响应 . RA 将包含前缀 .

  • 该节点将生成带有前缀及其接口ID的全球单播地址 .

  • 类似于创建链接本地地址时,节点将向该地址发送消息以确定它是否是唯一的 . Question 2: Is this also an NS message? 如果有回复,则该地址已被使用,地址分配必须手动进行 . Question 1b: Again, is there any automated way to recover?

  • 假设超时内没有回复,则将该地址指定为接口的全局IPv6地址 .

Question 3: It is possible to have more than one address for the interface. In fact, at the end of the above process, a single interface will have 2 addresses - a link-local one and a global unicast one. Is it possible to get additional addresses for this interface using SLAAC? Or must another method (e.g. DHCPv6) be used?

有状态DHCPv6

节点可以使用上面的步骤1-3获得链路本地地址 . 我相信这是可选的,它可以简单地在DHCP请求中使用 ::/128 (未指定)作为其源地址,直到为其分配地址 .

有两种获取地址的方法 - 正常和快速提交 . Normal是4消息交换( SolicitAdvertiseRequestReply ),Rapid是2消息交换( SolicitReply ) . 当客户端在 Solicit 消息中使用 Rapid-Commit 选项请求快速提交时 . 它与Normal基本相同,因为它对我的使用没有任何影响,我现在暂时忽略它 .

此外,消息可能通过中继进行代理 . 从中继发送到服务器的消息是 RELAY_FORW 消息,从服务器发送到中继的消息是 RELAY_REPL 消息 . 客户端和服务器之间的实际对话框完全封装在 OPTION_RELAY_MSG 选项中 . 对于以下内容,我只处理非中继消息 . 如果消息被中继,则很容易对原始消息进行说明,并且以下内容仍然成立 .

地址分配如下:

  • 客户端向"All DHCP Servers and Relays"多播地址发送 Solicit 消息 . 此消息的目的是发现本地链路上的DHCP服务器的标识 .

  • DHCP服务器以 Advertise 消息响应本地多播地址 .

  • 客户端直接向DHCP服务器发送 Request 消息,其中的选项指示它希望拥有IP地址 . Question 4: In the PCAP files I've seen, it looks like this message is still sent to the multicast address ff02::1:2. Any reason that this is not sent directly to the DHCP server from which the Advertise was received?

  • DHCP服务器以包含IP地址的 Reply 进行响应 .

  • 客户端应执行类似于SLAAC方法中步骤6的重复地址检测 .

  • 节点将此地址分配给接口,并可以开始使用它 .

这是一般的分配地址的方法,但更具体地说,有3种方法可以完成:

  • 非临时地址分配( IA_NA

  • 临时地址分配( IA_TA

  • 前缀授权( PD

所有这三种方法都是通过在 Request 中包含一个选项来完成的,该选项随后由服务器填充并返回 Reply . 对于前两个,返回完整的IPv6地址,然后可以将其分配为接口的IP地址 . 对于第三个,返回类似于SLAAC方法中的 RA 的前缀 . 然后,此前缀与接口标识符一起使用,以创建完整的全局IPv6地址 .

Question 5: In my pcap captures, I am seeing that the Solicit and Advertise often contain these options as well. This seems redundant in the non-rapid case since the Request and subsequent Reply must also contain the option. What is the purpose for including this option in the Solicit? And what is the purpose of the DHCP server creating the IP address (or prefix) in the Advertise before being Requested to do so?

Question 6: The RFCs indicate that multiple instances of the IA_NA (or IA_TA) option can be included. I assume this means that the interface will then have multiple addresses. Does the client simply include multiple instances of the option in the Request to get multiple addresses? What happens if a DHCP server can supply some, but not all of the addresses? Does the entire Reply indicate a failure? Or are some addresses given?


释放地址

对于DHCPv6,可以使用 Release 消息释放正在使用的地址 . 客户端可以使用 Decline 消息拒绝服务器在 Reply 中分配的地址,而不是使用该地址 .

如果客户端无法发送 ReleaseDecline ,则服务器将继续保留客户端的地址,直至其过期 .

Question 7: If a client can't send the Release (or Decline) and reboots, it will initiate a new DHCP request. Will the DHCP server give back the old address? Or will it assume this is a request for an additional IP address and assign a new one?

我不确定如何释放SLAAC或DHCP PD 创建的地址 . 也许这些地址的发布只在内部完成,没有外部设备需要知道该事件 .


正如我在开始时所说,我的目标是跟踪当前有效的所有地址分配 . 我的计划是做以下事情:

  • 创建一个由地址索引的映射,该映射存储分配给它的客户端(DUID) .

  • 在收到带有 Rapid-CommitRequestConfirmRenewRebindSolicit 的DHCPv6 Reply 时,请执行以下操作:

  • 解压缩 Client-DUID 选项

  • 对于每个 IA_NAIA_TA

  • 对于每个 IA ,设置 map[address]=Client-DUID

  • 存储地址的到期时间

  • 收到 DeclineReplyRelease 时,请执行以下操作

  • 对于每个 IA_NAIA_TA

  • 对于每个 IA ,设置删除 map[address]

  • 当地址过期时,它将从 Map 中删除

Question 8: How do I detect SLAAC generated addresses or DHCP PD addresses? Is there some field in the messages I can use to regenerate the complete IP address? I will already have the prefix, but the interface ID is unknown.

这是否足以维护分配给客户端的IP地址列表?

2 回答

  • 0

    好的 - 所以我做了更多的研究,现在我得到了大部分答案 .

    首先,纠正 . 使用DHCP无法通过 PD 获取地址 . 这就是DHCP服务器获取网络前缀以用于它们托管的DHCP客户端的方式 . 还有另一个DHCP服务器处理分发这些前缀 . 因此,可以忽略 PD 作为获得IP地址的方法 .


    Question 1a/b: Is there really no fall back here?

    答:没有自动回退机制 . 一个可以实现,但它将是自定义的 .

    Question 2: Is this also an NS message?

    答:是的

    Question 3: It is possible to have more than one address for the interface. In fact, at the end of the above process, a single interface will have 2 addresses - a link-local one and a global unicast one. Is it possible to get additional addresses for this interface using SLAAC? Or must another method (e.g. DHCPv6) be used?

    答:可以使用SLAAC生成多个地址 . 客户端可以使用来自多个路由器的路由器通告,并且每个路由器可以通告多个前缀 . 主机可以使用每个前缀来创建全局单播地址 .

    Question 8 (modified): How do I detect SLAAC generated addresses? Is there some field in the messages I can use to regenerate the complete IP address? I will already have the prefix, but the interface ID is unknown.

    答:检测它们的唯一方法是收听 NS 消息 . 由于这些消息是可选的,因此无法保证检测SLAAC生成的地址 .


    对于问题4-7我仍然没有答案,但我现在不太关心它们 .

    谢谢!!

  • 1

    第三种方法是获取IPv6地址,手动配置 .

相关问题