Example for Configuring OSPF Stub Areas
Networking Requirements
As shown in Figure 5-32, all switches run OSPF, and the entire AS is partitioned into three areas. Switch A and Switch B function as ABRs to advertise routes between areas; Switch D functions as the ASBR to import external routes (static routes).
It is required to configure Area 1 as a stub area to reduce the LSAs advertised to this area, which is expected not to affect the route reachability.
Configuration Roadmap
The configuration roadmap is as follows:
Configure basic OSPF functions on each switch to realize interconnection.
Configure static routes on Switch D and import them into OSPF.
Configure Area 1 as a stub area by running the stub command on all switches in Area 1, and check the OSPF routing information on Switch C.
Disable Switch A from advertising Type 3 LSAs to the stub area, and check the OSPF routing information on Switch C.
Procedure
- Assign an IP address to each interface. The configuration details are not provided here.
- Configure basic OSPF functions. For details, see Example for Configuring Basic OSPF Functions.
- Configure static routes on Switch D and import them into OSPF.
[~SwitchD] ip route-static 192.168.200.0 24 null 0
[*SwitchD] ospf 1
[*SwitchD-ospf-1] import-route static type 1
[*SwitchD-ospf-1] commit
[~SwitchD-ospf-1] quit
# Display ABR and ASBR information on Switch C.
[~SwitchC] display ospf abr-asbr
OSPF Process 1 with Router ID 10.3.3.3
Routing Table to ABR and ASBR
Type Destination Area Cost NextHop RtType
Intra-area 10.1.1.1 0.0.0.1 1 192.168.1.1 ABR
Inter-area 10.4.4.4 0.0.0.1 3 192.168.1.1 ASBR
# Display the OSPF routing table on Switch C.
If Switch C resides in a common area, external routes exist in the routing table.
[~SwitchC] display ospf routing
OSPF Process 1 with Router ID 10.3.3.3 Routing for Network -------------------------------------------------------------------------------- Destination Cost Type Next-Hop AdvRouter Area 172.16.1.0/24 1 Direct 172.16.1.1 10.3.3.3 0.0.0.1 172.17.1.0/24 4 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 192.168.1.0/24 1 Direct 192.168.1.2 10.1.1.1 0.0.0.1 192.168.2.0/24 3 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 Routing for ASEs -------------------------------------------------------------------------------- Destination Cost Type Tag NextHop AdvRouter 192.168.200.0/24 4 Type1 1 192.168.1.1 10.4.4.4 Total Nets: 6 Intra Area: 2 Inter Area: 3 ASE: 1 NSSA: 0
- Configure Area 1 as a stub area.
# Configure Switch A.
[~SwitchA] ospf 1
[*SwitchA-ospf-1] area 1
[*SwitchA-ospf-1-area-0.0.0.1] stub
[*SwitchA-ospf-1-area-0.0.0.1] commit
[~SwitchA-ospf-1-area-0.0.0.1] quit
[~SwitchA-ospf-1] quit
# Configure Switch C.
[~SwitchC] ospf 1
[*SwitchC-ospf-1] area 1
[*SwitchC-ospf-1-area-0.0.0.1] stub
[*SwitchC-ospf-1-area-0.0.0.1] commit
[~SwitchC-ospf-1-area-0.0.0.1] quit
[~SwitchC-ospf-1] quit
# Configure Switch E.
[~SwitchE] ospf 1
[*SwitchE-ospf-1] area 1
[*SwitchE-ospf-1-area-0.0.0.1] stub
[*SwitchE-ospf-1-area-0.0.0.1] commit
[~SwitchE-ospf-1-area-0.0.0.1] quit
[~SwitchE-ospf-1] quit
# Display the routing table on Switch C.
After the area where Switch C resides is configured as a stub area, a default route exists in the routing table, and no AS external route exists in the routing table.
[~SwitchC] display ospf routing
OSPF Process 1 with Router ID 10.3.3.3 Routing for Network -------------------------------------------------------------------------------- Destination Cost Type Next-Hop AdvRouter Area 0.0.0.0/0 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 172.16.1.0/24 1 Direct 172.16.1.1 10.3.3.3 0.0.0.1 172.17.1.0/24 4 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 192.168.1.0/24 1 Direct 192.168.1.2 10.3.3.3 0.0.0.1 192.168.2.0/24 3 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 Total Nets: 6 Intra Area: 2 Inter Area: 4 ASE: 0 NSSA: 0
- # Disable Switch A from advertising Type 3 LSAs to the stub area.
[~SwitchA] ospf
[*SwitchA-ospf-1] area 1
[*SwitchA-ospf-1-area-0.0.0.1] stub no-summary
[*SwitchA-ospf-1-area-0.0.0.1] commit
[~SwitchA-ospf-1-area-0.0.0.1] quit
- Verify the configuration.
# Display the OSPF routing table on Switch C.
[~SwitchC] display ospf routing
OSPF Process 1 with Router ID 10.3.3.3 Routing for Network -------------------------------------------------------------------------------- Destination Cost Type Next-Hop AdvRouter Area 0.0.0.0/0 2 Inter-area 192.168.1.1 10.1.1.1 0.0.0.1 172.16.1.0/24 1 Direct 172.16.1.1 10.3.3.3 0.0.0.1 192.168.1.0/24 1 Direct 192.168.1.2 10.3.3.3 0.0.0.1 Total Nets: 3 Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0
After the advertisement of summary LSAs to the stub area is disabled, the routing entries on devices in the stub area are further reduced, and only a default route to a destination outside the stub area is reserved.
Configuration Files
Configuration file of Switch A
# sysname SwitchA # vlan batch 10 20 # router id 10.1.1.1 # 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 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 20 # ospf 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
Configuration files of Switch B and Switch F are similar to the configuration file of Switch A, and are not provided here.
Configuration file of Switch C
# sysname SwitchC # vlan batch 20 40 # router id 10.3.3.3 # interface Vlanif20 ip address 192.168.1.2 255.255.255.0 # interface Vlanif40 ip address 172.16.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 20 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 area 0.0.0.1 network 192.168.1.0 0.0.0.255 network 172.16.1.0 0.0.0.255 stub # return
Configuration file of Switch D
# sysname SwitchD # vlan batch 30 50 # router id 10.4.4.4 # interface Vlanif30 ip address 192.168.2.2 255.255.255.0 # interface Vlanif50 ip address 172.17.1.1 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 30 # interface 10GE1/0/2 port link-type trunk port trunk allow-pass vlan 50 # ospf 1 import-route static type 1 area 0.0.0.2 network 192.168.2.0 0.0.0.255 network 172.17.1.0 0.0.0.255 # ip route-static 200.0.0.0 255.0.0.0 NULL0 # return
Configuration file of Switch E
# sysname SwitchE # vlan batch 40 # router id 10.5.5.5 # interface Vlanif40 ip address 172.16.1.2 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 40 # ospf 1 area 0.0.0.1 network 172.16.1.0 0.0.0.255 stub # return