IPv6基础协议介绍

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IPv6基础协议介绍相关的知识,希望对你有一定的参考价值。

ICMPv6协议

ICMPv6的协议类型是58 除了IPv4中的作用外 还添加了邻居发现、无状态自动配置、PMTU 等作用
技术图片

邻居发现协议NDP

NDP 邻居发现协议 有如下功能
技术图片
NDP使用ICMPv6的相关报文
RS(Router Solicitation):路由器请求报文
RA(Router Advertisement):路由器通告报文
NS(Neighbor Solicitation):邻居请求报文
NA(Neighbor Advertisement):邻居通告报文

地址解析

PCl准备访问PC2之前,首先在本地邻居表中查找PC2的IPv6地址对应的以太网MAC地址,如果查找到相关表项,则将发往PC2的数据包封装在以太数据帧中然后发出:如果没有找到PC2的MAC地址,则发送NS消息用来请求其链路层地址
用ICMPv6里面的type 135(NS 邻居请求)和type 136(NA 邻居的通告)发送
技术图片
过程如下:

  1. PCl向PC2的请求节点的组播地址发送NS消息,该消息是通过类型为135的ICMPv6报文来承载,目标地址是PC2的IPv6单播地址
  2. PC2收到NS消息后,以单播的方式向PCl回应NA消息,该消息中包含了PC2的MAC地址。PC2还会将PCl的 IPv6地址和MAC地址添加至本地的邻居缓存表中
  3. PCl收到来自PC2的NA消息后,将PC2的IPv6地址以及它的MAC地址添加至本地的邻居缓存表中
    假设PCl的IPv6地址为2001::1/64,PC2的IPv6地址为2001::2/64
    技术图片

    DAD检查

    DAD(Duplicate Address Detection)重复地址检测,类似于免费ARP的作用一样
    用ICMPv6里面的type 135(NS 邻居请求)和type 136(NA 邻居的通告)发送
    作用:用于地址分配或主机连接网络时检测重复的IPv4主机地址。
    过程:节点向一个自己将使用的试验地址所在的Solicited-node组播组发送一个以该试验地址为请求的目标地址的邻居请求(NS)报文,如果收到某个其它站点回应的邻居通告(NA)报文,就证明该地址已被网络上使用,节点将不能使用该试验地址进行通信。这种情况下,网络管理员需要手动为该节点分配另外一个地址
    技术图片

    无状态自动配置

    网络节点向相连的路由器发送RS,请求地址前缀信息
    路由器通过发送路由器通告RA,回复地址前缀信息
    用ICMPv6里面的type 133(NS 邻居请求)和type 134(NA 邻居的通告)发送
    技术图片
    举例如下:
    技术图片

    [R1-GigabitEthernet0/0/0]dis this
    #
    interface GigabitEthernet0/0/0
    ipv6 enable 
    ipv6 address 2019::1/64 
    undo ipv6 nd ra halt
    #
    Router Advertisement 用于回复RS报文,RS报文中包含IPv6地址或前缀信息

    注1:华为默认不会发送RA报文,手工开启后默认200S发送一次,使用以下命令开启

    [Huawei-GigabitEthernet0/0/0]undo ipv6  nd ra  halt 

    注2:主动发起RA报文后,同样也会被邻居路由器收到,在邻居路由器上开启发送RS报文,便可以无状态自动配置接口IP地址

    [Huawei-GigabitEthernet0/0/0]ipv6  address auto global

    注3:路由器收到RA回复后,使用EUI64生成接口IPv6地址;主机(windows)收到RA回复后,使用软件随机生成IPv6地址(更加安全)

    IPv6直连

    两台交换机通过GE0/0/1接口相连,SwitchA及SwitchB的GE0/0/1接口分别对应各自的VLANIF100接口,为VLANIF100接口配置IPv6地址,验证它们之间的三层互通性
    技术图片

    第一步:使能SWITCH的IPV6转发能力

    配置SwitchA

    <HUAWEI> system-view
    [HUAWEI] sysname SwitchA
    [SwitchA] ipv6

    配置SwitchB

    <HUAWEI> system-view
    [HUAWEI] sysname SwitchB
    [SwitchB] ipv6

    第二步:配置接口的IPV6地址

    配置SwitchA

    [SwitchA] vlan 100
    [SwitchA-vlan100] quit
    [SwitchA] interface gigabitethernet 0/0/1
    [SwitchA-GigabitEthernet0/0/1] port link-type hybrid
    [SwitchA-GigabitEthernet0/0/1] port hybrid pvid vlan 100
    [SwitchA-GigabitEthernet0/0/1] port hybrid untagged vlan 100
    [SwitchA-GigabitEthernet0/0/1] quit
    [SwitchA] interface vlanif 100
    [SwitchA-Vlanif100] ipv6 enable
    [SwitchA-Vlanif100] ipv6 address fc00:1::1/64
    [SwitchA-Vlanif100] quit

    配置SwitchB

    [SwitchB] vlan 100
    [SwitchB-vlan100] quit
    [SwitchB] interface gigabitethernet 0/0/1
    [SwitchB-GigabitEthernet0/0/1] port link-type hybrid
    [SwitchB-GigabitEthernet0/0/1] port hybrid pvid vlan 100
    [SwitchB-GigabitEthernet0/0/1] port hybrid untagged vlan 100
    [SwitchB-GigabitEthernet0/0/1] quit
    [SwitchB] interface vlanif 100
    [SwitchB-Vlanif100] ipv6 enable
    [SwitchB-Vlanif100] ipv6 address fc00:1::2/64
    [SwitchB-Vlanif100] quit

    第三步验证配置结果

    显示SwitchA的接口信息。

    [SwitchA] display ipv6 interface vlanif 100
    Vlanif100 current state : UP
    IPv6 protocol current state : UP
    IPv6 is enabled, link-local address is FE80::218:20FF:FE00:83
    Global unicast address(es):
    FC00:1::1, subnet is FC00:1::/64
    Joined group address(es):
    FF02::1:FF00:1
    FF02::1:FF00:83
    FF02::2
    FF02::1
    MTU is 1500 bytes
    ND DAD is enabled, number of DAD attempts: 1
    ND reachable time is 30000 milliseconds
    ND retransmit interval is 1000 milliseconds
    ND stale time is 1200 seconds 

    显示SwitchB的接口信息

    [SwitchB] display ipv6 interface vlanif 100
    Vlanif100 current state : UP
    IPv6 protocol current state : UP
    IPv6 is enabled, link-local address is FE80::2E0:FCFF:FE33:11
    Global unicast address(es):
    FC00:1::2, subnet is FC00:1::/64
    Joined group address(es):
    FF02::1:FF00:2
    FF02::1:FF33:11
    FF02::2
    FF02::1
    MTU is 1500 bytes
    ND DAD is enabled, number of DAD attempts: 1
    ND reachable time is 30000 milliseconds
    ND retransmit interval is 1000 milliseconds
    ND stale time is 1200 seconds 

    从SwitchA上Ping SwitchB的IPv6地址

    [SwitchA] ping ipv6 FC00:1::2
    PING FC00:1::2 : 56  data bytes, press CTRL_C to break
    Reply from FC00:1::2
    bytes=56 Sequence=1 hop limit=64  time = 12 ms
    Reply from FC00:1::2
    bytes=56 Sequence=2 hop limit=64  time = 3 ms
    Reply from FC00:1::2
    bytes=56 Sequence=3 hop limit=64  time = 3 ms
    Reply from FC00:1::2
    bytes=56 Sequence=4 hop limit=64  time = 3 ms
    Reply from FC00:1::2
    bytes=56 Sequence=5 hop limit=64  time = 3 ms
    
    --- FC00:1::2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 3/4/12 ms

    IPv6静态路由

    IPv6网络中属于不同网段的主机通过几台Switch相连,要求不配置动态路由协议,使不同网段的任意两台主机之间能够互通
    技术图片

    第一步:配置接口所属VLAN

    配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。

    <HUAWEI> system-view
    [HUAWEI] sysname SwitchA
    [SwitchA] vlan batch 10 20
    [SwitchA] interface gigabitethernet 0/0/1
    [SwitchA-GigabitEthernet0/0/1] port link-type trunk
    [SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 20
    [SwitchA-GigabitEthernet0/0/1] quit
    [SwitchA] interface gigabitethernet 0/0/2
    [SwitchA-GigabitEthernet0/0/2] port link-type access
    [SwitchA-GigabitEthernet0/0/2] port default vlan 10
    [SwitchA-GigabitEthernet0/0/2] quit

    第二步:配置VLANIF接口的IP地址

    配置SwitchA。SwitchB和SwitchC的配置与SwitchA类似。

    [SwitchA] ipv6
    [SwitchA] interface vlanif 10
    [SwitchA-Vlanif10] ipv6 enable
    [SwitchA-Vlanif10] ipv6 address fc00:0:0:2001::1/64
    [SwitchA-Vlanif10] quit
    [SwitchA] interface vlanif 20
    [SwitchA-Vlanif20] ipv6 enable
    [SwitchA-Vlanif20] ipv6 address fc00:0:0:2010::1/64
    [SwitchA-Vlanif20] quit

    第三步:配置主机地址和网关

    根据组网图配置好各主机的IPv6地址,并将PC1的缺省网关配置为fc00:0:0:2001::1,PC2的缺省网关配置为fc00:0:0:2002::1,主机3的缺省网关配置为fc00:0:0:2003::1。

    第四步:配置IPV6静态路由

    在SwitchA配置IPv6缺省路由

    [SwitchA] ipv6 route-static :: 0 vlanif20 fc00:0:0:2010::2

    在SwitchB配置两条IPv6静态路由

    [SwitchB] ipv6 route-static fc00:0:0:2001:: 64 vlanif20 fc00:0:0:2010::1
    [SwitchB] ipv6 route-static fc00:0:0:2003:: 64 vlanif40 fc00:0:0:2020::2

    在SwitchC配置IPv6缺省路由

    [SwitchC] ipv6 route-static :: 0 vlanif40 fc00:0:0:2020::1

    第五步:查看配置结果

    查看SwitchA的IPv6路由表

    [SwitchA] display ipv6 routing-table
    Routing Table : Public 
         Destinations : 7        Routes : 7
    
    Destination  : ::                              PrefixLength : 0
    NextHop      : FC00:0:0:2010::2                Preference   : 60
    Cost         : 0                               Protocol     : Static
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : Vlanif20                        Flags        : D
    
    Destination  : ::1                             PrefixLength : 128
    NextHop      : ::1                             Preference   : 0
    Cost         : 0                               Protocol     : Direct
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : InLoopBack0                     Flags        : D            
    
    Destination  : FC00:0:0:2001::                 PrefixLength : 64
    NextHop      : FC00:0:0:2001::1                Preference   : 0
    Cost         : 0                               Protocol     : Direct
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : Vlanif10                        Flags        : D     
    
    Destination  : FC00:0:0:2001::1                PrefixLength : 128
    NextHop      : ::1                             Preference   : 0
    Cost         : 0                               Protocol     : Direct
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : Vlanif10                        Flags        : D 
    
    Destination  : FC00:0:0:2010::                 PrefixLength : 64
    NextHop      : FC00:0:0:2010::1                Preference   : 0
    Cost         : 0                               Protocol     : Direct
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : Vlanif20                        Flags        : D
    
    Destination  : FC00:0:0:2010::1                PrefixLength : 128
    NextHop      : ::1                             Preference   : 0
    Cost         : 0                               Protocol     : Direct
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : Vlanif20                        Flags        : D
    
    Destination  : FE80::                          PrefixLength : 10
    NextHop      : ::                              Preference   : 0
    Cost         : 0                               Protocol     : Direct
    RelayNextHop : ::                              TunnelID     : 0x0
    Interface    : NULL0                           Flags        : D 

    使用Ping进行验证

    [SwitchA] ping ipv6 fc00:0:0:2003::1
    PING fc00:0:0:2003::1 : 56  data bytes, press CTRL_C to break
    Reply from FC00:0:0:2003::1
    bytes=56 Sequence=1 hop limit=63  time = 63 ms
    Reply from FC00:0:0:2003::1
    bytes=56 Sequence=2 hop limit=63  time = 62 ms
    Reply from FC00:0:0:2003::1
    bytes=56 Sequence=3 hop limit=63  time = 62 ms
    Reply from FC00:0:0:2003::1
    bytes=56 Sequence=4 hop limit=63  time = 63 ms
    Reply from FC00:0:0:2003::1
    bytes=56 Sequence=5 hop limit=63  time = 63 ms
    
    --- fc00:0:0:2003::1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 62/62/63 ms

    使用Tracert进行验证。

    [SwitchA] tracert ipv6 fc00:0:0:2003::1
    traceroute to fc00:0:0:2003::1  30 hops max,60 bytes packet
    1 FC00:0:0:2010::2 31 ms  32 ms  31 ms
    2 FC00:0:0:2003::1 62 ms  63 ms  62 ms

以上是关于IPv6基础协议介绍的主要内容,如果未能解决你的问题,请参考以下文章

IPv6 OSPFv3路由协议测试——信而泰网络测试仪实操

IPv6 OSPFv3路由协议测试——信而泰网络测试仪实操

[转帖]IPv6基础知识,一分钟了解下

华为设备OSPF理论基础和实现实验(迎接IPv6数通时代的重要协议)

IPv6改造方案:协议转换技术

Qt6网络抓包工具项目实战2.7IPV6协议介绍