基础配置
<Huawei>sys #进入配置模式
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en #关闭报文弹窗
Info: Information center is disabled.
[Huawei]sys R1 #设备名更改为R1
[R1]int g0/0/0 #进入接口
[R1-GigabitEthernet0/0/0]ip add 10.1.123.1 24 #配置IP地址
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 10.1.123.2 24
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 10.1.123.3 24
------------------
创建OSPF 1 区域0
[R1]ospf 1 router-id 1.1.1.1 #创建OSPF1 并设置router-id为1.1.1.1
[R1-ospf-1]a 0 #ospf设置区域为0(骨干区域)
[R1-ospf-1-area-0.0.0.0]net 10.1.123.1 0.0.0.0 #精准宣告接口IP地址
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]a 0
[R2-ospf-1-area-0.0.0.0]net 10.1.123.2 0.0.0.0
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]net 10.1.123.3 0.0.0.0
------------------
查看DR和BDR的选举
[R1]display ospf peer #查看接口的邻居信息
OSPF Process 1 with Router ID 1.1.1.1 #这里是自己的进程号1和自己的router-id
Neighbors
Area 0.0.0.0 interface 10.1.123.1(GigabitEthernet0/0/0)'s neighbors #这里介绍在区域0中的同广播域上与自己相连链路的邻居有哪些
Router ID: 2.2.2.2 Address: 10.1.123.2 #有2.2.2.2,对端与自己相连的链路的IP地址为10.1.123.2
State: Full Mode:Nbr is Master Priority: 1 #但前与邻居的关系为活动状态,同步DD数据表,当前自己为master主,对端的接口的优先级为1
DR: 10.1.123.1 BDR: 10.1.123.2 MTU: 0 #当前链路上DR为10.1.123.1,BDR为10.1.123.2
Dead timer due in 30 sec #邻居失效时间
Retrans timer interval: 5
Neighbor is up for 00:04:19 #建立邻居的总时间
Authentication Sequence: [ 0 ]
Router ID: 3.3.3.3 Address: 10.1.123.3
State: Full Mode:Nbr is Master Priority: 1
DR: 10.1.123.1 BDR: 10.1.123.2 MTU: 0
Dead timer due in 30 sec
Retrans timer interval: 5
Neighbor is up for 00:03:47
Authentication Sequence: [ 0 ]
以上邻居信息当中我们就可以知道在一条广播域当中有三台设备处于同一条链路当中分别是10.1.123.1,10.1.123.2,10.1.123.3,并且链路状态为FULL(同步DD报文)如下:
可以看到这两台路由中的LSDB是一样的,我们在根据邻居表信息表判断在链路中DR为10.1.123.1,BDR为10.1.123.2DRother为10.1.123.3
-------------------
查看OSPF接口信息
[R1]display ospf int g0/0/0
OSPF Process 1 with Router ID 1.1.1.1 #接口进程号为1 router-id为1.1.1.1
Interfaces
Interface: 10.1.123.1 (GigabitEthernet0/0/0) #接口的IP地址为...
Cost: 1 State: DR Type: Broadcast MTU: 1500 #开销为1,状态为DR,链路类型为广播,出口最大传输单元为1500字节
Priority: 1 #接口优先级1
Designated Router: 10.1.123.1 #指定端口ip
Backup Designated Router: 10.1.123.2 #备份端口IP
Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1 #发送HELLO包间隔时间10/s一次,失效时间40S
-----------------
指定更改DR
列:将R3更改为DR,R2更改为DRother,R1更改为BDR
由于OSPF中机制是无法通过更改优先级来进行抢占OSPF的DR,但是在OSPF中将优先级更改为0则表示将该接口指定更改为DRother,那么DR和BDR就会重新选举
更改方法:
1.将AR2接口优先级更改为0
2.将AR1接口优先级更改为0,此时R13就会进行重新选举成为DR
3.将AR1接口在更改为1,选举BDR
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ospf dr-priority 0
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ospf dr-priority 0
可以看到由于我们将R1和R2的接口优先级都改为0,使其成为DRother那么R3就会选举成为DR,我们再将R1的优先级改为1让R1在重新选举BDR
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ospf dr-priority 1