思科OSPF实验1:基本的OSPF配置实验步骤:1.首先在3台路由器上配置物理接口,并且使用ping命令确保物理链路的畅通。2.在路由器上配置loopback接口:R1(config)#intloopback0R1(config-if)#ipadd1.1.1.1255.255.255.0R2(config)#intloopback0R2(config-if)#ipadd2.2.2.2255.255.255.0R3(config)#intloopback0R3(config-if)#ipadd3.3.3.3255.255.255.0路由器的RID是路由器接口的最高的IP地址,当有环回口存在是,路由器将使用环回口的最高IP地址作为起RID,从而保证RID的稳定。3.在3台路由器上分别启动ospf进程,并且宣告直连接口的网络。R1(config)#routerospf10R1(config-router)#network192.168.1.00.0.0.255area0R1(config-router)#network1.1.1.00.0.0.255area0R1(config-router)#network192.168.3.0.0.0.255area0ospf的进程号只有本地意义,既在不同路由器上的进程号可以不相同。但是为了日后维护的方便,一般启用相同的进程号。ospf使用反向掩码。Area0表示骨干区域,在设计ospf网络时,所有的非骨干区域都需要和骨干区域直连!R2,R3的配置和R1类似,这里省略。不同的是我们在R2和R3上不宣告各自的环回口。*Aug1317:58:51.411:%OSPF-5-ADJCHG:Process10,Nbr2.2.2.2onSerial1/0fromLOADINGtoFULL,LoadingDone配置结束后,我们可以看到邻居关系已经到达FULL状态。4.在R1上查看路由表,可以看到以下信息:R1#showiprouteCodes:C-connected,S-static,R-RIP,M-mobile,B-BGPD-EIGRP,EX-EIGRPexternal,O-OSPF,IA-OSPFinterareaN1-OSPFNSSAexternaltype1,N2-OSPFNSSAexternaltype2E1-OSPFexternaltype1,E2-OSPFexternaltype2i-IS-IS,su-IS-ISsummary,L1-IS-ISlevel-1,L2-IS-ISlevel-2ia-IS-ISinterarea,*-candidatedefault,U-per-userstaticrouteo-ODR,P-periodicdownloadedstaticrouteGatewayoflastresortisnotset1.0.0.0/24issubnetted,1subnetsC1.1.1.0isdirectlyconnected,Loopback0C192.168.1.0/24isdirectlyconnected,Serial1/0O192.168.2.0/24[110/65]via192.168.1.2,00:03:42,Serial1/0C192.168.3.0/24isdirectlyconnected,FastEthernet0/我们看到R1学到了192.168.2.0/24这个网段的路由。后面的数字[110/65],分别表示OSPF的管理距离(AD)和路由的Metric值OSPF的Metric值是由cost值逐跳累加的。Cost=100Mb/带宽值。5.在R1上showipospfneighbor、showipospfinterfaceR1#showipospfneighborNeighborIDPriStateDeadTimeAddressInterface3.3.3.31FULL/BDR00:00:34192.168.3.3FastEthernet0/02.2.2.20FULL/-00:00:32192.168.1.2Serial1/0我们看到R1和R3选取了DR和BDR,而R1和R2没有选取。在ospf的五种网络类型中。Point-to-Point,Point-to-Multipoint(广播与非广播)这三种网络类型不选取DR与BDR;Broadcast,NBMA选取DR与BDR。R1#showipospfinterfaceFastEthernet0/0isup,lineprotocolisupInternetAddress192.168.3.1/24,Area0ProcessID10,RouterID1.1.1.1,NetworkTypeBROADCAST,Cost:1TransmitDelayis1sec,StateDR,Priority1DesignatedRouter(ID)1.1.1.1,Interfaceaddress192.168.3.1BackupDesignatedrouter(ID)3.3.3.3,Interfaceaddress192.168.3.3Timerintervalsconfigured,Hello10,Dead40,Wait40,Retransmit5oob-resynctimeout40Helloduein00:00:03Index3/3,floodqueuelength0Next0x0(0)/0x0(0)Lastfloodscanlengthis1,maximumis1Lastfloodscantimeis0msec,maximumis0msecNeighborCountis1,Adjacentneighborcountis1Adjacentwithneighbor3.3.3.3(BackupDesignatedRouter)Suppresshellofor0neighbor(s)Serial1/0isup,lineprotocolisupInternetAddress192.168.1.1/24,Area0ProcessID10,RouterID1.1.1.1,NetworkTypePOINT_TO_POINT,Cost:64TransmitDelayis1sec,StatePOINT_TO_POINT,Timerintervalsconfigured,Hello10,Dead40,Wait40,Retransmit5oob-resynctimeout40Helloduein00:00:02Index1/1,floodqueuelength0Next0x0(0)/0x0(0)Lastfloodscanlengthis1,maximumis1Lastfloodscantimeis4msec,maximumis4msecNeighborCountis1,Adjacentneighborcountis1Adjacentwithneighbor2.2.2.2Suppresshellofor0neighbor(s)Loopback0isup,lineprotocolisupInternetAddress1.1.1.1/24,Area0ProcessID10,RouterID1.1.1.1,NetworkTypeLOOPBACK,Cost:1LoopbackinterfaceistreatedasastubHost在这里我们看到环回口的网络网络类型是Loopback,这是一种特殊的网络类型,只针对环回口存在。我们到R2上看看路由表:R2#showiprouteCodes:C-connected,S-static,R-RIP,M-mobile,B-BGPD-EIGRP,EX-EIGRPexternal,O-OSPF,IA-OSPFinterareaN1-OSPFNSSAexternaltype1,N2-OSPFNSSAexternaltype2E1-OSPFexternaltype1,E2-OSPFexternaltype2i-IS-IS,su-IS-ISsummary,L1-IS-ISlevel-1,L2-IS-ISlevel-2ia-IS-ISinterarea,*-candidatedefault,U-per-userstaticrouteo-ODR,P-periodicdownloadedstaticrouteGatewayoflastresortisnotset1.0.0.0/32issubnetted,1subnetsO1.1.1.1[110/65]via192.168.1.1,00:12:34,Serial1/02.0.0.0/24issubnetted,1subnetsC2.2.2.0isdirectlyconnected,Loopback0C192.168.1.0/24isdirectlyconnected,Serial1/0C192.168.2.0/24isdirectlyconnected,Serial1/1O192.168.3.0/24[110/65]via192.168.1.1,00:12:34,Serial1/0[110/65]via192.168.2.3,00:12:34,Serial1/1R2的路由表显示来自环回口的路由,掩码为/32,既我们所说的“主机路由”。在实际应用中,环回口以32位的居多,用作ospf的管理接口。但是如果你想让环回口模拟一个网段,我们可以通过以下配置来消除。R1(config)#intloopback0R1(config-if)#ipospfnetworkpoint-to-point环回口只能配置成point-to-point这种类型,不可以配置成其它的类型。回到R2查看路由表:R2#showiprouteCodes:C-connected,S-static,R-RIP,M-mobile,B-BGPD-EIGRP,EX-EIGRPexternal,O-OSPF,IA-OSPFinterareaN1-OSPFNSSAexternaltype1,N2-OSPFNSSAexternaltype2E1-OSPFexternaltype1,E2-OSPFexternaltype2i-IS-IS,su-IS-ISsummary,L1-IS-ISlevel-1,L2-IS-ISlevel-2ia-IS-ISinterarea,*-candidatedefault,U-per-userstaticrouteo-ODR,P-periodicdownloadedstaticrouteGatewayoflastresortisnotset1.0.0.0/24issubnetted,1subnetsO1.1.1.0[110/65]via192.168.1.1,00:00:24,Serial1/02.0.0.0/24issubnetted,1subnetsC2.2.2.0isdirectlyconnected,Loopback0C192.168.1.0/24isdirectlyconnected,Serial1/0C192.168.2.0/24isdirectlyconnected,Serial1/1O192.168.3.0/24[110/65]via192.168.1.1,00:00:24,Serial1/0[110/65]via192.168.2.3,00:00:24,Serial1/1我们看到主机路由没有了,取而代之的是一个/24的网段。