配置OSPF负载分担示例

学习精彩网络技术老师:华为HCIA和HCIP数通eNSP实战视频课
点击学习精彩网络技术老师:华为、华三、锐捷、WLAN、IPv6全套视频课程

介绍OSPF负载分担的配置过程,包括使能负载分担功能、配置等价路由的优先级和负载分担方式。

组网需求

图1所示:

RouterA、RouterB、RouterC、RouterD和RouterE之间通过OSPF协议达到IP网络互连的目的。

RouterA、RouterB、RouterC、RouterD和RouterE同属于区域0。

要求配置负载分担,使得RouterA的流量,可以分别通过RouterC和RouterD发送到RouterE。

图1 配置OSPF负载分担组网图

Device

Interface

IP Address

Device

Interface

IP Address

RouterA

POS1/0/0

10.1.1.1/24

RouterC

POS1/0/0

10.1.2.2/24

POS2/0/0

10.1.2.1/24

POS2/0/0

192.168.1.1/24

POS3/0/0

10.1.3.1/24

RouterD

POS1/0/0

10.1.3.2/24

GE4/0/0

172.16.1.1./24

POS2/0/0

192.168.2.1/24

RouterB

POS1/0/0

10.1.1.2/24

RouterE

POS1/0/0

192.168.0.2/24

POS2/0/0

192.168.1.2/24

POS2/0/0

192.168.0.1/24

POS3/0/0

192.168.2.2/24

GE4/0/0

172.17.1.1/24

配置思路

采用如下的思路配置OSPF的负载分担:

在各路由器上使能OSPF基本功能,实现互连。

在RouterA上配置负载分担功能。

在RouterA上配置等价路由的优先级。

数据准备

为完成此配置例,需准备如下的数据:

RouterA的Router ID 1.1.1.1,运行的OSPF进程号1,区域0的网段10.1.1.0/24、10.1.2.0/24、10.1.3.0/24和172.16.1.0/24。

RouterB的Router ID 2.2.2.2,运行的OSPF进程号1,区域0的网段10.1.1.0/8和192.168.0.0/8。

RouterC的Router ID 3.3.3.3,运行的OSPF进程号1,区域0的网段10.1.2.0/8和192.168.1.0/8。

RouterD的Router ID 4.4.4.4,运行的OSPF进程号1,区域0的网段10.1.3.0/8和192.168.2.0/8。

RouterE的Router ID 5.5.5.5,运行的OSPF进程号1,区域0的网段192.168.0.0/24、192.168.1.0/24、192.168.2.0/24和172.17.1.0/24。

RouterA上负载分担数目为2。

从RouterA到RouterB、RouterC和RouterD的下一跳路由的权重值分别为2、1和1。

操作步骤
  1. 配置各接口的IP地址(略)
  2. 配置OSPF的基本功能(略)
  3. 查看RouterA的路由表

<RouterA> display ip routing-tableRoute Flags: R - relay, D - download

to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 12       Routes : 14

Destination/Mask    Proto  Pre  Cost  Flags     NextHop         Interface

       10.1.1.0/24  Direct 0    0       D        10.1.1.1         Pos1/0/0

       10.1.1.2/32  Direct 0    0       D        10.1.1.2         Pos1/0/0

       10.1.2.0/24  Direct 0    0       D        10.1.2.1         Pos2/0/0

       10.1.2.2/32  Direct 0    0       D        10.1.2.2         Pos2/0/0

       10.1.3.0/24  Direct 0    0       D        10.1.2.1         Pos3/0/0

       10.1.3.2/32  Direct 0    0       D        10.1.2.2         Pos3/0/0

    192.168.0.0/24  OSPF   10   2       D        10.1.1.2         Pos1/0/0

    192.168.1.0/24  OSPF   10   2       D        10.1.2.2         Pos2/0/0

    192.168.2.0/24  OSPF   10   2       D        10.1.2.2         Pos3/0/0

     172.17.1.0/24  OSPF   10   3       D        10.1.1.2         Pos1/0/0

                    OSPF   10   3       D        10.1.2.2         Pos2/0/0

                    OSPF   10   3       D        10.1.3.2         Pos3/0/0

    127.0.0.0/8     Direct 0    0       D        127.0.0.1        InLoopBack0

    127.0.0.1/32    Direct 0    0       D        127.0.0.1        InLoopBack0

  1. 在RouterA上配置最多允许两条路由进行负载分担

[RouterA] ospf 1

[RouterA-ospf-1] maximum load-balancing 2

[RouterA-ospf-1] quit

# 查看RouterA的路由表,可以看出,RouterA只有两个下一跳10.1.1.2(RouterB)和10.1.2.2(RouterC)成为有效路由。这是因为配置了等价路由条数的最大数量为2。

[RouterA] display ip routing-tableRoute Flags: R - relay, D - download

to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 12       Routes : 13

Destination/Mask    Proto  Pre  Cost  Flags     NextHop         Interface

       10.1.1.0/24  Direct 0    0       D        10.1.1.1         Pos1/0/0

       10.1.1.2/32  Direct 0    0       D        10.1.1.2         Pos1/0/0

       10.1.2.0/24  Direct 0    0       D        10.1.2.1         Pos2/0/0

       10.1.2.2/32  Direct 0    0       D        10.1.2.2         Pos2/0/0

       10.1.3.0/24  Direct 0    0       D        10.1.2.1         Pos3/0/0

       10.1.3.2/32  Direct 0    0       D        10.1.2.2         Pos3/0/0

    192.168.0.0/24  OSPF   10   2       D        10.1.1.2         Pos1/0/0

    192.168.1.0/24  OSPF   10   2       D        10.1.2.2         Pos2/0/0

    192.168.2.0/24  OSPF   10   2       D        10.1.2.2         Pos3/0/0

     172.17.1.0/24  OSPF   10   3       D        10.1.1.2         Pos1/0/0

                    OSPF   10   3       D        10.1.2.2         Pos2/0/0

    127.0.0.0/8     Direct 0    0       D        127.0.0.1        InLoopBack0

    127.0.0.1/32    Direct 0    0       D        127.0.0.1        InLoopBack0

  1. 在RouterA上配置等价路由的优先级

[RouterA] ospf 1

[RouterA-ospf-1] nexthop 10.1.1.2 weight 2

[RouterA-ospf-1] nexthop 10.1.2.2 weight 1

[RouterA-ospf-1] nexthop 10.1.3.2 weight 1

[RouterA-ospf-1] quit

# 查看RouterA的路由表。

[RouterA] display ip routing-tableRoute Flags: R - relay, D - download

to fib

----------------------------------------------------------------------------

Routing Tables: Public

         Destinations : 12       Routes : 13

Destination/Mask    Proto  Pre  Cost  Flags     NextHop         Interface

       10.1.1.0/24  Direct 0    0       D        10.1.1.1         Pos1/0/0

       10.1.1.2/32  Direct 0    0       D        10.1.1.2         Pos1/0/0

       10.1.2.0/24  Direct 0    0       D        10.1.2.1         Pos2/0/0

       10.1.2.2/32  Direct 0    0       D        10.1.2.2         Pos2/0/0

       10.1.3.0/24  Direct 0    0       D        10.1.2.1         Pos3/0/0

       10.1.3.2/32  Direct 0    0       D        10.1.2.2         Pos3/0/0

    192.168.0.0/24  OSPF   10   2       D        10.1.1.2         Pos1/0/0

    192.168.1.0/24  OSPF   10   2       D        10.1.2.2         Pos2/0/0

    192.168.2.0/24  OSPF   10   2       D        10.1.2.2         Pos3/0/0

     172.17.1.0/24  OSPF   10   3       D        10.1.2.2         Pos2/0/0

                    OSPF   10   3       D        10.1.3.2         Pos3/0/0

    127.0.0.0/8     Direct 0    0       D        127.0.0.1        InLoopBack0

    127.0.0.1/32    Direct 0    0       D        127.0.0.1        InLoopBack0

从路由表可以看出,由于下一跳地址为10.1.2.2和10.1.3.2的路由的优先级高于下一跳地址为10.1.1.2的路由,因此RouterA只有两个下一跳10.1.2.2(RouterC)和10.1.3.2(RouterD)成为有效路由。

配置文件

RouterA的配置文件

#

  sysname RouterA

#

interface GigabitEthernet4/0/0

 undo shutdown

 ip address 172.16.1.1 255.255.255.0

#

interface pos1/0/0

 link-protocol ppp

 undo shutdown

 ip address 10.1.1.1 255.255.255.0

#

interface pos2/0/0

 link-protocol ppp

 undo shutdown

 ip address 10.1.2.1 255.255.255.0

#

interface pos3/0/0

 link-protocol ppp

 undo shutdown

 ip address 10.1.3.1 255.255.255.0

#

ospf 1 router-id 1.1.1.1

 maximum load-balancing 2

 nexthop 10.1.1.2 weight 2

 nexthop 10.1.2.2 weight 1

 nexthop 10.1.3.2 weight 1

 area 0.0.0.0

  network 10.1.1.0 0.0.0.255

  network 10.1.2.0 0.0.0.255

  network 10.1.3.0 0.0.0.255

  network 172.16.1.0 0.0.0.255

#

return

RouterB的配置文件

#

  sysname RouterB

#

interface pos1/0/0

 link-protocol ppp

 undo shutdown

 ip address 10.1.1.2 255.255.255.0

#

interface pos2/0/0

 link-protocol ppp

 undo shutdown

 ip address 192.168.0.1 255.255.255.0

#

ospf 1 router-id 2.2.2.2

 area 0.0.0.0

  network 10.1.1.0 0.255.255.255

  network 192.168.0.0 0.255.255.255

#

return

RouterC的配置文件

#

  sysname RouterC

#

interface pos1/0/0

 undo shutdown

 link-protocol ppp

 ip address 10.1.2.2 255.255.255.0

#

interface pos2/0/0

 link-protocol ppp

 undo shutdown

 ip address 192.168.1.1 255.255.255.0

#

ospf 1 router-id 3.3.3.3

 area 0.0.0.0

  network 10.1.2.0 0.255.255.255

  network 192.168.1.0 0.0.255.255

#

return

RouterD的配置文件

#

  sysname RouterD

#

interface pos1/0/0

 link-protocol ppp

 undo shutdown

 ip address 10.1.3.2 255.255.255.0

#

interface pos2/0/0

 link-protocol ppp

 undo shutdown

 ip address 192.168.2.1 255.255.255.0

#

ospf 1 router-id 4.4.4.4

 area 0.0.0.0

  network 10.1.3.0 0.255.255.255

  network 192.168.2.0 0.0.255.255

#

return

RouterE的配置文件

#

  sysname RouterE

#

interface GigabitEthernet4/0/0

 undo shutdown

 ip address 172.17.1.1 255.255.255.0

#

interface pos1/0/0

 link-protocol ppp

 undo shutdown

 ip address 192.168.0.2 255.255.255.0

#

interface pos2/0/0

 link-protocol ppp

 undo shutdown

 ip address 192.168.1.2 255.255.255.0

#

interface pos3/0/0

 link-protocol ppp

 undo shutdown

 ip address 192.168.2.2 255.255.255.0

#

ospf 1 router-id 5.5.5.5

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

  network 192.168.1.0 0.0.0.255

  network 192.168.2.0 0.0.0.255

  network 172.17.1.0 0.0.0.255

#

return

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

精彩网络技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值