1 Common OSPF Operations
This chapter uses the Open Shortest Path First (OSPF) network shown in Figure 1 as an example to describe common OSPF operations.
Figure
1 Basic OSPF network

Configuring Basic OSPF Functions
The following uses the configuration of SwitchA as an example. The configurations of other switches are similar to the configuration of SwitchA.
<SwitchA> system-view
[SwitchA] ospf 1
[SwitchA-ospf-1] area 0
[SwitchA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255 //Enable OSPF on VLANIF10.
[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 //Enable OSPF on VLANIF20.
[SwitchA-ospf-1-area-0.0.0.1] quit
[SwitchA-ospf-1] quit
Configuring a Stub Area
A stub area is a special area where an area border router (ABR) does not flood received autonomous system (AS) external routes, which significantly reduces the routing table size and transmitted routing information of routers. A border area on an OSPF network is often configured as a stub area. For example, configure Area1 as a stub area.
The following uses the configuration of SwitchA as an example. The configurations of other switches in Area1 are similar to the configuration of SwitchA.
[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] quit
[SwitchA-ospf-1] quit
Configuring an NSSA
In a not-so-stubby area (NSSA), an ABR does not flood AS external routes received from other areas, similar to the situation in a stub area. The difference is that an ABR can import and flood AS external routes to the entire OSPF domain. A border area connected to another AS on an OSPF network is often configured as an NSSA. For example, configure Area2 as an NSSA.
The following uses the configuration of SwitchB as an example. The configurations of other switches in Area2 are similar to the configuration of SwitchB.
[SwitchB] ospf 1
[SwitchB-ospf-1] area 2
[SwitchB-ospf-1-area-0.0.0.2] nssa
[SwitchB-ospf-1-area-0.0.0.2] quit
[SwitchB-ospf-1] quit
Configuring OSPF to Import Routes
To access a device running a non-OSPF protocol, an OSPF-capable device needs to import routes of the non-OSPF protocol into the OSPF network. For example, configure OSPF to import direct routes of SwitchF into the OSPF network.
[SwitchF] ospf 1
[SwitchF-ospf-1] import-route direct
[SwitchF-ospf-1] quit
Setting the OSPF Interface Cost
OSPF automatically calculates the cost of an interface according to the interface bandwidth by default. You can also manually set the OSPF interface cost. For example, set the cost of VLANIF 20 on SwitchA to 5.
[SwitchA] interface vlanif 20
[SwitchA-Vlanif20] ospf cost 5
[SwitchA-Vlanif20] quit
Configuring Association Between OSPF and BFD
To accelerate OSPF convergence when the status of a link changes, you can configure bidirectional forwarding detection (BFD) on OSPF links. After detecting a link failure, BFD notifies OSPF of the failure, which triggers fast OSPF convergence. When the OSPF neighbor relationship is Down, the BFD session is deleted dynamically.
For example, set up a BFD session on the OSPF link between SwitchA and SwitchB.
# Configure SwitchA.
[SwitchA] bfd
[SwitchA-bfd] quit
[SwitchA] ospf 1
[SwitchA-ospf-1] bfd all-interfaces enable
[SwitchA-ospf-1] quit
# Configure SwitchB.
[SwitchB] bfd
[SwitchB-bfd] quit
[SwitchB] ospf 1
[SwitchB-ospf-1] bfd all-interfaces enable
[SwitchB-ospf-1] quit
Configuring OSPF to Advertise Default Routes
Multiple switches for next-hop backup or traffic load balancing often reside on the area border and AS border of an OSPF network. A default route can be configured to reduce routing entries and improve resource usage on the OSPF network.
The advertising mode of the default route is determined by the type of the area to which the default route is imported, as shown in Table 1.
Table 1 Default route advertising mode |
||||
Area Type |
Generated By |
Advertised By |
LSA Type |
Flooding Area |
Common area |
The default-route-advertise command |
ASBR |
Type5 LSA |
Common area |
Stub area |
Automatically |
ABR |
Type3 LSA |
Stub area |
NSSA |
The nssa [ default-route-advertise ] command |
ASBR |
Type7 LSA |
NSSA |
Totally NSSA |
Automatically |
ABR |
Type3 LSA |
NSSA |
This post was last edited by 神出鬼没 at 2017-08-25 06:15.