一、             实验目的

1、  掌握OSPF协议的单区域配置。

2、  掌握相关show,debug命令查看OSPF的信息。

3、  配置OSPF协议的验证。

4、  查看DR/BDR的选举过程。

二、             实验拓扑

CCNP路由实验---7、单区域的OSPF配置_第1张图片

三、             配置步骤

1、  根据拓扑图配置好各个路由器的接口IP地址,使用ping命令测试。

R1:

R1(config)#int fa0/0

R1(config-if)#ip add 172.16.1.1 255.255.255.0

R1(config-if)#no shut

R1(config)#int loop 0

R1(config-if)#ip add 172.16.31.11 255.255.255.0

       R2R3的接口IP地址配置参考拓扑去进行配置好就可以了。

2、  在每台路由器上启用OSPF协议。

R1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#router ospf 1

R1(config-router)#network 172.16.1.0 0.0.0.255 area 0

R1(config-router)#end

        R2R3的配置类似。

3、  配置完成后使用命令show ip protocols查看3台路由器上的OSPF协议的配置信息。

R1#sh ip protocols

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 172.16.31.11

  Number of areas in this router is 1. 1 normal 0 stub 0 nssa

  Maximum path: 4

  Routing for Networks:

    172.16.1.0 0.0.0.255 area 0

  Routing Information Sources:

    Gateway         Distance      Last Update

  Distance: (default is 110)

也可以用show ip ospf命令查看详细的OSPF信息,包括Router ID,分别查看3台路由器的Router ID.

R1#sh ip ospf    

 Routing Process "ospf 1" with ID 172.16.31.11

 Supports only single TOS(TOS0) routes

 Supports opaque LSA

 Supports Link-local Signaling (LLS)

 Initial SPF schedule delay 5000 msecs

 Minimum hold time between two consecutive SPFs 10000 msecs

 Maximum wait time between two consecutive SPFs 10000 msecs

 Minimum LSA interval 5 secs. Minimum LSA arrival 1 secs

 LSA group pacing timer 240 secs

 Interface flood pacing timer 33 msecs

 Retransmission pacing timer 66 msecs

 Number of external LSA 0. Checksum Sum 0x000000

 Number of opaque AS LSA 0. Checksum Sum 0x000000

 Number of DCbitless external and opaque AS LSA 0

 Number of DoNotAge external and opaque AS LSA 0

 Number of areas in this router is 1. 1 normal 0 stub 0 nssa

 External flood list length 0

    Area BACKBONE(0)

        Number of interfaces in this area is 1

        Area has no authentication

        SPF algorithm last executed 00:02:32.016 ago

        SPF algorithm executed 3 times

        Area ranges are

        Number of LSA 4. Checksum Sum 0x025CAD

        Number of opaque link LSA 0. Checksum Sum 0x000000

        Number of DCbitless LSA 0

        Number of indication LSA 0

        Number of DoNotAge LSA 0

        Flood list length 0

或者用show ip ospf neighbor查看OSPF邻接路由器信息和角色。

 

 

 

R1# sh ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

172.16.31.22      1   FULL/BDR        00:00:35    172.16.1.2      FastEthernet0/0

172.16.31.33      1   FULL/DR         00:00:33    172.16.1.3      FastEthernet0/0

使用show ip ospf neighbor detail查看OSPF邻接路由器的详细信息。

R1#sh ip ospf nei detail

 Neighbor 172.16.31.22, interface address 172.16.1.2

    In the area 0 via interface FastEthernet0/0

    Neighbor priority is 1, State is FULL, 8 state changes

    DR is 172.16.1.3 BDR is 172.16.1.2

    Options is 0x52

    LLS Options is 0x1 (LR)

    Dead timer due in 00:00:34

    Neighbor is up for 00:04:25

    Index 2/2, retransmission queue length 0, number of retransmission 1

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

    Last retransmission scan length is 1, maximum is 1

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

 Neighbor 172.16.31.33, interface address 172.16.1.3

    In the area 0 via interface FastEthernet0/0

    Neighbor priority is 1, State is FULL, 6 state changes

    DR is 172.16.1.3 BDR is 172.16.1.2

    Options is 0x52

    LLS Options is 0x1 (LR)

    Dead timer due in 00:00:33

    Neighbor is up for 00:04:06

    Index 1/1, retransmission queue length 0, number of retransmission 1

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

    Last retransmission scan length is 1, maximum is 1

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

现在我们已经可以看出,R3DRR2BDR

4、  使用show ip ospf interface fa0/0查看接口的信息。

R1#sh ip ospf interface fa0/0

FastEthernet0/0 is up, line protocol is up

  Internet Address 172.16.1.1/24, Area 0

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

  Transmit Delay is 1 sec, State DROTHER, Priority 1

  Designated Router (ID) 172.16.31.33, Interface address 172.16.1.3

  Backup Designated router (ID) 172.16.31.22, Interface address 172.16.1.2

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

    oob-resync timeout 40

    Hello due in 00:00:06

  Index 1/1, 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 2, Adjacent neighbor count is 2

    Adjacent with neighbor 172.16.31.22  (Backup Designated Router)

    Adjacent with neighbor 172.16.31.33  (Designated Router)

  Suppress hello for 0 neighbor(s)

从显示的信息可以看到fa0/0接口链接的是广播网络类型,Hello时间间隔10s,Dead timer时间是40s.

5、  修改R1Hello时间间隔和Dead timer时间间隔,看下邻居间的变化状况。

R1(config)#int fa0/0

R1(config-if)#ip ospf hello-interval 5

R1(config-if)#ip ospf dead-interval 20

R1(config-if)#exit

        修改完毕后,使用show ip ospf neighbors查看邻接路由器,会有什么输出信息?

R1#sh ip ospf nei

显示的是空白,找不出邻接的邻居R2R3了。下面也显示出邻居已经失去链接的提示信息。

*Oct 28 23:33:36.647: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.31.33 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired

*Oct 28 23:33:38.419: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.31.22 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Dead timer e     

使用debug ip ospf events命令查看R1失去邻接邻居的原因。

R1#debug ip ospf events

OSPF events debugging is on

R1#

*Oct 28 23:33:58.423: OSPF: Rcv hello from 172.16.31.22 area 0 from FastEthernet0/0 172.16.1.2

*Oct 28 23:33:58.427: OSPF: Mismatched hello parameters from 172.16.1.2

*Oct 28 23:33:58.427: OSPF: Dead R 40 C 20, Hello R 10 C 5  Mask R 255.255.255.0 C 255.255.255.0

*Oct 28 23:34:01.463: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.16.1.1

*Oct 28 23:34:06.463: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.16.1.1

*Oct 28 23:34:06.643: OSPF: Rcv hello from 172.16.31.33 area 0 from FastEthernet0/0 172.16.1.3

*Oct 28 23:34:06.643: OSPF: Mismatched hello parameters from 172.16.1.3

*Oct 28 23:34:06.643: OSPF: Dead R 40 C 20, Hello R 10 C 5  Mask R 255.255.255.0 C 255.255.255.0

*Oct 28 23:34:08.427: OSPF: Rcv hello from 172.16.31.22 area 0 from FastEthernet0/0 172.16.1.2

*Oct 28 23:34:08.427: OSPF: Mismatched hello parameters from 172.16.1.2

*Oct 28 23:34:08.427: OSPF: Dead R 40 C 20, Hello R 10 C 5  Mask R 255.255.255.0 C 255.255.255.0

*Oct 28 23:34:11.463: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.16.1.1

*Oct 28 23:34:16.463: OSPF: Send hello to 224.0.0.5 area 0 on FastEthernet0/0 from 172.16.1.1

*Oct 28 23:34:16.647: OSPF: Rcv hello from 172.16.31.33 area 0 from FastEthernet0/0 172.16.1.3

*Oct 28 23:34:16.651: OSPF: Mismatched hello parameters from 172.16.1.3

注意最后要使用命令undebug all停止debug命令。

6、  配置OSPF验证。

R1(config)#int fa0/0

R1(config-if)#ip ospf message-digest-key 1 md5 ciscoccnp

R1(config-if)#router ospf 1

R1(config-router)#area 0 authentication message-digest

R1(config-router)#exit

7、  使用debug ip ospf adj命令查看DR/BDR的选举过程。

R2#debug ip ospf adj

OSPF adjacency events debugging is on

R2#

*Oct 28 23:46:30.847: OSPF: Send with youngest Key 1

*Oct 28 23:46:31.343: OSPF: Send with youngest Key 1

*Oct 28 23:46:32.539: OSPF: Send with youngest Key 1

*Oct 28 23:46:33.007: OSPF: Rcv pkt from 172.16.1.3, FastEthernet0/0 : Mismatch Authentication type. Input packet specified type 0, we use type 2

*Oct 28 23:46:33.019: OSPF: 172.16.31.33 address 172.16.1.3 on FastEthernet0/0 is dead

*Oct 28 23:46:33.019: OSPF: 172.16.31.33 address 172.16.1.3 on FastEthernet0/0 is dead, state DOWN

*Oct 28 23:46:33.023: %OSPF-5-ADJCHG: Process 1, Nbr 172.16.31.33 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Dead timer expired

*Oct 28 23:46:33.023: OSPF: Neighbor change Event on interface FastEthernet0/0

*Oct 28 23:46:33.027: OSPF: DR/BDR election on FastEthernet0/0

*Oct 28 23:46:33.027: OSPF: Elect BDR 172.16.31.22

*Oct 28 23:46:33.027: OSPF: Elect DR 172.16.31.11

*Oct 28 23:46:33.031:        DR: 172.16.31.11 (Id)   BDR: 172.16.31.22 (Id)

8、通过修改接口的优先级,人为的进行DR/BDR的选举,修改后保存配置。重新启动路由器查看DR/BDR分别是那个路由器。

R1(config)#int fa0/0

R1(config-if)#ip ospf priority 200

R1(config-if)#exit

由于本人是用模拟器做实验,无法做重启路由器来验证,无法显示详细的信息了。各们朋友有条件的可以试验一下。