配置OSPF的DR选择示例
介绍在广播网络中,配置接口上的DR优先级进行DR选择的过程。
组网需求
在图5-11中,DeviceA接口的优先级为100,它是网络上的最高优先级,所以DeviceA被选为DR;DeviceC是优先级第二高的,被选为BDR;DeviceB的优先级为0,这意味着它将无法成为DR或BDR;DeviceD没有配置优先级,取缺省值1。
配置注意事项
重新配置设备的DR优先级后,仍不会改变网络中的DR或者BDR。可以利用下面两种方法重新进行DR或者BDR的选择,但是这会导致设备之间的OSPF邻接关系中断,一般情况下不推荐使用。
重启所有路由器上的OSPF进程。
在建立了OSPF邻居的接口上配置shutdown和undo shutdown命令。
配置思路
采用如下的思路配置OSPF的DR选择:
在各路由器上配置OSPF基本功能,实现互连。
在各路由器上配置Router ID。
在缺省优先级情况下,查看各路由器DR或者BDR状态。
配置接口上的DR优先级,查看DR或者BDR状态。
数据准备
为完成此配置例,需准备如下的数据:
DeviceA的Router ID 1.1.1.1,优先级100。
DeviceB的Router ID 2.2.2.2,优先级0。
DeviceC的Router ID 3.3.3.3,优先级2。
DeviceD的Router ID 4.4.4.4,优先级取缺省值1。
操作步骤
- 配置各接口的IP地址(略)
- 配置OSPF基本功能
# 配置DeviceA。
<HUAWEI> system-view
[~DeviceA] router id 1.1.1.1
[~DeviceA] ospf 1
[*DeviceA-ospf-1] area 0
[*DeviceA-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[*DeviceA-ospf-1-area-0.0.0.0] commit
[~DeviceA-ospf-1-area-0.0.0.0] quit
# 配置DeviceB。
<HUAWEI> system-view
[~DeviceB] router id 2.2.2.2
[~DeviceB] ospf 1
[*DeviceB-ospf-1] area 0
[*DeviceB-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[*DeviceB-ospf-1-area-0.0.0.0] commit
[~DeviceB-ospf-1-area-0.0.0.0] quit
# 配置DeviceC。
<HUAWEI> system-view
[~DeviceC] router id 3.3.3.3
[~DeviceC] ospf 1
[*DeviceC-ospf-1] area 0
[*DeviceC-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[*DeviceC-ospf-1-area-0.0.0.0] commit
[~DeviceC-ospf-1-area-0.0.0.0] quit
# 配置DeviceD。
<HUAWEI> system-view
[~DeviceD] router id 4.4.4.4
[~DeviceD] ospf 1
[*DeviceD-ospf-1] area 0
[*DeviceD-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255
[*DeviceD-ospf-1-area-0.0.0.0] commit
[~DeviceD-ospf-1-area-0.0.0.0] quit
# 查看DR或者BDR的状态。
[~DeviceA] display ospf peer
OSPF Process 1 with Router ID 1.1.1.1 Neighbors Area 0.0.0.0 interface 192.168.1.1 ( GE0/1/0 )'s neighbors Router ID: 2.2.2.2 Address: 192.168.1.2 State: 2-Way Mode:Nbr is Slave Priority: 1 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 32 sec Retrans timer interval: 0 Neighbor is up for Authentication Sequence: [ 0 ] Area 0.0.0.0 interface 192.168.1.1 ( GE0/1/0 )'s neighbors Router ID: 3.3.3.3 Address: 192.168.1.3 State: Full Mode:Nbr is Master Priority: 1 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 34 sec Retrans timer interval: 5 Neighbor is up for 00:02:17 Authentication Sequence: [ 0 ] Area 0.0.0.0 interface 192.168.1.1 ( GE0/1/0 )'s neighbors Router ID: 4.4.4.4 Address: 192.168.1.4 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 Retrans timer interval: 5 Neighbor is up for 00:02:17 Authentication Sequence: [ 0 ]
查看DeviceA的邻居信息,可以看到DR优先级(缺省为1)以及邻居状态,此时DeviceD为DR,DeviceC为BDR。
- 配置接口上的DR优先级
# 配置DeviceA。
[~DeviceA] interface gigabitethernet 0/1/0
[*DeviceA-GigabitEthernet0/1/0] ospf dr-priority 100
[*DeviceA-GigabitEthernet0/1/0] commit
[~DeviceA-GigabitEthernet0/1/0] quit
# 配置DeviceB。
[~DeviceB] interface gigabitethernet 0/1/0
[*DeviceB-GigabitEthernet0/1/0] ospf dr-priority 0
[*DeviceB-GigabitEthernet0/1/0] commit
[~DeviceB-GigabitEthernet0/1/0] quit
# 配置DeviceC。
[~DeviceC] interface gigabitethernet 0/1/0
[*DeviceC-GigabitEthernet0/1/0] ospf dr-priority 2
[*DeviceC-GigabitEthernet0/1/0] commit
[~DeviceC-GigabitEthernet0/1/0] quit
# 查看DR或者BDR的状态。
[~DeviceD] display ospf peer
OSPF Process 1 with Router ID 4.4.4.4 Neighbors Area 0.0.0.0 interface 192.168.1.4 ( GE0/1/0 )'s neighbors Router ID: 1.1.1.1 Address: 192.168.1.1 State: Full Mode:Nbr is Slave Priority: 100 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 38 sec Retrans timer interval: 5 Neighbor is up for 02:07:19 Authentication Sequence: [ 0 ] Area 0.0.0.0 interface 192.168.1.4 ( GE0/1/0 )'s neighbors Router ID: 2.2.2.2 Address: 192.168.1.2 State: Full Mode:Nbr is Slave Priority: 0 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 38 sec Retrans timer interval: 5 Neighbor is up for 02:07:19 Authentication Sequence: [ 0 ] Area 0.0.0.0 interface 192.168.1.4 ( GE0/1/0 )'s neighbors Router ID: 3.3.3.3 Address: 192.168.1.3 State: Full Mode:Nbr is Slave Priority: 2 DR: 192.168.1.4 BDR: 192.168.1.3 MTU: 0 Dead timer due in 30 sec Retrans timer interval: 5 Neighbor is up for 02:07:19 Authentication Sequence: [ 0 ]
- 重启OSPF进程
在各路由器的用户视图下,同时执行命令reset ospf 1 process,以重启OSPF进程。
- 验证配置结果
# 查看OSPF邻居状态。
[~DeviceD] display ospf peer
OSPF Process 1 with Router ID 4.4.4.4 Neighbors Area 0.0.0.0 interface 192.168.1.4 ( GE0/1/0 )'s neighbors Router ID: 1.1.1.1 Address: 192.168.1.1 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 Retrans timer interval: 5 Neighbor is up for 00:03:04 Authentication Sequence: [ 0 ] Area 0.0.0.0 interface 192.168.1.4 ( GE0/1/0 )'s neighbors Router ID: 2.2.2.2 Address: 192.168.1.2 State: 2-Way Mode:Nbr is Slave Priority: 0 DR: 192.168.1.1 BDR: 192.168.1.3 MTU: 0 Dead timer due in 35 sec Retrans timer interval: 0 Neighbor is up for Authentication Sequence: [ 0 ] Area 0.0.0.0 interface 192.168.1.4 ( GE0/1/0 )'s neighbors Router ID: 3.3.3.3 Address: 192.168.1.3 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 Retrans timer interval: 5 Neighbor is up for 00:03:03 Authentication Sequence: [ 0 ]
# 查看OSPF接口的状态。
[~DeviceA] display ospf interface
OSPF Process 1 with Router ID 1.1.1.1 Area: 0.0.0.0 MPLS TE not enabled Interface IP Address Type State Cost Pri GigabitEthernet0/1/0 192.168.1.1 Broadcast DR 1 100
[~DeviceB] display ospf interface
OSPF Process 1 with Router ID 2.2.2.2 Area: 0.0.0.0 MPLS TE not enabled Interface IP Address Type State Cost Pri GigabitEthernet0/1/0 192.168.1.2 Broadcast DROther 1 100
如果邻居的状态是Full,这说明它和邻居之间形成了邻接关系;如果停留在2-Way的状态,则说明两者都不是DR或BDR,两者之间不需要交换LSA。
如果OSPF接口的状态是DROther,则说明它既不是DR,也不是BDR。
配置文件
DeviceA的配置文件
#
sysname DeviceA
#
router id 1.1.1.1
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.1.1 255.255.255.0
ospf dr-priority 100
#
ospf 1
area 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return
DeviceB的配置文件
#
sysname DeviceB
#
router id 2.2.2.2
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.1.2 255.255.255.0
ospf dr-priority 0
#
ospf 1
area 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return
DeviceC的配置文件
#
sysname DeviceC
#
router id 3.3.3.3
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.1.3 255.255.255.0
ospf dr-priority 2
#
ospf 1
area 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return
DeviceD的配置文件
#
sysname DeviceD
#
router id 4.4.4.4
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.1.4 255.255.255.0
#
ospf 1
area 0.0.0.0
network 192.168.1.0 0.0.0.255
#
return