Example for Configuring DR Election of OSPF
Networking Requirements
As shown in Figure 5-34, SwitchA has the highest priority of 100 on the network and is elected as the DR; SwitchC has the second highest priority of 2 and is elected as the BDR; SwitchB has a priority of 0 and therefore cannot be elected as the DR or BDR; SwitchD is not configured with a priority and therefore uses the default priority of 1.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure the ID of the VLAN to which each interface belongs.
- Configure a VLANIF interface for each VLAN and assign an IP address to each VLANIF interface.
- Configure a router ID, enable OSPF, and specify network segments on each Switch.
- Check the DR/BDR status of each Switch using its default DR priority.
- Set the DR priority of the interface on each Switch and check the DR/BDR status on each Switch.
Procedure
- Configure a VLAN for each interface.
<HUAWEI> system-view [~HUAWEI] sysname SwitchA [*HUAWEI] commit [~SwitchA] vlan 10 [*SwitchA-vlan10] quit [*SwitchA] interface 10ge 1/0/1 [*SwitchA-10GE1/0/1] port link-type trunk [*SwitchA-10GE1/0/1] port trunk allow-pass vlan 10 [*SwitchA-10GE1/0/1] quit [*SwitchA] commit
The configurations of Switch B, Switch C, and Switch D are similar to the configuration of Switch A, and are not provided here.
- Configure a VLANIF interface for each VLAN and assign an IP address to each VLANIF interface.
[~SwitchA] interface vlanif 10 [*SwitchA-Vlanif10] ip address 192.168.1.1 24 [*SwitchA-Vlanif10] commit [~SwitchA-Vlanif10] quit
The configurations of SwitchB, SwitchC, and SwitchD are similar to the configuration of SwitchA, and are not provided here.
- Configure basic OSPF functions.
# Configure SwitchA.
[~SwitchA] router id 10.1.1.1 [*SwitchA] ospf [*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] quit [*SwitchA] commit
# Configure Switch B.
[~SwitchB] router id 10.2.2.2 [*SwitchB] ospf [*SwitchB-ospf-1] area 0 [*SwitchB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255 [*SwitchB-ospf-1-area-0.0.0.0] quit [*SwitchB-ospf-1] quit [*SwitchB] commit
# Configure SwitchC.
[~SwitchC] router id 10.3.3.3 [*SwitchC] ospf [*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] quit [*SwitchC-ospf-1] quit [*SwitchC] commit
# Configure SwitchD.
[~SwitchD] router id 10.4.4.4 [*SwitchD] ospf [*SwitchD-ospf-1] area 0 [*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] quit [*SwitchD-ospf-1] quit [*SwitchD] commit
# Display the neighbor information on SwitchA to check the DR and BDR status.
[~SwitchA] display ospf peer OSPF Process 1 with Router ID 10.1.1.1 Area 0.0.0.0 interface 192.168.1.1(Vlanif10)'s neighbors Router ID: 10.2.2.2 Address: 192.168.1.2 GR State: Normal State: Full Mode:Nbr is Master Priority: 1 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 32 sec Neighbor is up for 00:00:00 Authentication Sequence: [~ 0 ] Router ID: 10.3.3.3 Address: 192.168.1.3 GR State: Normal State: Full Mode:Nbr is Master Priority: 1 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 37 sec Neighbor is up for 00:04:06 Authentication Sequence: [~ 0 ] Router ID: 10.4.4.4 Address: 192.168.1.4 GR State: Normal State: Full Mode:Nbr is Master Priority: 1 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 37 sec Neighbor is up for 00:03:53 Authentication Sequence: [~ 0 ]
As shown in the neighbor information on SwitchA, the DR priority of SwitchA is the default value of 1 and its neighbor status indicates that SwitchD functions as the DR and SwitchC functions as the BDR.
When switches have the same DR priority, the switch with a higher router ID is elected as the DR. After DR/BDR election is complete, a new switch cannot become the DR even if it has the highest DR priority.
- Set the DR priority on each VLANIF interface.
# Configure SwitchA.
[~SwitchA] interface Vlanif 10 [~SwitchA-Vlanif10] ospf dr-priority 100 [*SwitchA-Vlanif10] quit [*SwitchA] commit
Configure Switch B.
[~SwitchB] interface Vlanif 10 [~SwitchB-Vlanif10] ospf dr-priority 0 [*SwitchB-Vlanif10] quit [*SwitchB] commit
# Configure SwitchC.
[~SwitchC] interface Vlanif 10 [~SwitchC-Vlanif10] ospf dr-priority 2 [*SwitchC-Vlanif10] quit [*SwitchC] commit
# Check the DR/BDR status.
[~SwitchD] display ospf peer OSPF Process 1 with Router ID 10.4.4.4 Area 0.0.0.0 interface 192.168.1.4(Vlanif10)'s neighbors Router ID: 10.1.1.1 Address: 192.168.1.1 GR State: Normal State: Full Mode:Nbr is Slave Priority: 100 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 31 sec Neighbor is up for 00:11:17 Authentication Sequence: [~ 0 ] Router ID: 10.2.2.2 Address: 192.168.1.2 GR State: Normal State: Full Mode:Nbr is Slave Priority: 0 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 35 sec Neighbor is up for 00:11:19 Authentication Sequence: [~ 0 ] Router ID: 10.3.3.3 Address: 192.168.1.3 GR State: Normal State: Full Mode:Nbr is Slave Priority: 2 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 33 sec Neighbor is up for 00:11:15 Authentication Sequence: [~ 0 ]
The DR priorities configured on interfaces do not take effect immediately.
- Restart the OSPF processes.
In the user view of each Switch, run the reset ospf 1 process command simultaneously to restart the OSPF processes.
- Verify the configuration.
# Check the OSPF neighbor status.
[~SwitchD] display ospf peer OSPF Process 1 with Router ID 10.4.4.4 Area 0.0.0.0 interface 192.168.1.4(Vlanif10)'s neighbors Router ID: 10.1.1.1 Address: 192.168.1.1 GR State: Normal State: Full Mode:Nbr is Slave Priority: 100 DR: 192.168.1.1 BDR: 192.168.1.3 MTU: 0 Dead timer due in 35 sec Neighbor is up for 00:07:19 Authentication Sequence: [~ 0 ] Router ID: 10.2.2.2 Address: 192.168.1.2 GR State: Normal State: Full Mode:Nbr is Master Priority: 0 DR: 192.168.1.1 BDR: 192.168.1.3 MTU: 0 Dead timer due in 35 sec Neighbor is up for 00:00:00 Authentication Sequence: [~ 0 ] Router ID: 10.3.3.3 Address: 192.168.1.3 GR State: Normal State: Full Mode:Nbr is Slave Priority: 2 DR: 192.168.1.1 BDR: 192.168.1.3 MTU: 0 Dead timer due in 37 sec Neighbor is up for 00:07:17 Authentication Sequence: [~ 0 ]
# Check the OSPF interface status.
[~SwitchA] display ospf interface OSPF Process 1 with Router ID 10.1.1.1 Area: 0.0.0.0 (MPLS TE not enabled) Interface IP Address Type State Cost Pri Vlanif10 192.168.1.1 Broadcast DR 1 1 [~SwitchB] display ospf interface OSPF Process 1 with Router ID 10.2.2.2 Area: 0.0.0.0 (MPLS TE not enabled) Interface IP Address Type State Cost Pri Vlanif10 192.168.1.2 Broadcast DROther 1 0
If all neighbors are in Full state, the local device establishes adjacencies with all its neighbors. If a neighbor stays in 2-way state, neither the local device nor the neighbor is the DR or BDR, and therefore they do not need to exchange LSAs.
If the OSPF interface of a device is in DROther state, the device is neither the DR nor the BDR.
Configuration Files
Configuration file of SwitchA
# sysname SwitchA # vlan batch 10 # router id 10.1.1.1 # interface Vlanif10 ip address 192.168.1.1 255.255.255.0 ospf dr-priority 100 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 # return
Configuration file of SwitchB
# sysname SwitchB # vlan batch 10 # router id 10.2.2.2 # interface Vlanif10 ip address 192.168.1.2 255.255.255.0 ospf dr-priority 0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 # return
Configuration file of SwitchC
# sysname SwitchC # vlan batch 10 # router id 10.3.3.3 # interface Vlanif10 ip address 192.168.1.3 255.255.255.0 ospf dr-priority 2 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 # return
Configuration file of SwitchD
# sysname SwitchD # vlan batch 10 # router id 10.4.4.4 # interface Vlanif10 ip address 192.168.1.4 255.255.255.0 # interface 10GE1/0/1 port link-type trunk port trunk allow-pass vlan 10 # ospf 1 area 0.0.0.0 network 192.168.1.0 0.0.0.255 # return