计算机网络-IPv6静态路由配置

一、概述

前面我们学习了IPv6的基础概念、IPv6地址的格式与配置方法以及ICMPv6和DHCPv6的应用,但是在实际情况下基于IPv6的还有很多应用,基于IPv6的OSPF、BGP、RIP等等。这里只简单学习下IPv6的静态路由配置即可,能够上网实现网段互通。
相关应用

二、IPv6静态路由

拓扑图:

IPv6静态路由与IPv4静态路由类似,也需要管理员手工配置,适合于一些结构比较简单的IPv6网络。在创建IPv6静态路由时,可以同时指定出接口和下一跳,或者只指定出接口或只指定下一跳。

  • 对于点到点接口:指定出接口。

  • 对于广播类型接口:指定下一跳。

    [Huawei] ipv6 route-static dest-ipv6-address prefix-length { interface-type interface-number [ nexthop-ipv6-address ] | nexthop-ipv6-address | vpn-instance vpn-destination-name nexthop-ipv6-address } [ preference preference][ permanent | inherit-cost ] [ description text ]

    AR1

    ipv6 route-static 2001:1:: 64 2001:1::3 # 静态路由
    ipv6 route-static 2001:2:: 64 2001:1::3 # 静态路由
    ipv6 route-static 2001:3:: 64 2001:1::3 # 静态路由

    AR4

    ipv6 route-static :: 0 2001:3::3 # 配置默认路由

IPV6的静态路由与IPv4类似,都需要管理员手动指定、也包括全0的默认路由,使用:: 0 表示,使用静态路由一样需要考虑双向的路由配置。

三、OSPFv3配置

OSPFv3拓扑图

这里只简单配置OSPFv3不深入讨论相关报文了。有几点需要注意:

  • OSPFv3是用于IPv6使用
  • 和OSPFv2类似,保留了router-id、process id等等
  • 不再需要network网段通告,在接口进行通告即可
  • 必须配置router-id,格式与ospfv2一致

配置:

复制代码
# AR1
# 全局启用ipv6
ipv6 
# 配置ospf进程以及router-id
ospfv3 1
 router-id 1.1.1.1

# 接口通告进行ospfv3的进程和区域
interface GigabitEthernet0/0/0
 ipv6 enable 
 ipv6 address 2001:1::1/64 
 ospfv3 1 area 0.0.0.0
 
# 接口通告进行ospfv3的进程和区域
interface LoopBack0
 ipv6 enable 
 ipv6 address 240E::1/64 
 ospfv3 1 area 0.0.0.0

# AR2
# 全局启用IPv6
ipv6 
# 配置OSPFv3进程和router-id
ospfv3 1
 router-id 2.2.2.2
# 接口通告
interface GigabitEthernet0/0/1
 ipv6 enable 
 ipv6 address 2001:2::2/64 
 ospfv3 1 area 0.0.0.0
 
 
# AR3
#
ipv6 
#
ospfv3 1
 router-id 3.3.3.3
#
interface GigabitEthernet0/0/0
 ipv6 enable 
 ipv6 address 2001:1::3/64 
 ospfv3 1 area 0.0.0.0
#
interface GigabitEthernet0/0/1
 ipv6 enable 
 ipv6 address 2001:2::3/64 
 ospfv3 1 area 0.0.0.0
#
interface GigabitEthernet0/0/2
 ipv6 enable 
 ipv6 address 2001:3::3/64 
 ospfv3 1 area 0.0.0.0
 
# AR4
ipv6 
#
ospfv3 1
 router-id 4.4.4.4
#
interface GigabitEthernet0/0/2
 ipv6 enable 
 ipv6 address 2001:3::4/64 
 ospfv3 1 area 0.0.0.0

查看路由:

复制代码
# 查看OSPFv3邻居
<AR3>dis ospfv3 peer
OSPFv3 Process (1)
OSPFv3 Area (0.0.0.0)
Neighbor ID     Pri  State            Dead Time Interface            Instance ID
1.1.1.1           1  Full/Backup      00:00:33  GE0/0/0                        0
2.2.2.2           1  Full/Backup      00:00:34  GE0/0/1                        0
4.4.4.4           1  Full/Backup      00:00:31  GE0/0/2                        0


# 查看IPv6路由表
[AR4]dis ipv6 routing-table 
Routing Table : Public
	Destinations : 7	Routes : 7

 Destination  : ::1                             PrefixLength : 128
 NextHop      : ::1                             Preference   : 0
 Cost         : 0                               Protocol     : Direct
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : InLoopBack0                     Flags        : D

 Destination  : 2001:1::                        PrefixLength : 64
 NextHop      : FE80::2E0:FCFF:FE93:5F2B        Preference   : 10
 Cost         : 2                               Protocol     : OSPFv3
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : GigabitEthernet0/0/2            Flags        : D

 Destination  : 2001:2::                        PrefixLength : 64
 NextHop      : FE80::2E0:FCFF:FE93:5F2B        Preference   : 10
 Cost         : 2                               Protocol     : OSPFv3
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : GigabitEthernet0/0/2            Flags        : D

 Destination  : 2001:3::                        PrefixLength : 64
 NextHop      : 2001:3::4                       Preference   : 0
 Cost         : 0                               Protocol     : Direct
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : GigabitEthernet0/0/2            Flags        : D

 Destination  : 2001:3::4                       PrefixLength : 128
 NextHop      : ::1                             Preference   : 0
 Cost         : 0                               Protocol     : Direct
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : GigabitEthernet0/0/2            Flags        : D

 Destination  : 240E::1                         PrefixLength : 128
 NextHop      : FE80::2E0:FCFF:FE93:5F2B        Preference   : 10
 Cost         : 2                               Protocol     : OSPFv3
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : GigabitEthernet0/0/2            Flags        : D

 Destination  : FE80::                          PrefixLength : 10
 NextHop      : ::                              Preference   : 0
 Cost         : 0                               Protocol     : Direct
 RelayNextHop : ::                              TunnelID     : 0x0
 Interface    : NULL0                           Flags        : D

# 测试连通性
[AR4]ping ipv6 240e::1
  PING 240e::1 : 56  data bytes, press CTRL_C to break
    Reply from 240E::1 
    bytes=56 Sequence=1 hop limit=63  time = 30 ms
    Reply from 240E::1 
    bytes=56 Sequence=2 hop limit=63  time = 40 ms
    Reply from 240E::1 
    bytes=56 Sequence=3 hop limit=63  time = 30 ms
    Reply from 240E::1 
    bytes=56 Sequence=4 hop limit=63  time = 30 ms
    Reply from 240E::1 
    bytes=56 Sequence=5 hop limit=63  time = 40 ms

  --- 240e::1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/34/40 ms

总结:这里大概了解下ipv6的路由配置,静态路由配置与IPv4类似,OSPFv3稍有不同。

本文由mdnice多平台发布

相关推荐
NE_STOP3 天前
Vibe Coding -- Claude Code 的核心配置与常用命令
程序人生
郝学胜-神的一滴10 天前
Python 高级编程 020:属性查找全解析
开发语言·人工智能·python·程序人生
郝学胜-神的一滴10 天前
CMake 019:程序生成与清理全解析
开发语言·c++·qt·程序人生·软件构建·cmake
旧曲重听110 天前
2026前端技术从「夯」到「拉」
前端·程序人生·职场和发展·软件工程
CoderYanger11 天前
A.每日一题:2095. 删除链表的中间节点
java·数据结构·程序人生·leetcode·链表·面试·职场和发展
CoderYanger11 天前
A.每日一题:234. 回文链表
数据结构·程序人生·leetcode·链表·面试·职场和发展·学习方法
CoderYanger11 天前
A.每日一题:3612. 用特殊操作处理字符串 I
java·程序人生·leetcode·面试·职场和发展·学习方法·改行学it
CoderYanger11 天前
A.每日一题:144题+145题 二叉树的前序遍历+后序遍历
java·程序人生·leetcode·面试·职场和发展·学习方法·改行学it
NE_STOP11 天前
Vibe Coding--初识AI编程
程序人生
这个DBA有点耶11 天前
国产数据库有哪些?2026年主流产品选型对比
数据库·程序人生·职场和发展·架构·程序员创富·改行学it