Typical OSPF Configuration
Example for Configuring Basic OSPF Functions
OSPF Overview
The Open Shortest Path First (OSPF) protocol is a link-state Interior Gateway Protocol (IGP) developed by the Internet Engineering Task Force (IETF). OSPF Version 2 defined in RFC 2328 is used in IPv4.
OSPF is loop-free, provides fast route convergence, and supports area partitioning, equal-cost routes, authentication, and multicast transmission. Therefore, OSPF is widely used as the mainstream IGP in various industries, including the enterprise, carrier, government, finance, education, and health care industries.
OSPF uses the hierarchical design, provides various routing policies, and applies to networks of different sizes and topologies. OSPF is often the first choice for deploying an IGP.
Configuration Notes
- Each router ID in an OSPF process must be unique on an OSPF network. Otherwise, the OSPF neighbor relationship cannot be established and routing information is incorrect. You are advised to configure a unique router ID for each OSPF process on an OSPF device.
- OSPF partitions an AS into different areas, in which Area 0 is the backbone area. OSPF requires that all non-backbone areas maintain the connectivity with the backbone area and devices in the backbone area maintain the connectivity with each other.
- Network types of interfaces on both ends of a link must be the same; otherwise, the two interfaces cannot establish an OSPF neighbor relationship. On a link, if the network type of one OSPF interface is broadcast and the other is P2P, the two OSPF interfaces can still establish an OSPF neighbor relationship but cannot learn routing information from each other.
- The IP address masks of OSPF interfaces on both ends of a link must be the same; otherwise, the two OSPF interfaces cannot establish an OSPF neighbor relationship. On a P2MP network, however, you can run the ospf p2mp-mask-ignore command to disable a device from checking the network mask so that an OSPF neighbor relationship can be established.
- On a broadcast or NBMA network, there must be at least one OSPF interface of which the DR priority is not 0 to ensure that the DR can be elected. Otherwise, the neighbor status of devices on both ends can only be 2-Way.
- This example applies to the following products:
- S2720-EI: V200R011C10 and later versions
- S3700-EI, S3700-HI
- S5700-EI, S5700-HI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-127, SwitchA, SwitchB, and SwitchC reside on the OSPF network. The three switches need to communicate with each other, and SwitchA and SwitchB function as core switches to support network expansion.
Configuration Roadmap
The configuration roadmap is as follows:
Configure an IP address for each VLANIF interface on each switch and specify the VLAN to which the interfaces belong to implement interworking.
Configure basic OSPF functions on each switch and partition the OSPF network into Area 0 and Area 1 with SwitchA as the area border router (ABR). Consequently, the area where SwitchA and SwitchB reside becomes the backbone area and can be used to expand the OSPF network.
Procedure
- Specify the VLANs to which interfaces belong.
# Configure SwitchA. The configurations of SwitchB and SwitchC are similar.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 20 [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
- Configure an IP address for each VLANIF interface.
# Configure SwitchA. The configurations of SwitchB and SwitchC are similar.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 192.168.0.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 20 [SwitchA-Vlanif20] ip address 192.168.1.1 24 [SwitchA-Vlanif20] quit
- Configure basic OSPF functions.
# Configure SwitchA.
[SwitchA] ospf 1 router-id 10.1.1.1 //Create an OSPF process 1 with the router ID 10.1.1.1. [SwitchA-ospf-1] area 0 //Create Area 0 and enter the Area 0 view. [SwitchA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255 //Configure a network segment in Area 0. [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] area 1 //Create Area 1 and enter the Area 1 view. [SwitchA-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255 //Configure a network segment in Area 1. [SwitchA-ospf-1-area-0.0.0.1] return
# Configure SwitchB.
[SwitchB] ospf 1 router-id 10.2.2.2 [SwitchB-ospf-1] area 0 [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] return
# Configure SwitchC.
[SwitchC] ospf 1 router-id 10.3.3.3 [SwitchC-ospf-1] area 1 [SwitchC-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.1] return
- Verify the configuration.
# Check information about OSPF neighbors of SwitchA.
<SwitchA> display ospf peer OSPF Process 1 with Router ID 10.1.1.1 Neighbors Area 0.0.0.0 interface 192.168.0.1(Vlanif10)'s neighbors Router ID: 10.2.2.2 Address: 192.168.0.2 State: Full Mode:Nbr is Master Priority: 1 DR: 192.168.0.2 BDR: 192.168.0.1 MTU: 0 Dead timer due in 36 sec Retrans timer interval: 5 Neighbor is up for 00:15:04 Authentication Sequence: [ 0 ] Neighbors Area 0.0.0.1 interface 192.168.1.1(Vlanif20)'s neighbors Router ID: 10.3.3.3 Address: 192.168.1.2 State: Full Mode:Nbr is Master Priority: 1 DR: 192.168.1.2 BDR: 192.168.1.1 MTU: 0 Dead timer due in 39 sec Retrans timer interval: 5 Neighbor is up for 00:07:32 Authentication Sequence: [ 0 ]
# Check OSPF routing information on SwitchC.
<SwitchC> display ospf routing OSPF Process 1 with Router ID 10.3.3.3 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Transit 192.168.1.2 10.3.3.3 0.0.0.1 192.168.0.0/24 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 Total Nets: 2 Intra Area: 1 Inter Area: 1 ASE: 0 NSSA: 0
The preceding command output shows that SwitchC has a route to 192.168.0.0/24 and the route is an inter-area route.
# Check the routing table on SwitchB and perform the ping operation to test the connectivity between SwitchB and SwitchC.
<SwitchB> display ospf routing OSPF Process 1 with Router ID 10.2.2.2 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.0.0/24 1 Transit 192.168.0.2 10.2.2.2 0.0.0.0 192.168.1.0/24 2 Inter-area 192.168.0.1 10.1.1.1 0.0.0.0 Total Nets: 2 Intra Area: 1 Inter Area: 1 ASE: 0 NSSA: 0
The preceding command output shows that SwitchB has a route to 192.168.1.0/24 and the route is an inter-area route.
# On SwitchB, perform a ping operation to test the connectivity between SwitchB and SwitchC.
<SwitchB> ping 192.168.1.2 PING 192.168.1.2: 56 data bytes, press CTRL_C to break Reply from 192.168.1.2: bytes=56 Sequence=1 ttl=254 time=62 ms Reply from 192.168.1.2: bytes=56 Sequence=2 ttl=254 time=16 ms Reply from 192.168.1.2: bytes=56 Sequence=3 ttl=254 time=62 ms Reply from 192.168.1.2: bytes=56 Sequence=4 ttl=254 time=94 ms Reply from 192.168.1.2: bytes=56 Sequence=5 ttl=254 time=63 ms --- 192.168.1.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 16/59/94 ms
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 10 20 # interface Vlanif10 ip address 192.168.0.1 255.255.255.0 # interface Vlanif20 ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.1.1.1 area 0.0.0.0 network 192.168.0.0 0.0.0.255 area 0.0.0.1 network 192.168.1.0 0.0.0.255 # return
SwitchB configuration file
# sysname SwitchB # vlan batch 10 # interface Vlanif10 ip address 192.168.0.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 router-id 10.2.2.2 area 0.0.0.0 network 192.168.0.0 0.0.0.255 # return
SwitchC configuration file
# sysname SwitchC # vlan batch 20 # interface Vlanif20 ip address 192.168.1.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.3.3.3 area 0.0.0.1 network 192.168.1.0 0.0.0.255 # return
Example for Configuring an OSPF Stub Area
Stub Area Overview
A stub area is an area that does not allow an ABR to advertise received AS external routes. In a stub area, the routing table size and transmitted routing information volume of routers are greatly reduced. A stub area is often placed at the edge of an AS. To ensure the reachability of a destination outside the AS, the ABR in the stub area generates a default route and advertises it to the non-ABR routers in the stub area.
Assume that a device of Company H connects to the backbone area through a single link. The device has low performance and a small routing table. The area where the device resides needs to access other areas or network segments outside the OSPF area, and the next-hop address of routes of the device is the IP address of the next-hop core device of the link. Therefore, the area where the device resides does not need to learn a large number of OSPF external routes and can be configured as a stub area. This configuration can reduce the routing table size of the area and resource consumption of the device.
Configuration Notes
- The backbone area cannot be configured as a stub area.
- An ASBR cannot exist in a stub area. That is, external routes are not advertised in a stub area.
- A virtual link cannot pass through a stub area.
- To configure an area as a stub area, configure stub area attributes on all the routers in this area using the stub command.
- To configure an area as a totally stub area, run the stub command on all the routers in this area, and run the stub no-summary command on the ABR in this area.
- The stub no-summary command can only be configured on an ABR to prevent the ABR from advertising Type 3 LSAs within a stub area. After this command is configured on the ABR, the area becomes a totally stub area, the number of routing entries on routers in the area is reduced, and there are only intra-area routes and a default route advertised by the ABR.
- This example applies to the following products:
- S2720-EI: V200R011C10 and later versions
- S3700-EI, S3700-HI
- S5700-EI, S5700-HI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-128, SwitchA, SwitchB, and SwitchC run OSPF, and the OSPF network is divided into Area 0 and Area 1. SwitchB functions as an ASBR to communicate with external networks. The OSPF routing table size on SwitchC needs to be reduced without affecting communication.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic OSPF functions on each switch to implement interworking in the OSPF network.
Configure a static route on SwitchB and import the route to the OSPF routing table to ensure that there is a reachable route from the OSPF network to external networks.
Configure Area 1 as a stub area to reduce the OSPF routing table size on SwitchC.
Prohibit the ABR (SwitchA) in Area 1 from advertising Type 3 LSAs within the stub area to configure Area 1 as a totally stub area. This configuration minimizes the OSPF routing table size on SwitchC.
Procedure
- Specify the VLANs to which interfaces belong.
# Configure SwitchA. The configurations of SwitchB and SwitchC are similar.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 20 [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
- Configure an IP address for each VLANIF interface.
# Configure SwitchA. The configurations of Switch B and SwitchC are similar.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 192.168.0.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 20 [SwitchA-Vlanif20] ip address 192.168.1.1 24 [SwitchA-Vlanif20] quit
- Configure basic OSPF functions.
# Configure SwitchA.
[SwitchA] ospf 1 router-id 10.1.1.1 [SwitchA-ospf-1] area 0 [SwitchA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
# Configure SwitchB.
[SwitchB] ospf 1 router-id 10.2.2.2 [SwitchB-ospf-1] area 0 [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
# Configure SwitchC.
[SwitchC] ospf 1 router-id 10.3.3.3 [SwitchC-ospf-1] area 1 [SwitchC-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.1] quit [SwitchC-ospf-1] quit
- Configure SwitchB to import a static route.
[SwitchB] ip route-static 10.0.0.0 8 null 0 [SwitchB] ospf 1 [SwitchB-ospf-1] import-route static type 1 //SwitchB functions as an ASBR and imports external routes. [SwitchB-ospf-1] quit
# Check the OSPF routing table on SwitchC. The command output shows that the OSPF routing table contains an AS external route.
[SwitchC] display ospf routing OSPF Process 1 with Router ID 10.3.3.3 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Transit 192.168.1.2 10.3.3.3 0.0.0.1 192.168.0.0/24 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 10.0.0.0/8 3 Type1 1 192.168.1.1 10.2.2.2 Total Nets: 3 Intra Area: 1 Inter Area: 1 ASE: 1 NSSA: 0
- Configure Area 1 as a stub area.
# Configure SwitchA.
[SwitchA] ospf 1 [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] stub //Configure Area 1 as a stub area. All the routers in Area 1 must have the stub command configured. [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
# Configure SwitchC.
[SwitchC] ospf 1 [SwitchC-ospf-1] area 1 [SwitchC-ospf-1-area-0.0.0.1] stub //Configure Area 1 as a stub area. All the routers in Area 1 must have the stub command configured. [SwitchC-ospf-1-area-0.0.0.1] quit [SwitchC-ospf-1] quit
# Check the OSPF routing table on SwitchC. The command output shows that the OSPF routing table does not contain the AS external route 10.0.0.0/8 but contains a default route to external networks.
[SwitchC] display ospf routing OSPF Process 1 with Router ID 10.3.3.3 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Transit 192.168.1.2 10.3.3.3 0.0.0.1 0.0.0.0/0 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 192.168.0.0/24 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 Total Nets: 3 Intra Area: 1 Inter Area: 2 ASE: 0 NSSA: 0
- Configure Area 1 as a totally stub area.
[SwitchA] ospf 1 [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] stub no-summary //Configure Area 1 as a totally stub area. An ABR in Area 1 must have the stub no-summary command configured, while other routers in Area 1 must have the stub command configured. [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
- Verify the configuration.
# Check the OSPF routing table on SwitchC. The command output shows that the OSPF routing table contains only an intra-area OSPF route and a default route to external networks but does not contain the Inter-Area route 192.168.0.0/24.
[SwitchC] display ospf routing OSPF Process 1 with Router ID 10.3.3.3 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Transit 192.168.1.2 10.3.3.3 0.0.0.1 0.0.0.0/0 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 Total Nets: 2 Intra Area: 1 Inter Area: 1 ASE: 0 NSSA: 0
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 10 20 # interface Vlanif10 ip address 192.168.0.1 255.255.255.0 # interface Vlanif20 ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.1.1.1 area 0.0.0.0 network 192.168.0.0 0.0.0.255 area 0.0.0.1 network 192.168.1.0 0.0.0.255 stub no-summary # return
SwitchB configuration file
# sysname SwitchB # vlan batch 10 # interface Vlanif10 ip address 192.168.0.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 router-id 10.2.2.2 import-route static type 1 area 0.0.0.0 network 192.168.0.0 0.0.0.255 # ip route-static 10.0.0.0 255.0.0.0 NULL0 # return
SwitchC configuration file
# sysname SwitchC # vlan batch 20 # interface Vlanif20 ip address 192.168.1.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.3.3.3 area 0.0.0.1 network 192.168.1.0 0.0.0.255 stub # return
Example for Configuring an OSPF NSSA
NSSA Overview
An NSSA is a special type of OSPF area. It is similar to a stub area in that neither of them transmits routes learned from other areas in the AS they reside. The difference is that an NSSA allows AS external routes to be imported and advertised in the entire AS whereas a stub area does not. To ensure the reachability of AS external routes, the ABR in an NSSA generates a default route and advertises the route to the other routers in the NSSA.
An NSSA allows Type 7 LSAs (NSSA External LSAs) to be advertised. Type 7 LSAs are generated by the ASBR of the NSSA. When reaching the ABR of the NSSA, these LSAs can be translated into Type 5 LSAs (AS External LSAs) and advertised to other areas.
Assume that a device of Company H connects to the backbone area through a single link. The device has low performance and a small routing table. The company wants to configure the area where the device resides as a stub area to reduce the routing table size and system resource consumption of the device. In addition, AS external routes need to be imported and advertised to the entire AS. However, a stub area cannot meet this requirement because it does not allow received AS external routes to be advertised. Therefore, the area needs to be configured as an NSSA.
Configuration Notes
- The backbone area cannot be configured as an NSSA.
- To configure an area as an NSSA, configure NSSA attributes on all the routers in this area.
- A virtual link cannot pass through an NSSA.
- To reduce the number of LSAs that are transmitted to the NSSA, configure no-summary on an ABR. This prevents the ABR from transmitting Type 3 LSAs to the NSSA, making the area a totally NSSA.
- This example applies to the following products:
- S2720-EI: V200R011C10 and later versions
- S3700-EI, S3700-HI
- S5700-EI, S5700-HI, S5710-EI, S5710-HI, S5720-LI, S5720S-LI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S2730S-S, S5735-L-I, S5735-L1, S300, S5735-L, S5735S-L, S5735S-L1, S5735S-L-M, S5735-S, S500, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-LI, S6720S-LI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-129, SwitchA, SwitchB, SwitchC, and SwitchD run OSPF, and the OSPF network is divided into Area 0 and Area 1. Devices in Area 1 need to be prohibited from receiving external routes imported from other areas and to communicate with external networks using the external routes imported by the ASBR in Area 1. SwitchB transmits many services, so SwitchA needs to translate Type 7 LSAs into Type 5 LSAs and send the LSAs to other OSPF areas.
In this scenario, ensure that all connected interfaces have STP disabled. If STP is enabled and VLANIF interfaces of switches are used to construct a Layer 3 ring network, an interface on the network will be blocked. As a result, Layer 3 services on the network cannot run normally.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic OSPF functions on each switch to implement interworking in the OSPF network.
Configure Area 1 as an NSSA, configure a static route on SwitchD, and configure SwitchD to import the static route into the OSPF routing table so that switches in Area 1 can communicate with external networks only through SwitchD.
Configure SwitchA as an LSA translator to translate Type 7 LSAs into Type 5 LSAs and send the LSAs to other OSPF areas.
Procedure
- Specify the VLANs to which interfaces belong.
# Configure SwitchA. The configurations of SwitchB, SwitchC, and SwitchD are similar.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 30 [SwitchA] interface gigabitethernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] port link-type trunk [SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 30 [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 10 [SwitchA-GigabitEthernet1/0/2] quit
- Configure an IP address for each VLANIF interface.
# Configure SwitchA. The configurations of SwitchB, SwitchC, and SwitchD are similar.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 192.168.1.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 30 [SwitchA-Vlanif30] ip address 192.168.3.1 24 [SwitchA-Vlanif30] quit
- Configure basic OSPF functions.
# Configure SwitchA.
[SwitchA] ospf 1 router-id 10.1.1.1 [SwitchA-ospf-1] area 0 [SwitchA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] network 192.168.3.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
# Configure SwitchB.
[SwitchB] ospf 1 router-id 10.2.2.2 [SwitchB-ospf-1] area 0 [SwitchB-ospf-1-area-0.0.0.0] network 192.168.2.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] quit [SwitchB-ospf-1] area 1 [SwitchB-ospf-1-area-0.0.0.1] network 192.168.4.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.1] quit [SwitchB-ospf-1] quit
# Configure SwitchC.
[SwitchC] ospf 1 router-id 10.3.3.3 [SwitchC-ospf-1] area 0 [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] network 192.168.2.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] quit [SwitchC-ospf-1] quit
# Configure SwitchD.
[SwitchD] ospf 1 router-id 10.4.4.4 [SwitchD-ospf-1] area 1 [SwitchD-ospf-1-area-0.0.0.1] network 192.168.3.0 0.0.0.255 [SwitchD-ospf-1-area-0.0.0.1] network 192.168.4.0 0.0.0.255 [SwitchD-ospf-1-area-0.0.0.1] quit [SwitchD-ospf-1] quit
- Configure Area 1 as an NSSA.
# Configure SwitchA.
[SwitchA] ospf 1 [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] nssa //Configure Area 1 as an NSSA. All the devices in Area 1 must have the nssa command configured. [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
# Configure SwitchB.
[SwitchB] ospf 1 [SwitchB-ospf-1] area 1 [SwitchB-ospf-1-area-0.0.0.1] nssa //Configure Area 1 as an NSSA. All the devices in Area 1 must have the nssa command configured. [SwitchB-ospf-1-area-0.0.0.1] quit [SwitchB-ospf-1] quit
# Configure SwitchD.
[SwitchD] ospf 1 [SwitchD-ospf-1] area 1 [SwitchD-ospf-1-area-0.0.0.1] nssa //Configure Area 1 as an NSSA. All the devices in Area 1 must have the nssa command configured. [SwitchD-ospf-1-area-0.0.0.1] quit [SwitchD-ospf-1] quit
- Configure SwitchD to import a static route.
[SwitchD] ip route-static 172.16.0.0 16 null 0 [SwitchD] ospf 1 [SwitchD-ospf-1] import-route static //Configure SwitchD to function as an ASBR of the NSSA to import external routes. [SwitchD-ospf-1] quit
# Check the OSPF routing table on SwitchC.
[SwitchC] display ospf routing OSPF Process 1 with Router ID 10.3.3.3 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Transit 192.168.1.2 10.3.3.3 0.0.0.0 192.168.2.0/24 1 Transit 192.168.2.2 10.3.3.3 0.0.0.0 192.168.3.0/24 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.0 192.168.4.0/24 2 Inter-area 192.168.2.1 10.2.2.2 0.0.0.0 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 172.16.0.0/16 1 Type2 1 192.168.1.1 10.2.2.2 Total Nets: 5 Intra Area: 2 Inter Area: 2 ASE: 1 NSSA: 0
The command output shows that the AS external routes imported into the NSSA are advertised by SwitchB to other areas. That is, SwitchB translates Type 7 LSAs into Type 5 LSAs. This is because OSPF selects the ABR with a larger router ID as an LSA translator.
- Configure SwitchA as an LSA translator.
[SwitchA] ospf 1 [SwitchA-ospf-1] area 1 [SwitchA-ospf-1-area-0.0.0.1] nssa translator-always [SwitchA-ospf-1-area-0.0.0.1] quit [SwitchA-ospf-1] quit
- Verify the configuration.
# Wait for 40 seconds and then check the OSPF routing table on SwitchC.
[SwitchC] display ospf routing OSPF Process 1 with Router ID 10.3.3.3 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.1.0/24 1 Transit 192.168.1.2 10.3.3.3 0.0.0.0 192.168.2.0/24 1 Transit 192.168.2.2 10.3.3.3 0.0.0.0 192.168.3.0/24 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.0 192.168.4.0/24 2 Inter-area 192.168.2.1 10.2.2.2 0.0.0.0 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 172.16.0.0/16 1 Type2 1 192.168.1.1 10.1.1.1 Total Nets: 5 Intra Area: 2 Inter Area: 2 ASE: 1 NSSA: 0
The command output shows that the AS external routes imported into the NSSA are advertised by SwitchA to other areas. That is, SwitchA translates Type 7 LSAs into Type 5 LSAs.
By default, the new LSA translator works with the previous LSA translator to translate LSAs for 40 seconds. After 40 seconds, only the new LSA translator translates LSAs.
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 10 30 # interface Vlanif10 ip address 192.168.1.1 255.255.255.0 # interface Vlanif30 ip address 192.168.3.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 router-id 10.1.1.1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 area 0.0.0.1 network 192.168.3.0 0.0.0.255 nssa translator-always # return
SwitchB configuration file
# sysname SwitchB # vlan batch 20 40 # interface Vlanif20 ip address 192.168.2.1 255.255.255.0 # interface Vlanif40 ip address 192.168.4.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 40 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.2.2.2 area 0.0.0.0 network 192.168.2.0 0.0.0.255 area 0.0.0.1 network 192.168.4.0 0.0.0.255 nssa # return
SwitchC configuration file
# sysname SwitchC # vlan batch 10 20 # interface Vlanif10 ip address 192.168.1.2 255.255.255.0 # interface Vlanif20 ip address 192.168.2.2 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.3.3.3 area 0.0.0.0 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.255 # return
Configuration file of SwitchD
# sysname SwitchD # vlan batch 30 40 # interface Vlanif30 ip address 192.168.3.2 255.255.255.0 # interface Vlanif40 ip address 192.168.4.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 router-id 10.4.4.4 import-route static area 0.0.0.1 network 192.168.3.0 0.0.0.255 network 192.168.4.0 0.0.0.255 nssa # ip route-static 172.16.0.0 255.255.0.0 NULL0 # return
Example for Configuring OSPF Load Balancing
OSPF Load Balancing Overview
Equal-cost multiple path (ECMP) evenly load balances traffic over multiple paths between each two network nodes. ECMP reduces traffic load on each path and enhances network robustness. If a routing protocol discovers multiple routes to the same destination and these routes have the same cost, traffic can be load balanced among the routes. When load balancing is configured, the router forwards packets according to five factors, namely, the source addresses, destination addresses, source ports, destination ports, and protocols in the packets. If the five factors are the same, the router always chooses the next-hop address that is the same as the last one to send packets. If the five factors are different, the router chooses the relatively idle path to forward packets.
On an OSPF network, multiple equal-cost paths may exist between two network elements (NEs), while a single path carries all service traffic. Users require that all service traffic be load balanced over multiple paths to improve network reliability and resource usage. In this case, OSPF can be configured.
Configuration Notes
- The maximum number of equal-cost routes for load balancing can be configured using the maximum load-balancing command.
- To cancel load balancing, you can set the maximum number of equal-cost routes to 1.
- This example applies to the following products:
- S3700-EI, S3700-HI
- S5700-EI, S5700-HI, S5710-EI, S5710-HI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S5735-S, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-130, four switches all belong to Area0 on the OSPF network. Load balancing needs to be configured so that the traffic from SwitchA is sent to SwitchD through SwitchB and SwitchC.
In this scenario, ensure that all connected interfaces have STP disabled. If STP is enabled and VLANIF interfaces of switches are used to construct a Layer 3 ring network, an interface on the network will be blocked. As a result, Layer 3 services on the network cannot run normally.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic OSPF functions on each switch to implement basic connections on the OSPF network.
- Configure load balancing on SwitchA.
Procedure
- Configure VLANs to which each interface belongs.
# Configure SwitchA. The configurations of SwitchB, SwitchC, and SwitchD are similar.
<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
- Configure an IP address for each VLANIF interface.
# Configure SwitchA. The configurations of SwitchB, SwitchC, and SwitchD are similar.
[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
- Configure basic OSPF functions.
# 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
# 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
# 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
# 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
# Display the routing table of SwitchA.
[SwitchA] display ip routing-table Route Flags: R - relay, D - download to fib, T - to vpn-instance ------------------------------------------------------------------------------ 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
As shown in the routing table, two next hops 10.1.1.2 (SwitchB) and 10.1.2.2 (SwitchC) of SwitchA both become valid routes.
- Configure the weight of equal-cost routes on SwitchA.
If you do not want to implement load balancing between SwitchB and SwitchC, set the weight of equal-cost routes to specify the next hop.
[SwitchA] ospf 1 [SwitchA-ospf-1] nexthop 10.1.2.2 weight 1 //Specify the weight parameter to set the priority of equal-cost routes. The default weight value is 255. A larger priority value indicates a lower priority. [SwitchA-ospf-1] quit
# Check the routing table on SwitchA.
[SwitchA] display ip routing-table Route Flags: R - relay, D - download to fib, T - to vpn-instance ------------------------------------------------------------------------------ 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
As shown in the routing table, the priority of the next hop 10.1.2.2 (SwitchC) with the weight 1 is higher than that of 10.1.1.2 (SwitchB), after the weight is set for equal-cost routes. OSPF selects the route with the next hop 10.1.2.2 as the optimal route.
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 10 20 50 # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 # interface Vlanif20 ip address 10.1.2.1 255.255.255.0 # interface Vlanif50 ip address 172.16.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet1/0/3 port link-type trunk port trunk allow-pass vlan 50 # ospf 1 router-id 10.10.10.1 nexthop 10.1.2.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 172.16.1.0 0.0.0.255 # return
SwitchB configuration file
# sysname SwitchB # vlan batch 10 30 # interface Vlanif10 ip address 10.1.1.2 255.255.255.0 # interface Vlanif30 ip address 192.168.0.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 router-id 10.10.10.2 area 0.0.0.0 network 10.1.1.0 0.0.0.255 network 192.168.0.0 0.0.0.255 # return
SwitchC configuration file
# sysname SwitchC # vlan batch 20 40 # interface Vlanif20 ip address 10.1.2.2 255.255.255.0 # interface Vlanif40 ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 router-id 10.10.10.3 area 0.0.0.0 network 10.1.2.0 0.0.0.255 network 192.168.1.0 0.0.0.255 # return
SwitchD configuration file
# sysname SwitchD # vlan batch 30 40 60 # interface Vlanif30 ip address 192.168.0.2 255.255.255.0 # interface Vlanif40 ip address 192.168.1.2 255.255.255.0 # interface Vlanif60 ip address 172.17.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 40 # interface GigabitEthernet1/0/3 port link-type trunk port trunk allow-pass vlan 60 # ospf 1 router-id 10.10.10.4 area 0.0.0.0 network 172.17.1.0 0.0.0.255 network 192.168.0.0 0.0.0.255 network 192.168.1.0 0.0.0.255 # return
Example for Configuring BFD for OSPF
BFD for OSPF Overview
Bidirectional forwarding detection (BFD) is a mechanism used to detect communication faults between forwarding engines. BFD detects connectivity of a data protocol on a path between two systems. The path can be a physical or logical link. In BFD for OSPF, a BFD session is associated with OSPF. The BFD session quickly detects a link fault and then notifies OSPF of the fault. This speeds up OSPF's response to the change of the network topology.
Any link fault or topology change on the network will cause the device to recalculate routes. If the OSPF detection mechanism is used, the route recalculation time is the OSPF protocol convergence time. In this case, OSPF detects faults in seconds. In high-speed data transmission, for example, at gigabit rates, a detection time longer than one second results in the loss of a large amount of data. In delay-sensitive services such as voice, a delay longer than one second is unacceptable. When an OSPF network requires high reliability or the services running on the network are delay-sensitive, BFD for OSPF can be configured. BFD speeds up OSPF network convergence and then OSPF can detect the fault in milliseconds if a fault occurs in the link between neighbors.
Configuration Notes
- BFD needs to be configured on the two ends between which the OSPF neighbor relationship is established.
- The two ends that establish BFD sessions must be located in the same network segment on an OSPF area.
- The ospf bfd enable and ospf bfd block commands are mutually exclusive and cannot be enabled at the same time.
- This example applies to the following products:
- S3700-EI, S3700-HI
- S5700-EI, S5700-HI, S5710-EI, S5710-HI, S5720-SI, S5720S-SI, S5720I-SI, S5720-EI, S5720-HI, S5730-HI, S5730-SI, S5730S-EI, S5731-H, S5731-S, S5731S-S, S5731S-H, S5732-H, S5735-S, S5735S-S, S5735-S-I, S5735S-H, S5736-S
- S6700-EI, S6720-SI, S6720S-SI, S6720-EI, S6720S-EI, S6720-HI, S6730-H, S6730-S, S6730S-S, S6730S-H
- S7703, S7706, S7712, S7703 PoE, S7706 PoE, S9703, S9706, S9712
For the product models whose applicable versions are not listed above, see Table 3-1 in "Applicable Products and Versions" for details.
To view detailed information about software mappings, visit Info-Finder, select a product series or product model, and click Hardware Center.
Networking Requirements
As shown in Figure 3-131, OSPF runs among SwitchA, SwitchB, and SwitchC, and the switch between SwitchA and SwitchB only provides the transparent transmission function. SwitchA and SwitchB need to quickly detect the status of the link between them. When the link SwitchA->SwitchB is faulty, services can be quickly switched to the backup link SwitchA->SwitchC->SwitchB.
In this scenario, ensure that all connected interfaces have STP disabled. If STP is enabled and VLANIF interfaces of switches are used to construct a Layer 3 ring network, an interface on the network will be blocked. As a result, Layer 3 services on the network cannot run normally.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic OSPF functions on SwitchA, SwitchB, and SwitchC to implement basic connections on the OSPF network.
Configure BFD for OSPF on SwitchA, SwitchB, and SwitchC so that services can be quickly switched to the backup link when the link between SwitchA and SwitchB is faulty.
Procedure
- Configure VLANs to which each interface belongs.
# Configure SwitchA. The configurations of SwitchB and SwitchC are the same as the configuration of SwitchA.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 10 30 [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 30 [SwitchA-GigabitEthernet1/0/2] quit
- Configure an IP address for each VLANIF interface.
# Configure SwitchA. The configurations of SwitchB and SwitchC are similar.
[SwitchA] interface vlanif 10 [SwitchA-Vlanif10] ip address 10.1.1.1 24 [SwitchA-Vlanif10] quit [SwitchA] interface vlanif 30 [SwitchA-Vlanif30] ip address 10.3.3.1 24 [SwitchA-Vlanif30] quit
- Configure basic OSPF functions.
# 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 10.1.1.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] network 10.3.3.0 0.0.0.255 [SwitchA-ospf-1-area-0.0.0.0] quit [SwitchA-ospf-1] quit
# 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.2.2.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] network 10.3.3.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] network 172.16.1.0 0.0.0.255 [SwitchB-ospf-1-area-0.0.0.0] quit [SwitchB-ospf-1] quit
# 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.1.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] network 10.2.2.0 0.0.0.255 [SwitchC-ospf-1-area-0.0.0.0] quit [SwitchC-ospf-1] quit
# After the preceding configurations, run the display ospf peer command. The neighbor relationships are set up among SwitchA, SwitchB, and SwitchC. The command output of SwitchA is used as an example.
[SwitchA] display ospf peer OSPF Process 1 with Router ID 10.10.10.1 Neighbors Area 0.0.0.0 interface 10.1.1.1(Vlanif10)'s neighbors Router ID: 10.10.10.3 Address: 10.1.1.2 State: Full Mode:Nbr is Master Priority: 1 DR: 10.1.1.2 BDR: 10.1.1.1 MTU: 0 Dead timer due in 38 sec Retrans timer interval: 5 Neighbor is up for 00:00:15 Authentication Sequence: [ 0 ] Neighbors Area 0.0.0.0 interface 10.3.3.1(Vlanif30)'s neighbors Router ID: 10.10.10.2 Address: 10.3.3.2 State: Full Mode:Nbr is Master Priority: 1 DR: 10.3.3.2 BDR: 10.3.3.1 MTU: 0 Dead timer due in 25 sec Retrans timer interval: 5 Neighbor is up for 00:00:59 Authentication Sequence: [ 0 ]
# Check the OSPF routing table on SwitchA. You can see the routing entries to SwitchB and SwitchC. However, the next-hop address of the route to the destination network segment 172.16.1.0/24 is 10.3.3.2, which indicates that the traffic is transmitted on the link SwitchA→SwitchB.
[SwitchA] display ospf routing OSPF Process 1 with Router ID 10.10.10.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 10.1.1.0/24 1 Transit 10.1.1.1 10.10.10.1 0.0.0.0 10.3.3.0/24 1 Transit 10.3.3.1 10.10.10.1 0.0.0.0 10.2.2.0/24 2 Transit 10.1.1.2 10.10.10.3 0.0.0.0 10.2.2.0/24 2 Transit 10.3.3.2 10.10.10.3 0.0.0.0 172.16.1.0/24 2 Stub 10.3.3.2 10.10.10.2 0.0.0.0 Total Nets: 5 Intra Area: 5 Inter Area: 0 ASE: 0 NSSA: 0
- Configure BFD for OSPF.
# Configure BFD for OSPF on SwitchA.
[SwitchA] bfd //Enable BFD globally. [SwitchA-bfd] quit [SwitchA] ospf 1 [SwitchA-ospf-1] bfd all-interfaces enable //Enable BFD in OSPF process 1. [SwitchA-ospf-1] quit
# Configure BFD for OSPF on SwitchB.
[SwitchB] bfd //Enable BFD globally. [SwitchB-bfd] quit [SwitchB] ospf 1 [SwitchB-ospf-1] bfd all-interfaces enable //Enable BFD in OSPF process 1. [SwitchB-ospf-1] quit
# Configure BFD for OSPF on SwitchC.
[SwitchC] bfd //Enable BFD globally. [SwitchC-bfd] quit [SwitchC] ospf 1 [SwitchC-ospf-1] bfd all-interfaces enable //Enable BFD in OSPF process 1. [SwitchC-ospf-1] quit
# After the preceding configurations, run the display ospf bfd session all command on SwitchA, SwitchB, or SwitchC. The peer BFD session is Up. The command output of SwitchA is used as an example.
[SwitchA] display ospf bfd session all OSPF Process 1 with Router ID 10.10.10.1 Area 0.0.0.0 interface 10.1.1.1(Vlanif10)'s BFD Sessions NeighborId:10.10.10.3 AreaId:0.0.0.0 Interface:Vlanif10 BFDState:up rx :1000 tx :1000 Multiplier:3 BFD Local Dis:8195 LocalIpAdd:10.1.1.1 RemoteIpAdd:10.1.1.2 Diagnostic Info:No diagnostic information Area 0.0.0.0 interface 10.3.3.1(Vlanif30)'s BFD Sessions NeighborId:10.10.10.2 AreaId:0.0.0.0 Interface:Vlanif30 BFDState:up rx :1000 tx :1000 Multiplier:3 BFD Local Dis:8194 LocalIpAdd:10.3.3.1 RemoteIpAdd:10.3.3.2 Diagnostic Info:No diagnostic information
- Verify the configuration.
# Run the shutdown command on GE1/0/1 of SwitchB to simulate the link fault.
[SwitchB] interface gigabitethernet 1/0/1 [SwitchB-GigabitEthernet1/0/1] shutdown
# Check the OSPF routing table on SwitchA.
[SwitchA] display ospf routing OSPF Process 1 with Router ID 10.10.10.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 10.1.1.0/24 1 Transit 10.1.1.1 10.10.10.1 0.0.0.0 10.2.2.0/24 2 Transit 10.1.1.2 10.10.10.3 0.0.0.0 172.16.1.0/24 3 Stub 10.1.1.2 10.10.10.2 0.0.0.0 Total Nets: 3 Intra Area: 3 Inter Area: 0 ASE: 0 NSSA: 0
When the link SwitchA->SwitchB is faulty, the backup link SwitchA->SwitchC->SwitchB takes effect and the next-hop address of the route to the destination network segment 172.16.1.0/24 changes to 10.1.1.2.
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 10 30 # bfd # interface Vlanif10 ip address 10.1.1.1 255.255.255.0 # interface Vlanif30 ip address 10.3.3.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 30 # ospf 1 router-id 10.10.10.1 bfd all-interfaces enable area 0.0.0.0 network 10.1.1.0 0.0.0.255 network 10.3.3.0 0.0.0.255 # return
SwitchB configuration file
# sysname SwitchB # vlan batch 20 30 40 # bfd # interface Vlanif20 ip address 10.2.2.2 255.255.255.0 # interface Vlanif30 ip address 10.3.3.2 255.255.255.0 # interface Vlanif40 ip address 172.16.1.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # interface GigabitEthernet1/0/3 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 router-id 10.10.10.2 bfd all-interfaces enable area 0.0.0.0 network 10.2.2.0 0.0.0.255 network 10.3.3.0 0.0.0.255 network 172.16.1.0 0.0.0.255 # return
SwitchC configuration file
# sysname SwitchC # vlan batch 10 20 # bfd # interface Vlanif10 ip address 10.1.1.2 255.255.255.0 # interface Vlanif20 ip address 10.2.2.1 255.255.255.0 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 1 router-id 10.10.10.3 bfd all-interfaces enable area 0.0.0.0 network 10.1.1.0 0.0.0.255 network 10.2.2.0 0.0.0.255 # return