登录站点

用户名

密码

OSPF协议在广播网络中DR选举

4已有 4628 次阅读  2012-05-22 08:54   标签路由器  做什么  blank  router  target 

OSPF协议在广播网络中DR选举

OSPF中,有两个相当重要的概念:DR和BDR。我们先来看看什么叫DR,什么叫BDR,然后再来看看他们都是做什么的。

DR:designated router 指定路由器
BDR:backup designated router 备份指定路由器

在一个LAN 连接中,OSPF将选举出一个路由器做为DR,再选举一个做为BDR,所有其他的和DR以及BDR相连的路由器形成完全邻接状态而且只传输LSA(链路状态通告)给DR和BDR。

[CCNA] OSPF协议在广播网络中DR选举试验拓扑图

  • 完成各设备的基本配置

Router>enable
Router#config term
Router(config)#hostname R1
R1(config)#interface f0/0
R1(config‐if)#ip address 192.168.1.1 255.255.255.0
R1(config‐if)#no shutdown
R1(config‐if)#interface loop 0
R1(config‐if )#ip address 1.1.1.1 255.255.255.0
R2,R3 配置略过

R1
R1(config)#router ospf 1
R1(config‐router)#network 1.1.1.1 0.0.0.0 area 0
R1(config‐router)#network 192.168.1.0 0.0.0.255 area 0
R2
R2(config)#router ospf 1
R2(config‐router)#network 2.2.2.0 0.0.0.255 area 0
R2(config‐router)#network 192.168.1.0 0.0.0.255 area 0
R3
R3(config)#router ospf 1
R3(config‐router)#network 3.3.3.0 0.0.0.255 area 0
R3(config‐router)#network 192.168.1.0 0.0.0.255 area 0

如果路由器上没有配置loopback 接口,物理接口IP 地址最高的将成为该路由器的ID,如果配置了loopback 接口,loopback 接口IP 地址高将成为路由器的ID,所以我们可以看到各自路由器的router‐id。

R1#show ip protocol
Routing Protocol is “ospf 1″
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 1.1.1.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
1.1.1.1 0.0.0.0 area 0
192.168.1.0 0.0.0.255 area 0
Reference bandwidth unit is 100 mbps
Routing Information Sources:
Gateway Distance Last Update
192.168.1.3 110 00:00:21
Distance: (default is 110)

R2#show ip protocol
Routing Protocol is “ospf 1″
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 2.2.2.2
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
2.2.2.0 0.0.0.255 area 0
192.168.1.0 0.0.0.255 area 0
Reference bandwidth unit is 100 mbps
Routing Information Sources:
Gateway Distance Last Update
Distance: (default is 110)

R3#show ip protocol
Routing Protocol is “ospf 1″
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 3.3.3.3
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
3.3.3.0 0.0.0.255 area 0
192.168.1.0 0.0.0.255 area 0
Reference bandwidth unit is 100 mbps
Routing Information Sources:
Gateway Distance Last Update
1.1.1.1 110 00:00:32
2.2.2.2 110 00:05:36
192.168.1.1 110 00:06:07
Distance: (default is 110)

察看OSPF 的邻居关系,了解DR/BDR 的选举原则。

R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:35 192.168.1.2 FastEthernet0/0
3.3.3.3 1 FULL/DR 00:00:34 192.168.1.3 FastEthernet0/0
//广播网络中,OSPF 的DR/BDR 的选举原则为当优先级相同的情况下Router‐ID 高的为DR,
次高的成为BDR,所以R3(Router‐id 为3.3.3.3)成为DR,R2 成为BDR

R2#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
1.1.1.1 1 FULL/DROTHER 00:00:31 192.168.1.1 FastEthernet0/0
3.3.3.3 1 FULL/DR 00:00:39 192.168.1.3 FastEthernet0/0
//R1 和R2 的关系为DROTHER

R3#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
1.1.1.1 1 FULL/DROTHER 00:00:31 192.168.1.1 FastEthernet0/0
2.2.2.2 1 FULL/BDR 00:00:30 192.168.1.2 FastEthernet0/0

查看OSPF协议接口信息

R1#show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DROTHER, Priority 1
  Designated Router (ID) 3.3.3.3, Interface address 192.168.1.3
  Backup Designated router (ID) 2.2.2.2, Interface address 192.168.1.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob‐resync timeout 40
Hello due in 00:00:06
Supports Link‐local Signaling (LLS)
Index 2/2, flood queue length 0
Next 0×0(0)/0×0(0)
Last flood scan length is 0, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor 2.2.2.2 (Backup Designated Router)
Adjacent with neighbor 3.3.3.3 (Designated Router)
Suppress hello for 0 neighbor(s)
Loopback0 is up, line protocol is up
Internet Address 1.1.1.1/24, Area 0
Process ID 1, Router ID 1.1.1.1, Network Type LOOPBACK, Cost: 1
Loopback interface is treated as a stub Host

查看路由表信息

R1#show ip route
Codes: C ‐ connected, S ‐ static, R ‐ RIP, M ‐ mobile, B ‐ BGP
D ‐ EIGRP, EX ‐ EIGRP external, O ‐ OSPF, IA ‐ OSPF inter area
N1 ‐ OSPF NSSA external type 1, N2 ‐ OSPF NSSA external type 2
E1 ‐ OSPF external type 1, E2 ‐ OSPF external type 2
i ‐ IS‐IS, su ‐ IS‐IS summary, L1 ‐ IS‐IS level‐1, L2 ‐ IS‐IS level‐2
ia ‐ IS‐IS inter area, * ‐ candidate default, U ‐ per‐user static route
o ‐ ODR, P ‐ periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C        1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O        2.2.2.2 [110/2] via 192.168.1.2, 00:01:46, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O        3.3.3.3 [110/2] via 192.168.1.3, 00:01:46, FastEthernet0/0
C      192.168.1.0/24 is directly connected, FastEthernet0/0

  • 手工指定路由器 ID

R1(config)#router ospf 1
R1(config‐router)#router-id 192.168.1.1
R1(config‐router)#end

修改后需要重新启动OSPF 进程
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R3#clear ip ospf process
Reset ALL OSPF processes? [no]: yes

验证结果

R1#show ip protocol
Routing Protocol is “ospf 1″
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.1.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
1.1.1.1 0.0.0.0 area 0
192.168.1.0 0.0.0.255 area 0
Reference bandwidth unit is 100 mbps
Routing Information Sources:
Gateway Distance Last Update
2.2.2.2 110 00:00:03
3.3.3.3 110 00:00:03
192.168.1.3 110 00:03:31
Distance: (default is 110)

R1#show ip ospf neig
Neighbor ID Pri State  Dead Time Address     Interface
  2.2.2.2 1 FULL/DROTHER 00:00:38  192.168.1.2 FastEthernet0/0
  3.3.3.3 1 FULL/BDR     00:00:39  192.168.1.3 FastEthernet0/0
//发现DR/BDR 重新进行了选举,R1 的Router‐id 为192.168.1.1 最大成为DR.R3 成为BDR

R1#show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.1/24, Area 0
Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1 //优先级
  Designated Router (ID) 192.168.1.1, Interface address 192.168.1.1
  Backup Designated router (ID) 3.3.3.3, Interface address 192.168.1.3
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob‐resync timeout 40
Hello due in 00:00:08
Supports Link‐local Signaling (LLS)
Index 2/2, flood queue length 0
Next 0×0(0)/0×0(0)
Last flood scan length is 1, maximum is 2
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor 2.2.2.2
Adjacent with neighbor 3.3.3.3 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
Loopback0 is up, line protocol is up
Internet Address 1.1.1.1/24, Area 0
Process ID 1, Router ID 192.168.1.1, Network Type LOOPBACK, Cost: 1
Loopback interface is treated as a stub Host

R2#show ip ospf neighbor

  Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 1 FULL/BDR 00:00:30 192.168.1.3 FastEthernet0/0
192.168.1.1 1 FULL/DR 00:00:38 192.168.1.1 FastEthernet0/0

R3#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/DROTHER 00:00:37 192.168.1.2 FastEthernet0/0
192.168.1.1 1 FULL/DR 00:00:36 192.168.1.1 FastEthernet0/0

  • 修改接口 OSPF 优先级来改变DR/BDR 的选举

R2(config)#interface f0/0
R2(config‐if)#ip ospf priority 255
//将R2 的OSPF 接口F0/0 优先级修改为最大255

修改后需要重新启动OSPF 进程
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R3#clear ip ospf process
Reset ALL OSPF processes? [no]: yes

验证结果

R2#show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 192.168.1.2/24, Area 0
Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 255
Designated Router (ID) 2.2.2.2, Interface address 192.168.1.2
  Backup Designated router (ID) 192.168.1.1, Interface address 192.168.1.1
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob‐resync timeout 40
Hello due in 00:00:03
Supports Link‐local Signaling (LLS)
Index 2/2, flood queue length 0
Next 0×0(0)/0×0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor 3.3.3.3
Adjacent with neighbor 192.168.1.1 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
Loopback0 is up, line protocol is up
Internet Address 2.2.2.2/24, Area 0
Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
Loopback interface is treated as a stub Host
//因为我们调整了R2 的优先级为255,也就是说R2 始终为DR

R1#show ip ospf neighbor

  Neighbor ID Pri State Dead Time Address Interface
  2.2.2.2 255 FULL/DR 00:00:35 192.168.1.2 FastEthernet0/0
3.3.3.3 1 FULL/DROTHER 00:00:37 192.168.1.3 FastEthernet0/0

R2#show ip ospf neighbor

  Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 1 FULL/DROTHER 00:00:34 192.168.1.3 FastEthernet0/0
192.168.1.1 1 FULL/BDR 00:00:39 192.168.1.1 FastEthernet0/0

R3#show ip ospf neighbor

  Neighbor ID Pri State Dead Time Address Interface
  2.2.2.2 255 FULL/DR 00:00:35 192.168.1.2 FastEthernet0/0
  192.168.1.1 1 FULL/BDR 00:00:32 192.168.1.1 FastEthernet0/0

分享 举报

发表评论 评论 (3 个评论)

涂鸦板