华为OSPF路由负载分担配置实验

一、组网需求

 如图所示,OSPF网络中有四台交换机,同属于区域0。要求配置负载分担,使得SWA流量,可以分别通过SWB和SWC送到SWD。

二、配置思路

1、在各交换机上配置OSPF基本功能,实现OSPF网络的基本互通。

2、在SwitchA配置负载分担,实现负载均衡的目的。

三、配置操作

1、配置接口

SWA接口配置:

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname SWA
[SWA]vlan batch 10 20 50
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWA]int gi 0/0/1
[SWA-GigabitEthernet0/0/1]port link-type trunk
[SWA-GigabitEthernet0/0/1]port trunk allow-pass vlan 10
[SWA-GigabitEthernet0/0/1]q
[SWA]int gi 0/0/2
[SWA-GigabitEthernet0/0/2]port link-type trunk
[SWA-GigabitEthernet0/0/2]port trunk allow-pass vlan 20
[SWA-GigabitEthernet0/0/2]q
[SWA]int gi 0/0/3
[SWA-GigabitEthernet0/0/3]port link-type trunk
[SWA-GigabitEthernet0/0/3]port trunk allow-pass vlan 50
[SWA-GigabitEthernet0/0/3]q
[SWA]int vlanif 10
[SWA-Vlanif10]ip addr 10.1.1.1 24
[SWA-Vlanif10]q
[SWA]int vlanif 20
[SWA-Vlanif20]ip addr 10.1.2.1 24
[SWA-Vlanif20]q
[SWA]int vlanif 50
[SWA-Vlanif50]ip addr 172.16.1.1 24
[SWA-Vlanif50]q
[SWA]

SWB接口配置:

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname SWB
[SWB]vlan batch 10 30 
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWB]int gi0/0/1
[SWB-GigabitEthernet0/0/1]port link-type trunk
[SWB-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 
[SWB-GigabitEthernet0/0/1]q
[SWB]int gi 0/0/2
[SWB-GigabitEthernet0/0/2]port link-type trunk
[SWB-GigabitEthernet0/0/2]port trunk allow-pass vlan 30
[SWB-GigabitEthernet0/0/2]q
[SWB]int vlanif 10
[SWB-Vlanif10]ip addr 10.1.1.2 24
[SWB-Vlanif10]q
[SWB]int vlanif 30
[SWB-Vlanif30]ip addr 192.168.0.1 24
[SWB-Vlanif30]q
[SWB]

SWC接口配置:

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname SWC
[SWC]vlan batch 20 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWC]int gi 0/0/1
[SWC-GigabitEthernet0/0/1]port link-type trunk
[SWC-GigabitEthernet0/0/1]port trunk allow-pass vlan 20
[SWC-GigabitEthernet0/0/1]q
[SWC]int gi 0/0/2
[SWC-GigabitEthernet0/0/2]port link-type trunk
[SWC-GigabitEthernet0/0/2]port trunk allow-pass vlan 40
[SWC-GigabitEthernet0/0/2]q
[SWC]int vlanif 20
[SWC-Vlanif20]ip addr 10.1.2.2 24
[SWC-Vlanif20]q
[SWC]int vlanif 40
[SWC-Vlanif40]ip addr 192.168.1.1 24
[SWC-Vlanif40]

SWD接口配置:

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sysname SWD
[SWD]vlan batch 30 40 60 
Info: This operation may take a few seconds. Please wait for a moment...done.
[SWD]int gi 0/0/1
[SWD-GigabitEthernet0/0/1]port link-type trunk
[SWD-GigabitEthernet0/0/1]port trunk allow-pass vlan 30
[SWD-GigabitEthernet0/0/1]q
[SWD]int gi 0/0/2
[SWD-GigabitEthernet0/0/2]port link-type trunk
[SWD-GigabitEthernet0/0/2]port trunk allow-pass vlan 40
[SWD-GigabitEthernet0/0/2]q
[SWD]int gi 0/0/3
[SWD-GigabitEthernet0/0/3]port link-type trunk
[SWD-GigabitEthernet0/0/3]port trunk allow-pass vlan 60
[SWD-GigabitEthernet0/0/3]q
[SWD]int vlanif 30
[SWD-Vlanif30]ip addr 192.168.0.2 24
[SWD-Vlanif30]q
[SWD]int vlanif 40
[SWD-Vlanif40]ip addr 192.168.1.2 24
[SWD-Vlanif40]q
[SWD]int vlanif 60
[SWD-Vlanif60]ip addr 172.17.1.1 24
[SWD-Vlanif60]

2、连通性配置(OSPF)

SWA连通性配置

[SWA]ospf 1 router-id 1.1.1.1
[SWA-ospf-1]area 0
[SWA-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[SWA-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[SWA-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[SWA-ospf-1-area-0.0.0.0]q
[SWA-ospf-1]q
[SWA]

SWB连通性配置

[SWB]ospf 1 router-id 2.2.2.2
[SWB-ospf-1]area 0
[SWB-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[SWB-ospf-1-area-0.0.0.0]network 192.168.0.0 0.0.0.255
[SWB-ospf-1-area-0.0.0.0]q
[SWB-ospf-1]q
[SWB]

SWC连通性配置

[SWC]ospf 1 router-id 3.3.3.3
[SWC-ospf-1]area 0
[SWC-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[SWC-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[SWC-ospf-1-area-0.0.0.0]q
[SWC-ospf-1]q
[SWC]

SWD连通性配置

[SWD]ospf 1 router-id 4.4.4.4
[SWD-ospf-1]area 0
[SWD-ospf-1-area-0.0.0.0]network 172.17.1.0 0.0.0.255
[SWD-ospf-1-area-0.0.0.0]network 192.168.0.0 0.0.0.255
[SWD-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[SWD-ospf-1-area-0.0.0.0]q
[SWD-ospf-1]q

配置结果说明

查看SWA的路由表。

[SwitchA] display ip routing-table

Route Flags: R - relay, D - download to fib

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

Routing Tables: Public

         Destinations : 11       Routes : 12

 

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

 

       10.1.1.0/24  Direct  0    0           D   10.1.1.1        Vlanif10

       10.1.1.1/32  Direct  0    0           D   127.0.0.1       Vlanif10

       10.1.2.0/24  Direct  0    0           D   10.1.2.1        Vlanif20

       10.1.2.1/32  Direct  0    0           D   127.0.0.1       Vlanif20

      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

     172.16.1.0/24  Direct  0    0           D   172.16.1.1      Vlanif50

     172.16.1.1/32  Direct  0    0           D   127.0.0.1       Vlanif50

     172.17.1.0/24  OSPF    10   3           D   10.1.1.2        Vlanif10

                    OSPF    10   3           D   10.1.2.2        Vlanif20

    192.168.0.0/24  OSPF    10   2           D   10.1.1.2        Vlanif10

    192.168.1.0/24  OSPF    10   2           D   10.1.2.2        Vlanif20

    从路由表可以看出,由于最大等价路由条数的缺省值为16,因此SwitchA的两个下一跳10.1.1.2(SwitchB)和10.1.2.2(SwitchC)均成为有效路由。

 

在SWA上配置等价路由优先级

如果不希望SwitchB和SwitchC形成负载分担,可以配置等价路由优先级,指定下一跳。

[SwitchA] ospf 1

[SwitchA-ospf-1] nexthop 10.1.2.2 weight 1

[SwitchA-ospf-1] quit

 

查看SWA的路由表

[SwitchA] display ip routing-table

Route Flags: R - relay, D - download to fib

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

Routing Tables: Public

         Destinations : 11       Routes : 11

 

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/24  Direct  0    0           D   10.1.1.1        Vlanif10

       10.1.1.1/32  Direct  0    0           D   127.0.0.1       Vlanif10

       10.1.2.0/24  Direct  0    0           D   10.1.2.1        Vlanif20

       10.1.2.1/32  Direct  0    0           D   127.0.0.1       Vlanif20

      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

     172.16.1.0/24  Direct  0    0           D   172.16.1.1      Vlanif50

     172.16.1.1/32  Direct  0    0           D   127.0.0.1       Vlanif50

     172.17.1.0/24  OSPF    10   3           D   10.1.2.2        Vlanif20

    192.168.0.0/24  OSPF    10   2           D   10.1.1.2        Vlanif10

    192.168.1.0/24  OSPF    10   2           D   10.1.2.2        Vlanif20

    从路由表中可以看出,当配置等价路由的优先级后,由于下一跳为10.1.2.2(SwitchC)的优先级(权值为1)高于下一跳为10.1.1.2(SwitchB)的优先级,所以OSPF优先选择下一跳为10.1.2.2为唯一最优路由。

猜你喜欢

转载自blog.csdn.net/WannaHaha/article/details/107905737