IPv6 地址分类、地址格式及其寻址方式


An Internet Protocol Version 6 address (IPv6 address) is a numeric label that is used to identify and locate a network interface of a computer or a network node participating in a computer network using IPv6. IP addresses are included in the packet header to indicate the source and the destination of each packet. The IP address of the destination is used to make decisions about routing IP packets to other networks.

IPv6 is the successor to the first addressing infrastructure of the Internet, Internet Protocol version 4 (IPv4). In contrast to IPv4, which defined an IP address as a 32-bit value, IPv6 addresses have a size of 128 bits. Therefore, in comparison, IPv6 has a vastly enlarged address space.


Addressing methods寻址方法[edit]

IPv6 addresses are classified by the primary addressing and routing methodologies common in networking: unicast addressing, anycast addressing, and multicast addressing.[1]

A unicast address identifies a single network interface. The Internet Protocol delivers packets sent to a unicast address to that specific interface.

An anycast address is assigned to a group of interfaces, usually belonging to different nodes. A packet sent to an anycast address is delivered to just one of the member interfaces, typically the nearest host, according to the routing protocol's definition of distance. Anycast addresses cannot be identified easily, they have the same format as unicast addresses, and differ only by their presence in the network at multiple points. Almost any unicast address can be employed as an anycast address.

A multicast address is also used by multiple hosts that acquire the multicast address destination by participating in the multicast distribution protocol among the network routers. A packet that is sent to a multicast address is delivered to all interfaces that have joined the corresponding multicast group. IPv6 does not implement broadcast addressing. Broadcast's traditional role is subsumed by multicast addressing to the all-nodes link-local multicast group ff02::1. However, the use of the all-nodes group is not recommended, and most IPv6 protocols use a dedicated link-local multicast group to avoid disturbing every interface in the network.

根据路由和寻址方式的不同,IPv6地址可以分为:单播地址任播地址 多播地址;

单播地址 用于标识 一个单一的 网络接口; IP协议 将被送往该单播地址 的 所有数据包 都传送 到  这个 具体的 网络接口上。

任僠地址  分配给一组网络接口,通常这些接口分别 属于不同的节点。被送往该任播地址 的 数据包, 将仅被传送到该组接口中的一个接口上,具体是哪个接口,通常是根据路由协议定义确定的最近的那个主机/接口。 任播地址不容易被识别,因为他们与单播地址 有着相同的格式,只有根据他们在网络中多点的存在才能区分(当不特地指明一个单播地址是否是任播地址时,仅凭其格式,你无法区别到底是不是任播地址,因为任播地址与单播地址有着相同的格式)。几乎任意单播地址 都可以用作任播地址;
【任播地址  也叫 共享单播 地址,一组网络接口有相同的 IPv6地址,送往该地址的数据包只会发送给其中的一个接口,通常是按路由协议计算出来的最近的主机】

多播地址 也是用于一组主机,这些主机需要这种 多播地址 用于参与到 不同网络路由器之间进行的 多播分发协议(多播寻址,用于支持主机参与网间路由分发)。发送给多播地址的数据包,将被传送到已加入到相应的多播组中的全部接口。IPv6 没有 广播寻址的概念,广播寻址的传统角色在IPv6中由 多播寻址 取代,多播寻址将数据包路由到 link-local 多播组 ff02::1中的全部节点。但是,在通常情况下,该包括所有节点的多播组ff02::1 不建议使用,多数的IPv6协议都使用一个专门的link-local 多播组来代替,以避免打扰到该网络上的所有接口(主机)。 
【IPv6的多播功能类似于 IPv4的 组播,IPv6 没有广播寻址(因为同一个广播域可能网太大,主机太多,广播会引发消息风暴?)】

Address formats地址格式[edit]

An IPv6 address consists of 128 bits.[1] For each of the major addressing and routing methodologies, various address formats are recognized by dividing the 128 address bits into bit groups and using established rules for associating the values of these bit groups with special addressing features.

一个IPv6地址 由128 bit构成,在每类主要的寻址和路由协议/方法中 IPv6地址的128bit 会被区分为不同的 bit组(即IPv6地址的格式构成),各bit组中的 值 基于特定的映射规则 分别对应着不同的特殊寻址/路由特性。(不同格式的IPv6 对应着不同的 路由/寻址规则)


 



上图引用自:CSDN

 

一、Unicast and anycast address format单播和任播地址[edit]

Unicast and anycast addresses are typically composed of two logical parts: a 64-bit network prefix used for routing, and a 64-bit interface identifier used to identify a host's network interface.

单播 和 任播地址 通常由两个逻辑部分构成,即 一个用来路由的 64位的 网络前缀 和 一个用来标识主机网络接口的 64位 网络接口标识/接口ID
General unicast address format (routing prefix size varies) 通用单播地址格式(路由前缀的长度是可变的)
bits 48 (or more) 16 (or fewer) 64
field routing prefix subnet id interface identifier

The network prefix (the routing prefix combined with the subnet id) is contained in the most significant 64 bits of the address. The size of the routing prefix may vary; a larger prefix size means a smaller subnet id size. The bits of the subnet id field are available to the network administrator to define subnets within the given network. The 64-bit interface identifier is automatically established randomly, obtained from a DHCPv6 server, or assigned manually. (Historically, it was automatically generated from the interface's MAC address using the modified EUI-64 format, but this method is now deprecated for privacy reasons.)

General unicast address ,,也叫全局单播地址吧,global unicast addres (GUA)

网络前缀(路由前缀 + 子网ID)被包括在 这类地址最重要的 64 bit中。其中的 路由前缀 长度各异:大一点的路由前缀意味着小一些的子网ID 范围。网络管理员可以通过 子网ID 的bit位 在给定的网络中划分子网。64位的网络接口ID 是随机建立的,从DHCPv6服务器上获取到,或者,也可以手动分配。(在历史上,他是基于接口主机 的MAC地址  使用修正后的 EUI-64标准 自动生产的。这个方法基于MAC,通过特定逻辑,生成接口标识 ID, 出于隐私保护的原因 已经不建议使用此方法

1、单播地址

单播地址只能分配给一个节点上的一个接口,即寻址到该单播地址的数据报文最终会被发送到一个唯一的接口。

单播地址可以分为链路本地地址,站点本地地址可聚合全球单播地址(全球单播地址)、全球唯一本地地址(Unique local address )


单播地址结构
一个主机接口上的128位IPv6单笔地址一般可以被看做成一个整体来代表这台主机,而当要表示这个主机上的接口所连接的网络时,将这个128位IPv6单播地址分成两部分来表示:
其中各字段的含义如下:

Subnet Prefix:n位子网前缀(错矣!n实为网络前缀位数,包括了 路由前缀 位 和 子网ID 位。/表示法中斜线后面数字 通常为 路由前缀长度 ? ),表示接口所属的网络
Interface ID:接口标识,用以区分连接在一条链路上的不同接口。
【单播地址  和 任僠地址,通常按 4:4分,将 8个16位的 IPv6地址为分 一半一半,前半部分为 网络前缀,后半部分为 网络接口ID】

1.1 可聚合全球单播地址(全球单播地址)
IPv6公网地址,可聚合全球单播地址前缀的最高3位固定为001,其结构如下图所示:
其中各字段的含义如下:
Global Routing Prefix:全球可路由前缀,表示了站点所得到的前缀值全球可路由前缀是由IANA下属的组织分配给ISP或其他机构的,前3位是001。该部分包含有严格的等级结构,用以区分不同地区,不同等级的机构或者ISP,便于路由聚合。
Subnet ID:子网ID,表示全球可路由前缀所代表的站点内的子网。
Interface ID:接口标识,用于表示链路上不同的接口,并具有唯一性。接口ID可以有设备随机生成或手动配置,在以太网中还可以按EUI-64格式自动生成。
如:2000::/3, 2100::/3 ,3000::/3等,均是全球单播地址(可聚合全球单播地址)

1.2 全球唯一本地地址(又称 唯一本地地址)

Unique local addresses are addresses analogous to IPv4 private network addresses. 本地唯一地址  是 类似于 IPv4中的私有网络地址 的一类地址;这类地址网络前缀(IPv4中的网络号)是固定的,主要依赖网络接口部分的不同来 进行通信  和 主机识别

Unique local address format
bits 7 1 40 16 64
field prefix L random subnet id interface identifier

The prefix field contains the binary value 1111110. The L bit is one for locally assigned addresses; the address range with L set to zero is currently not defined. The random field is chosen randomly once, at the inception of the /48 routing prefix. 本球 唯一本地地址 的前缀部分包括了固定的 值: 1111 110,第8位 L位,为1表示本地分配,为0当前未定义;随机部分的40位,作为Global ID,它由 获取/48位路由前缀时随机生成。【因此,本地IPv6局域网地址,均为 FCxx::/7, 前面8位用十六进制表示时固定为 FC,紧接着后面一个8位 的十六进制默认使用 00,


唯一本地地址
唯一本地赋值的结构如下图所示:

其中各字段的含义如下:
1)固定前缀为FC00::/7    如, FC00:0:0:0001::/7   ----->这表示本地 局域网中,子网ID为 0001 的一个网段,该网段即使路由泄露 到公网,也不会与其他局域网的地址产生冲突,因为有一个40位的 Blobal ID;(严格来说全球本地唯一地址前缀是 FCxx::/7,如在资源规划工具中 给出的本地IPv6地址即是默认的 FC01::/7 网段的地址示例)
2)L:表示地址的范围,如果取值为1,表示本地范围,0保留
3)Global ID:全球唯一前缀,随机方式生成
4)Subnet ID:划分子网时使用

唯一本地地址具有以下特性:
1)具有全球唯一前缀
2)可用于构建VPN
3)具有众所知周的前缀,边界路由器可以很容易对其过滤
4)其地址与ISP分配的地址无关,任何人都可以随意使用
5)一旦出现路由泄露,不会与Internet路由产生冲突,因为其是全球唯一的
6)在应用中,上层协议将其当成全球单播地址对待,简化上层协议


1.3 链路本地地址()

A link-local address is also based on the interface identifier, but uses a different format for the network prefix. 与本地唯一地址一样,链路本地地址,也是基于 网络接口部分 来工作的,但是它的网络前缀 与 本地唯一地址还是不一样的。如下:

Link-local address format
bits 10 54 64
field prefix zeroes interface identifier

The prefix field contains the binary value 1111111010. The 54 zeroes that follow make the total network prefix the same for all link-local addresses (fe80::/64 link-local address prefix), rendering them non-routable. 链路本地地址的 网络前缀 部分包括了 10位的 1111 1110 10 即 fe-10, 后边接着54位固定为 0,因此,固定前缀为 fe80::/64


链路本地地址
链路本地地址的应用范围受限,只能在连接到同一本地链路的节点之间使用,【即 链路本地地址不能被三层转发?可以理解为 比如,同一L2交换机下的各服务器之间 或 L3交换机下同一个VLAN内的主机之间(他们均在同一个LAN内) 可以用这个链路本地地址 实现相互通信, 处在同一广播域中。但一旦跨LAN网 或跨 VLAN 通信,涉及L3转发的,就不能再用 链路本地地址,因为L3设备不会转发/路由 目标地址为 链路本地地址 的数据包 】。
【同一本地链路,即同处一广播域的主机之间的链路】
【由以上 可知,在I层部署规划时,凡是涉及到 跨LAN/VLAN通信的,均需要配置 全球唯一本地地址,如果需要在L3上做网段隔离,在L3层面做好不同IPv6网段/子网的路由隔离即可(IPv6用链路代替了网段,子网等IPv4中的概念,如何配置IPv6地址之间的路由实现隔离,请参考:IPv6路由协议解析),如果同时希望L2广播域也能隔离,避免广播风暴,那么在L2层划分不同的VLAN 即可】


在IPv6邻居节点之间的通信协议中广泛使用了该地址,如邻居发现协议,动态路由协议等

链路本地地址有固定的格式,如下图所示:
链路本地地址由一个特定的前缀和接口ID两部分组成,它使用了特定的链路本地前缀FE80::/64,同事将接口ID添加在后面作为地址的低64位。
当一个节点启动IPv6协议栈时,节点的每个接口会配置一个链路本地地址。这种机制使得两个连接到同一链路的IPv6节点不需要做任何配置就可以通信。链路本地地址使用固定的前缀FE80::/64,接口ID部分使用EUI-64地址。

?----【同一L2交换机下的各服务器之间,或L3交换机的同一VLAN下的各服务器之间,不用配置就可以基于IPv6的 链路本地地址 实现L3通信,如何配置隔离?】
?----【同时,这也带来了 IPv6地址下的 VLAN之间的 隔离的问题吧?如何配置层3使用IPv6时的 L2的 不同VLAN间的隔离?
使用IPv4时,划分了VLAN之后,在L3交换机相应端口上给各VLAN增加L3子接口或配置VLANIF,才能实现各VLAN间的通信。
如果使用IPv6,是不是划了VLAN,但只要VLAN接口在同一L3交换机下,那VLAN之间 就默认是可以 基于 链路本地地址通信的?如何隔离这个?

站点本地地址

站点本地地址是另一种应用范围受限的地址,它只能在一个站点内使用。目前已被废弃,不再使用。


1.4 特殊地址
特殊地址主要有两类:未指定地址和环回地址。

未指定地址
全0,表示某一地址不可用,特别时在报文中的源地址为指定时使用。未指定地址不能用于目的地址。 ---->   ::/128
环回地址
与IPv4的127.0.0.1功能相同,只在节点内部有效。当路由器收到目的地址是其环回地址的报文时,不能再向链路上转发。 ---> ::1/128



2.任播地址
任播地址 与 全球单播地址 相同。仅通过地址本身,节点时无法区分任播地址和单播地址的
任播地址
IPv6特有的地址类型,用于标识一组网络接口。但是与组播地址不同,路由器会将目的地址为任播地址的数据报文,发送给距本路由器最近的一个网络即可。任播适合于“One-to-One-of-Many”的通信场合,接收方只要时一组接口中的任意一个即可。
任播地址从单播地址空间中进行分配,使用单播地址的格式。仅通过地址本身,节点时无法区分任播地址和单播地址的,所以,节点必须使用明确的配置而指明它是一个任播地址。目前,任播地址仅被用做目的地址,且仅分配给路由器。

接口上的IPv6地址
IPv6的一个优点就是在节点的一个接口上可以配置多个IPv6地址,包括单播地址,组播地址等。


二、Multicast address forma多播地址 格式/有些地方 也翻译为 组播[edit]

Multicast addresses are formed according to several specific formatting rules, depending on the application. 多播地址的结构格式 要看基体的格式规则而定,格式规则取决于特定的应用。

General multicast address format
bits 8 4 4 112
field prefix flg sc group ID

For all multicast addresses, the prefix field holds the binary value 11111111. 在所有的多播地址格式中,网络前缀 均固定为 1111 1111, 因此前缀固定为 FFxx::/8, 通常为 FF00::/8

Currently, three of the four flag bits in the flg field are defined;[1] the most-significant flag bit is reserved for future use. 当前,flag 4位中,后三位已定义,第1位预留给将来使用,具体如下;

Multicast address flags[2]
bit flag Meaning when 0 Meaning when 1
8 reserved reserved reserved
9 R (Rendezvous)[3] Rendezvous point not embedded Rendezvous point embedded
10 P (Prefix)[4] Without prefix information Address based on network prefix
11 T (Transient)[1] Well-known multicast address Dynamically assigned multicast address

The four-bit scope field (sc) is used to indicate where the address is valid and unique. sc 的4位,用来标识在什么范围内 本多播地址合法和唯一,如下表

In addition, the scope field is used to identify special multicast addresses, like solicited node. 同时,sc位也用于标识 一些 特殊的多播地址,如 solicited node.

Scope values[1]: 2.7 
Value Scope name Notes
0x0 reserved  
0x1 interface-local Interface-local scope spans only a single interface on a node, and is useful only for loopback transmission of multicast.
0x2 link-local Link-local scope spans the same topological region as the corresponding unicast scope.
0x3 realm-local Realm-local scope is defined as larger than link-local, automatically determined by network topology and must not be larger than the following scopes.[13]
0x4 admin-local Admin-local scope is the smallest scope that must be administratively configured, i.e., not automatically derived from physical connectivity or other, non-multicast-related configuration.
0x5 site-local Site-local scope is intended to span a single site belonging to an organisation.
0x8 organization-local Organization-local scope is intended to span all sites belonging to a single organization.
0xe global Global scope spans all reachable nodes on the internet - it is unbounded.
0xf reserved  

All other scopes are unassigned and available to administrators for defining additional regions. 其余的 sc 值,暂未分配/定义,管理员可用 其来定义多播地址的额外的合法/唯一 范围/区域;


Solicited-node multicast address format
bits 8 4 4 79 9 24
field prefix flg sc zeroes ones unicast address

The sc(ope) field holds the binary value 0010 (link-local). Solicited-node multicast addresses are computed as a function of a node's unicast or anycast addresses. A solicited-node multicast address is created by copying the last 24 bits of a unicast or anycast address to the last 24 bits of the multicast address.

Unicast-prefix-based multicast address format[3][4]
bits 8 4 4 4 4 8 64 32
field prefix flg sc res riid plen network prefix group ID

Link-scoped multicast addresses use a comparable format.[5]

组播地址

组播地址基本结构

所谓组播,是指一个源节点发送的单个数据报文能被特定的多个目的节点接收到。在IPv6网络中,组播地址有特定的前缀FF::/8来标识,其结构如下图所示:


下:
1)Flgs(标志):该段有4位|0|R|P|T|

Flgs的高1位为保留位,必须设置为0;
T - T位如果为置0表示永久分配或者是well-known组播地址,如果置1表示临时分配动态的地址,不固定。
P - P位如果置1的话表示此组播地址是一个基于单播前缀的ipv6组播地址,默认为0,如果P位设置为1,那么T位必须为1。
R - R位如果置1的话表示此组播地址是一个内嵌RP地址的ipv6组播地址,默认为0。

2)Scop(范围):该字段占有4位,用来限制组播数据流在网络中发送的范围。

0 reserved
1 Interface-Local scope–节点本地范围
2 Link-Local scope–链路本地范围
3 reserved
4 Admin-Local scope-管理本地范围
5 Site-Local scope–站点本地范围
6 (unassigned)
7 (unassigned)
8 Organization-Local scope-组织本地范围
9 (unassigned)
A (unassigned)
B (unassigned)
C (unassigned)
D (unassigned)
E Global scope–全局范围的
F reserved


3)Group ID(组ID):该字段长度为112位,用以标识组播组。

被请求节点组播地址

在IPv6组播地址中,有一种特别的组播地址,被称为请求节点组播地址(Solicitted-node Address)。被请求节点组播地址时一种具有特殊用途的地址,主要用于在重复地址检测和获取邻居节点的链路层地址时,代替IPv4中使用的广播地址。
被请求节点组播地址由前缀FF02::1:FF00::/104和单播地址的最后24位组成,如下图所示:

对于节点或路由器的接口上配置的每个单播和任播地址,都自动启用一个对应的被请求节点组播地址。被请求节点组播地址使用范围为链路本地。

众所周知的组播地址

IPv6具有一些众所周知的组播地址,他们具有特殊的含义,如下表所示:

组播地址        范围        含义        描述
FF01::1        节点        所有节点        在本地接口范围的所有节点
FF01::2        节点        所有路由器        在本地接口范围的所有路由器
FF02::1        链路本地        所有节点        在本地链路范围的所有节点
FF02::2        链路本地        所有路由器        在本地链路范围的所有路由器
FF02::5        链路本地        OSPF路由器        所有OSPF路由器组播地址
FF02::6        链路本地        OSPF DR路由器        所有OSPF的DR路由器组播地址
FF02::9        本地链路        RIP路由器        所有RIP路由器组播地址
FF02::13        本地链路        PIM路由器        所有PIM路由器组播地址
FF05::2        站点        所有路由器        在一个站点范围内的所有路由器



三、IEEE EUI-64接口ID (隐私保护原因,目前已经被弃用?)
EUI-64接口ID时IEEE定义的一种64位的扩展唯一标识符。目前IPv6单播地址基本上都要求接口标识符为64位。IEEE EUI-64格式的接口标识符是从接口的链路层地址(MAC地址)变化而来的。IPv6地址中的接口标识符是64位,而MAC地址是48位,因此需要在MAC地址的中间位置(从高位开始的第24位后)插入十六进制数FFFE(1111111111111110)。为了确保这个从MAC地址得到的接口标识符是唯一的,还要将Universal/Local (U/L)位(从高位开始的第7位)设置为“1”。最后得到的这组数就作为EUI-64格式的接口标识符。如下图所示:


 



posted @ 2023-04-18 10:27  慢旅  阅读(984)  评论(0)    收藏  举报