Networking graphics
Introduction to OSPF load sharing
- Equal cost multiple path (ECMP) means that when there are multiple paths between two network nodes at the same time, the traffic between nodes is equally shared on multiple paths. The role of load sharing is to reduce the traffic pressure of each path and enhance the robustness of the network. When there are multiple routes found by the same routing protocol at the same destination, and the overhead values of these routes are the same, the load sharing condition is satisfied. When load sharing is realized, the router forwards according to the five tuples (source address, destination address, source port, destination port and protocol). When the five tuples are the same, the router always selects the same next hop address as the previous one to send messages. When the quintuples are different, the router will select a relatively idle path for forwarding.
- In the ospf network, sometimes there are multiple equivalent paths between two network elements, and a single path is difficult to bear all the traffic. At this time, users generally want multiple paths to evenly share all the traffic. This can not only improve the reliability of the network, but also improve the utilization of resources. In this case, you can consider configuring OSPF load sharing.
Networking requirements
- As shown in Figure 1, there are four switches in the OSPF network, which belong to zone 0. It is required to configure load sharing so that SwitchA traffic can be sent to SwitchD through SwitchB and SwitchC respectively.
Configuration ideas
- 1. configure OSPF basic functions on each switch to realize the basic interworking of ospf network.
- 2. configure load sharing in SwitchA to achieve load balancing.
Operation steps
- 1. configure the VLAN of each interface
\a configure SwitchA. The configuration of SwitchB, SwitchC, and SwitchD is similar to that of SwitchA and will not be repeated.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 20 50 [SwitchA] interface gigabitethernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] port link-type trunk [SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 [SwitchA-GigabitEthernet1/0/1] quit [SwitchA] interface gigabitethernet 1/0/2 [SwitchA-GigabitEthernet1/0/2] port link-type trunk [SwitchA-GigabitEthernet1/0/2] port trunk allow-pass vlan 20 [SwitchA-GigabitEthernet1/0/2] quit [SwitchA] interface gigabitethernet 1/0/3 [SwitchA-GigabitEthernet1/0/3] port link-type trunk [SwitchA-GigabitEthernet1/0/3] port trunk allow-pass vlan 50 [SwitchA-GigabitEthernet1/0/3] quit
- 2. Configure the IP address of each VLANIF interface
\a configure SwitchA. The configuration of SwitchB, SwitchC, and SwitchD is similar to that of SwitchA and will not be repeated.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 10.1.1.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 20 [SwitchA-Vlanif20] ip address 10.1.2.1 24 [SwitchA-Vlanif20] quit [SwitchA] interface vlanif 50 [SwitchA-Vlanif50] ip address 172.16.1.1 24 [SwitchA-Vlanif50] quit
- 3. Configuring OSPF basic functions
\a configure SwitchA.
[SwitchA] ospf 1 router-id 10.10.10.1 [SwitchA-ospf-1] area 0 [SwitchA-ospf-1-area-0.0.0.0] network 172.16.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] quit
\b configure SwitchB.
[SwitchB] ospf 1 router-id 10.10.10.2 [SwitchB-ospf-1] area 0 [SwitchB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] quit [SwitchB-ospf-1] quit
\c configure SwitchC.
[SwitchC] ospf 1 router-id 10.10.10.3 [SwitchC-ospf-1] area 0 [SwitchC-ospf-1-area-0.0.0.0] network 10.1.2.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] quit [SwitchC-ospf-1] quit
\d configure SwitchD.
[SwitchD] ospf 1 router-id 10.10.10.4 [SwitchD-ospf-1] area 0 [SwitchD-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255 [SwitchD-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [SwitchD-ospf-1-area-0.0.0.0] network 172.17.1.0 0.0.0.255 [SwitchD-ospf-1-area-0.0.0.0] quit [SwitchD-ospf-1] quit
\a view the SwitchA routing table.
[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.2.2 Vlanif20 OSPF 10 3 D 10.1.1.2 Vlanif10 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
It can be seen from the routing table that since the maximum number of equivalent routes of the box switch is 16 and the maximum number of equivalent routes of the box switch is 8, the two next hops 10.1.1.2 (SwitchB) and 10.1.2.2 (SwitchC) of SwitchA become effective routes.
- 4. configure equivalent routing priority on SwitchA
If you do not want SwitchB and SwitchC to share the load, you can configure the equivalent routing priority and specify the next hop.
[SwitchA] ospf 1 [SwitchA-ospf-1] nexthop 10.1.2.2 weight 1 //Set the priority of equivalent routes through the weight parameter. By default, the value of weight is 255. The smaller the value, the higher the priority. [SwitchA-ospf-1] quit
\view the routing table of SwitchA
[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
It can be seen from the routing table that when the priority of the equivalent route is configured, since the priority (weight 1) of the next hop 10.1.2.2 (SwitchC) is higher than that of the next hop 10.1.1.2 (SwitchB), OSPF preferentially selects the next hop 10.1.2.2 as the only optimal route.