通过本实验可以了解:

1、 路由器OSPF的启动过程;

2、 启用路由接口,并通告网络所在路由;

3、 DR选举的控制;

4、 广播多路访问链路的特征;

实验拓扑图:

实验步骤:

配置各个路由器fa0/0和loopback 0的IP地址,并配置OSPF路由协议

R1的ospf配置如下:

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 192.168.1.0 255.255.255.0 area 0

R1(config-router)#network 1.1.1.0 255.255.255.0 area 0

R2、R3、R4与之类似。

当所有配置完成之后,在R1、R2上查看路由信息,可以看到DR,BDR的选举正在进行

clip_p_w_picpath004

clip_p_w_picpath006

再到R4上执行“show ip ospf neighbor”

clip_p_w_picpath008

以上实验输出表明在该广播多路访问网络中,R4是DR,R3是BDR,R1和R2是DROTHER。

【注】:

1、为了避免路由器之间建立完全邻接关系而引起的大量开销,OSPF协议要求在多路访问链路中选举一个DR,每个路由器都与之建立邻接关系。选举DR的同时,也选举一个BDR。在DR失效的时候,BDR担负起DR的责任,而且所有其他路由器只与DR和BDR建立邻接关系;

2、DR和BDR有他们自己的组播地址224.0.0.6;

3、DR和BDR的选举是以各个网络为基础的,也就是说DR和BDR选举是一个;路由器的接口特性,而不是整个路由器的特性;

4、DR的选举规则为:

①首要因素是时间,最先启动的路由器被选举为DR;

②如果是同时启动,或者重新选举,则看接口优先级(范围是0--255),优先级最高的被选举为DR,默认情况下,多路访问网络的接口优先级为1,点到点的接口优先级为0,修改优先级的命令为“ip ospf priority ”,如果接口的优先级被置为0,那么该接口将不参与DR的选举;

③如果前两者相同,最后看路由器ID,路由器最高的被选举为DR;

5、DR选举是非抢占的,除非人为地重新选举,重新选举的方法有两种,一是路由器重启,二是执行“clear ip ospf process”命令;

在R1上执行show ip ospf int fastEthernet 0/0命令

clip_p_w_picpath010

R1#show ip ospf int fa0/0

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

//网络类型为BROADCAST;

Transmit Delay is 1 sec, State DROTHER, Priority 1

//自己的State是DROTHER;

Designated Router (ID) 4.4.4.4, Interface address 192.168.1.4

//DR的路由器ID和接口地址;

Backup Designated router (ID) 3.3.3.3, Interface address 192.168.1.3

//BDR的路由器ID和接口地址;

Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

oob-resync timeout 40

Hello due in 00:00:09

Supports Link-local Signaling (LLS)

Index 2/2, flood queue length 0

Next 0x0(0)/0x0(0)

Last flood scan length is 0, maximum is 1

Last flood scan time is 0 msec, maximum is 0 msec

Neighbor Count is 3, Adjacent neighbor count is 2

//有3个邻居,只与R3、R4形成邻接关系,与R2只是邻居关系;

Adjacent with neighbor 3.3.3.3 (Backup Designated Router)

Adjacent with neighbor 4.4.4.4 (Designated Router)

//与R3、R4形成邻接关系;

Suppress hello for 0 neighbor(s)

 

 

在R4上执行show ip ospf int fastEthernet 0/0命令

R4#show ip ospf int fastEthernet 0/0

FastEthernet0/0 is up, line protocol is up

Internet Address 192.168.1.4/24, Area 0

Process ID 1, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 1

Transmit Delay is 1 sec, State DR, Priority 1

//自己是DR;

Designated Router (ID) 4.4.4.4, Interface address 192.168.1.4

//DR路由器的ID和接口地址;

Backup Designated router (ID) 3.3.3.3, Interface address 192.168.1.3

//BDR路由器的ID和接口地址;

Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

oob-resync timeout 40

Hello due in 00:00:07

Supports Link-local Signaling (LLS)

Index 1/1, flood queue length 0

Next 0x0(0)/0x0(0)

Last flood scan length is 1, maximum is 1

Last flood scan time is 4 msec, maximum is 4 msec

Neighbor Count is 3, Adjacent neighbor count is 3

//R4是DR,有3个邻居,并且全部形成邻接关系;

Adjacent with neighbor 1.1.1.1

Adjacent with neighbor 2.2.2.2

Adjacent with neighbor 3.3.3.3 (Backup Designated Router)

Suppress hello for 0 neighbor(s)

从路由器的R1和R4的输出来看,邻居关系和邻接关系是不相同的,邻居关系是指达到2WAY状态的路由器,而邻接关系是指达到FULL状态的路由器。

Debug ip ospf adj 命令显示邻接关系的创建或中断的过程。在OSPF邻接关系创建的过程中,接口状态变化包括:DOWN,2WAY,EXSTART,EXCHANGE,LOADING,FULL

 

 

R4# debug ip ospf adj

OSPF adjacency events debugging is on

R4#clear ip ospf process

………………

*Mar 1 00:09:44.811: OSPF: Elect DR 3.3.3.3

*Mar 1 00:09:44.811: DR: 3.3.3.3 (Id) BDR: 4.4.4.4 (Id)

*Mar 1 00:09:47.495: OSPF: 3.3.3.3 address 192.168.1.3 on FastEthernet0/0 is dead

*Mar 1 00:09:47.495: OSPF: 3.3.3.3 address 192.168.1.3 on FastEthernet0/0 is dead, state DOWN

………………

*Mar 1 00:09:47.495: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired

*Mar 1 00:09:47.499: OSPF: Neighbor change Event on interface FastEthernet0/0

*Mar 1 00:09:47.499: OSPF: DR/BDR election on FastEthernet0/0

………………

*Mar 1 00:10:05.791: OSPF: 2 Way Communication to 3.3.3.3 on FastEthernet0/0, state 2WAY

*Mar 1 00:10:05.791: OSPF: Neighbor change Event on interface FastEthernet0/0

*Mar 1 00:10:05.791: OSPF: DR/BDR election on FastEthernet0/0

*Mar 1 00:10:05.795: OSPF: Elect BDR 1.1.1.1

*Mar 1 00:10:05.795: OSPF: Elect DR 4.4.4.4

*Mar 1 00:10:05.795: DR: 4.4.4.4 (Id) BDR: 1.1.1.1 (Id)

*Mar 1 00:10:05.795: OSPF: Send DBD to 3.3.3.3 on FastEthernet0/0 seq 0x6CD opt 0x52 flag 0x7 len 32

………………

*Mar 1 00:10:06.703: OSPF: Rcv DBD from 3.3.3.3 on FastEthernet0/0 seq 0x8AF opt 0x52 flag 0x7 len 32 mtu 1500 state EXSTART

*Mar 1 00:10:06.703: OSPF: First DBD and we are not SLAVE

*Mar 1 00:10:06.727: OSPF: Rcv DBD from 3.3.3.3 on FastEthernet0/0 seq 0x6CD opt 0x52 flag 0x2 len 132 mtu 1500 state EXSTART

*Mar 1 00:10:06.727: OSPF: NBR Negotiation Done. We are the MASTER

*Mar 1 00:10:06.731: OSPF: Send DBD to 3.3.3.3 on FastEthernet0/0 seq 0x6CE opt 0x52 flag 0x3 len 132

*Mar 1 00:10:07.063: OSPF: Rcv DBD from 3.3.3.3 on FastEthernet0/0 seq 0x6CE opt 0x52 flag 0x0 len 32 mtu 1500 state EXCHANGE

*Mar 1 00:10:07.063: OSPF: Send DBD to 3.3.3.3 on FastEthernet0/0 seq 0x6CF opt 0x52 flag 0x1 len 32

*Mar 1 00:10:07.111: OSPF: Rcv LS UPD from 3.3.3.3 on FastEthernet0/0 length 88 LSA count 1

*Mar 1 00:10:07.115: OSPF: Rcv LS UPD from 3.3.3.3 on FastEthernet0/0 length 68 LSA count 1

*Mar 1 00:10:07.183: OSPF: Rcv LS REQ from 3.3.3.3 on FastEthernet0/0 length 36 LSA count 1

*Mar 1 00:10:07.187: OSPF: Send UPD to 192.168.1.3 on FastEthernet0/0 length 52 LSA count 1

*Mar 1 00:10:07.187: OSPF: Rcv DBD from 3.3.3.3 on FastEthernet0/0 seq 0x6CF opt 0x52 flag 0x0 len 32 mtu 1500 state EXCHANGE

*Mar 1 00:10:07.187: OSPF: Exchange Done with 3.3.3.3 on FastEthernet0/0

*Mar 1 00:10:07.187: OSPF: Synchronized with 3.3.3.3 on FastEthernet0/0, state FULL

*Mar 1 00:10:07.191: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done

………………