实验四 ospf认证
- 格式:doc
- 大小:236.50 KB
- 文档页数:10
OSPF实验5:OSPF认证完整总结实验等级:Expert实验拓扑:实验说明:OSPF的认证有2种类型(确切说是3种),其中type0表示无认证,type1表示明文认证,type2表示MD5认证。
明文认证发送密码进行认证,而MD5认证发送的是报文摘要。
有关MD5的详细信息,可以参阅RFC1321.OSPF的认证可以在链路上进行,也可以在整个区域内进行认证。
另外虚链路同样也可以进行认证。
实验基本配置:R1:interface Loopback0ip address 1.1.1.1 255.255.255.0!interface FastEthernet0/0ip address 21.1.1.1 255.255.255.0 duplex half!router ospf 10router-id 1.1.1.1log-adjacency-changesnetwork 10.1.1.0 0.0.0.255 area 0 network 21.1.1.0 0.0.0.255 area 0 R2:interface Loopback0ip address 2.2.2.2 255.255.255.0 !interface FastEthernet0/0ip address 21.1.1.2 255.255.255.0 duplex half!interface Serial1/0ip address 10.1.1.2 255.255.255.0 serial restart-delay 0!interface Serial1/1ip address 11.1.1.1 255.255.255.0 serial restart-delay 0!router ospf 10router-id 2.2.2.2log-adjacency-changesarea 1 virtual-link 3.3.3.3 network 10.1.1.0 0.0.0.255 area 0 network 11.1.1.0 0.0.0.255 area 1 network 21.1.1.0 0.0.0.255 area 0 R3:interface Loopback0ip address 3.3.3.3 255.255.255.0 !interface Serial1/0ip address 11.1.1.2 255.255.255.0 serial restart-delay 0!router ospf 10router-id 3.3.3.3log-adjacency-changesarea 1 virtual-link 2.2.2.2network 3.3.3.0 0.0.0.255 area 2network 11.1.1.0 0.0.0.255 area 1认证配置:1.在R1和R2的串行链路上进行OSPF明文认证:首先先在R1上做如下配置,看在R1配置完认证,R2还没有配置认证的时候的情况:R1(config)#int s1/0R1(config-if)#ip ospf authentication(启用认证)R1(config-if)#ip ospf authentication-key cisco(配置密码)通过debug工具我们可以看到如下信息:*Aug 15 22:51:54.275: OSPF: Rcv pkt from 10.1.1.2, Serial1/0 : MismatchAuthentication type. Input packet specified type 0, we use type 1这里的type0是指对方没有启用认证,type1是明文认证。
一.OSPF区域认证1.区域简单口令认证R1(config)#router ospf 1R1(config-router)#area 0 authentication //区域0启用简单口令认证R1(config)#int s0/0R1(config-if)#ip ospf authentication-key cisco //配置认证密码为cisco R2(config)#router ospf 1R2(config-router)#area 0 authenticationR2(config)#int s0/0R2(config-if)#ip ospf authentication-key cisco实验调试R1#show ip ospf以上输出表明区域0采用了简单口令认证。
R1#show ip ospf int s0/0以上输出最后一行信息表明该接口启用了简单口令认证。
R1#debug ip ospf packet以上输出表明接收到认证类型为1的Hello数据包。
认证:1).如果R1区域0没有启用认证,而R2区域0启用简单口令认证,则R2会出现下面的信息:R2#debug ip ospf events2).如果R1和R2的区域0都启用简单口令认证,但R2接口下没有配置密码或密码错误,则R2会出现下面的信息:R2#debug ip ospf events2.区域MD5认证R1(config)#router ospf 1R1(config-router)#area 0 authentication message-digest //区域0启用MD5认证R1(config)#int s0/0R1(config-if)#ip ospf message-digest-key 1 md5 cisco //配置认证Key ID 及密匙R2(config)#router ospf 1R2(config-router)#area 0 authentication message-digestR2(config)#int s0/0R2(config-if)#ip ospf message-digest-key 1 md5cisco实验调试R1#show ip ospf以上输出表明区域0采用了MD5认证。
实验名称:OSPF 认证实验设备:路由器3700二台(模拟器GNS3)实验拓补:基本配置:Router>enableRouter#configure terminalRouter(config)#hostname R1R1(config)#interface serial 1/0R1(config-if)#ip address 192.168.100.1 255.255.255.252R1(config-if)#no shutdownR1(config)#interface loopback 10R1(config-if)#ip address 192.168.1.1 255.255.255.0R1(config)#router ospf 10R1(config-router)#network 192.168.1.0 0.0.0.255 area 0R1(config-router)#network 192.168.100.0 0.0.0.3 area 0 Router>enableRouter#configure terminalRouter(config)#hostname R2R2(config)#interface loopback 10R2(config-if)#ip address 192.168.2.1 255.255.255.0R2(config)#interface serial 1/0R2(config-if)#ip address 192.168.100.2 255.255.255.252R2(config-if)#clock rate 64000R2(config-if)#no shutdownR2(config)#router ospf 20R2(config-router)#network 192.168.2.0 0.0.0.255 area 0R2(config-router)#network 192.168.100.0 0.0.0.3 area 0认证方式:一、明文认证R1 配置R1(config)#interface serial 1/0R1(config-if)#ip ospf authentication /**在所有参与OSPF进程的接口启用明文验证R1(config-if)#ip ospf authentication-key cisco /**设置明文口令R1(config)#interface loopback 10R1(config-if)#ip ospf authenticationR1(config-if)#ip ospf authentication-key ciscoR1(config)#router ospf 10R1(config-router)#area 0 authentication /**声明在Area 0 使用明文验证R2配置R2(config)#interface serial 1/0R2(config-if)#ip ospf authenticationR2(config-if)#ip ospf authentication-key ciscoR2(config)#interface loopback 10R2(config-if)#ip ospf authenticationR2(config-if)#ip ospf authentication-key ciscoR2(config)#router ospf 20R2(config-router)#area 0 authentication二、MD5认证R1 配置R1(config)#interface serial 1/0R1(config-if)#no ip ospf authentication-key /**取消以前的明文密码R1(config-if)#ip ospf authentication message-digest /**启用MD5的密文验证R1(config-if)#ip ospf message-digest-key 1 md5 cisco /**设置密文验证的口令R1(config)#interface loopback 10R1(config-if)#no ip ospf authentication-keyR1(config-if)#ip ospf authentication message-digestR1(config-if)#ip ospf message-digest-key 1 md5 ciscoR1(config)#router ospf 10R1(config-router)#area 0 authentication message-digest /**声明Area 0 使用密文验证R2 配置R2(config)#interface serial 1/0R2(config-if)#no ip ospf authentication-keyR2(config-if)#ip ospf authentication message-digestR2(config-if)#ip ospf message-digest-key 1 md5 ciscoR2(config)#interface loopback 10R2(config-if)#no ip ospf authentication-keyR2(config-if)#ip ospf authentication message-digestR2(config-if)#ip ospf message-digest-key 1 md5 ciscoR2(config)#router ospf 20R2(config-router)#area 0 authentication message-digestR2#show ip ospf interface serial 1/0 /** 查看配置的验证。
【OSPF认证终结版】
无论是进行明文认证,还是密文认证:
1、首先双方要进行认证类型的匹配;如果认证类型不匹配,认证不成功;
2、如果认证类型匹配成功,且都是明文认证;
@如果双方只启用明文认证,但是不配置密码,则使用空密码,认证成功;
@如果双方启用了明文认证,且在接口配置了密码,如果密码相同,则认证成功;反之,认证失败;
3、如果认证类型匹配,且都是密文认证;
@如果是只启用密文认证,但是不配置密码,则使用默认的key-id=0所对应的密钥,认证成功;
@ 如果启用了密文认证,且配置了密码,则只使用本地最新的key-id 所对应的密码;
到了对方设备以后,只查找对方的数据库中是否有自己的key-id 对应的密钥;
如果有的话,则查看密码是否一致;如果一致,认证成功,反之,认证失败!
@如果启用了密文认证以后,且配置了多个密码;则同时发送多个 key-id以及相应的密钥【但不包括key-id =0】;
到了对方设备以后,首先查看有么有与自己本地最新的key-id相同的密钥;
如果有的话,查看密码是否相同;相同,认证成功;反之,失败!如果没有的话,则用除最新以外的其他key-id 与该路由器上的密码数据库中的key- id进行比较;
找到相应的key-id,然后进行比对密码;如果相同,则认证成功;反之,认证失败!
找不到相应的key-id,则认证失败!
在多key-id认证过程中,只会查找相应的Key-id。
即使么有的话,也不会去查找key-id + 1 或者 key-id - 1 ;
不同OSPF 进程之间的重分发
《OSPF Redistribution Among Different OSPF Processes》。
实验4. 动态路由—OSPF1 背景知识OSPF是由IETF的IGP工作组为ip网开发的路由协议。
该工作组成立于1998年,专门设计用于因特网的基于最短路径优先(SPF)算法的IGP。
与IGRP类似,OSPF创建的原因是到了八十年代中期,RIP不能服务于大型、异构网络的缺陷愈发明显。
OSPF有两个主要的特性。
首先该协议是开放的,即其规范是公开的,公布的OSPF 规范是RFC1247。
另一个基本的特性是OSPF基于SPF算法,该算法也称为Dijkstra算法,即以创建该算法的人来命名。
2 实验需求:思科路由器C3640三台3 实验目的通过本实验可以掌握:◆在路由器上启动OSPF 路由进程◆启用参与路由协议的接口,并且通告网络及所在的区域◆认识DR和BDR选举◆OSPF特殊区域配置◆OSPF 认证的类型和意义◆基于区域的OSPF 简单口令认证和MD5的配置和调试◆OSPF路由汇总◆验证OSPF 路由协议相关信息4 实验拓扑Hlsz-R1Hlsz-R2Hlsz-R3S2/0S2/0F0/0F0/0Lo 0Lo 0Area 0Area 1Area 3成都互联神州网络技术培训 12.1.1.0/3023.1.1.0/305 实验步骤实验基本配置省略5.1 OSPF 单区域和多区域配置配置R1路由器R1(config)#router ospf 1 /开启ospf 进程,进程ID 本地有效,可一样也可以不一样 R1(config-router)#network 1.1.1.1 0.0.0.0 area 1 /通告网段的时候要注意的area ID R1(config-router)#network 12.1.1.0 0.0.0.3 area 0 /此网段要通告到area 0 R1(config-router)#end配置R2路由器R2(config)#router ospf 1R2(config-router)#network 12.1.1.0 0.0.0.3 area 0 /这里三个网段都是area 0 R2(config-router)#network 2.2.2.2 0.0.0.0 area 0 R2(config-router)#network 23.1.1.0 0.0.0.3 area 0 R2(config-router)#exit配置R3路由器R3(config)#router ospf 1R3(config-router)#network 23.1.1.0 0.0.0.3 area 0 /此网段属于区域0 R3(config-router)#network 3.3.3.3 0.0.0.0 area 3 /此网段属于区域3查看R1和R3的路由表R1#show ip routeCodes: C - connected, S - static, R - RIP , M - mobile, B - BGPD - 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 2i - 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 routeGateway of last resort is not set1.0.0.0/32 is subnetted, 1 subnetsC 1.1.1.1 is directly connected, Loopback02.0.0.0/32 is subnetted, 1 subnetsO 2.2.2.2 [110/65] via 12.1.1.2, 00:13:15, Serial2/0 /区域内的路由3.0.0.0/32 is subnetted, 1 subnetsO IA 3.3.3.3 [110/66] via 12.1.1.2, 00:13:15, Serial2/0 /区域间的路由23.0.0.0/30 is subnetted, 1 subnetsO 23.1.1.0 [110/65] via 12.1.1.2, 00:13:15, Serial2/012.0.0.0/30 is subnetted, 1 subnetsC 12.1.1.0 is directly connected, Serial2/0R3#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not set1.0.0.0/32 is subnetted, 1 subnetsO IA 1.1.1.1 [110/66] via 23.1.1.1, 00:13:37, FastEthernet0/0 /区域间的路由2.0.0.0/32 is subnetted, 1 subnetsO 2.2.2.2 [110/2] via 23.1.1.1, 00:13:37, FastEthernet0/0 /区域内的路由3.0.0.0/32 is subnetted, 1 subnetsC 3.3.3.3 is directly connected, Loopback023.0.0.0/30 is subnetted, 1 subnetsC 23.1.1.0 is directly connected, FastEthernet0/012.0.0.0/30 is subnetted, 1 subnetsO 12.1.1.0 [110/65] via 23.1.1.1, 00:13:37, FastEthernet0/0查看R2的ospf的邻居(邻接)关系R2#show ip ospf neighborNeighbor ID Pri State Dead Time Address Interface 3.3.3.3 1 FULL/BDR 00:00:38 23.1.1.2 FastEthernet0/0 1.1.1.1 0 FULL/ - 00:00:31 12.1.1.1 Serial2/0备注:以太网链路有DR、BDR的选举,WAN链路(点到点)不选择DR、BDR查看运行了ospf路由协议的接口R2#sh ip os int f0/0FastEthernet0/0 is up, line protocol is upInternet Address 23.1.1.1/30, Area 0 / 此接口地址及这个接口所在的区域Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1/网络环境类型Transmit Delay is 1 sec, State DR, Priority 1/DR或者是BDR,优先级Designated Router (ID) 2.2.2.2, Interface address 23.1.1.1 /Router-ID也是DRBackup Designated router (ID) 3.3.3.3, Interface address 23.1.1.2 /BDRTimer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 /存活时间oob-resync timeout 40Hello due in 00:00:09Supports Link-local Signaling (LLS)Index 3/3, flood queue length 0Next 0x0(0)/0x0(0)Last flood scan length is 0, maximum is 1Last flood scan time is 0 msec, maximum is 0 msecNeighbor Count is 1, Adjacent neighbor count is 1/邻居个数Adjacent with neighbor 3.3.3.3 (Backup Designated Router)/邻接个数Suppress hello for 0 neighbor(s)R2#sh ip ospf int s2/0 /无DR、BDR 的选举Serial2/0 is up, line protocol is upInternet Address 12.1.1.2/30, Area 0Process ID 1, Router ID 2.2.2.2, Network Type POINT_TO_POINT, Cost: 64 /网络环境Transmit Delay is 1 sec, State POINT_TO_POINT,Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5oob-resync timeout 40Hello due in 00:00:01Supports Link-local Signaling (LLS)Index 1/1, flood queue length 0Next 0x0(0)/0x0(0)Last flood scan length is 1, maximum is 2Last flood scan time is 0 msec, maximum is 0 msecNeighbor Count is 1, Adjacent neighbor count is 1 /邻居个数Adjacent with neighbor 1.1.1.1 /邻接个数Suppress hello for 0 neighbor(s)R3#ping 1.1.1.1/测试与R1的连通性Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 12/38/80 mshlsz-R3#ping 12.1.1.1Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 12.1.1.1, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 8/27/52 ms5.2 OSPF特殊区域配置实验拓扑:R1R2R3 Area 1 Stub Area 012.1.1.0/3023.1.1.0/30Interface loopback1.1.1.0/242.2.2.0/243.3.3.0/244.4.4.0/24实验步骤基本配置略,stub区域作用:R1所处的区域1路由器性能不是太好,不需要学习全部的OSPF路由条目,可以把AREA 1设置为特殊区域配置R2 区域1为stub区域R2(config)#router ospf 1R2(config-router)#area 1 stub配置R1区域1为stub区域R1(config)#router ospf 1R1(config-router)#area 1 stub查看R1路由表/可以观察在R1路由表多了一条OSPF的默认路由,即拒绝了5类LSA.5.3 OSPF认证实验拓扑AERA 05.3.1 基于区域的OSPF 简单口令认证实验步骤(接口IP地址、ospf路由启用配置略)(1)配置路由器R1R1(config)#router ospf 1R1(config-router)#router-id 1.1.1.1R1(config-router)#network 12.1.1.0 255.255.255.0 area 0R1(config-router)#network 1.1.1.0 255.255.255.0 area 0R1(config-router)#area 0 authentication /区域0 启用简单口令认证R1(config)#interface s2/0R1(config-if)#ip ospf authentication-key cisco /配置认证密码(2)配置路由器R2R2(config)#router ospf 1R2(config-router)#router-id 2.2.2.2R2(config-router)#network 2.2.2.0 255.255.255.0 area 0R2(config-router)#network 12.1.1.0 255.255.255.0 area 0R2(config-router)#area 0 authenticationR2(config)#interface s2/1R2(config-if)#ip ospf authentication-key cisco实验验证(1)show ip ospf interfaceR1#show ip ospf interface s2/0Serial2/0 is up, line protocol is upInternet Address 12.1.1.1/24, Area 0Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 64 Transmit Delay is 1 sec, State POINT_TO_POINT,Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40Hello due in 00:00:09Supports Link-local Signaling (LLS)Index 2/2, flood queue length 0Next 0x0(0)/0x0(0)Last flood scan length is 1, maximum is 1Last flood scan time is 0 msec, maximum is 0 msecNeighbor Count is 1, Adjacent neighbor count is 1Adjacent with neighbor 2.2.2.2Suppress hello for 0 neighbor(s)Simple password authentication enabled /简单口令认证(2)show ip ospfR1#show ip ospfRouting Process "ospf 1" with ID 1.1.1.1Supports only single TOS(TOS0) routes......Area BACKBONE(0)Number of interfaces in this area is 2 (1 loopback)Area has simple password authentication /简单口令认证SPF algorithm last executed 00:00:01.916 agoSPF algorithm executed 5 timesArea ranges areNumber of LSA 2. Checksum Sum 0x010117Number of opaque link LSA 0. Checksum Sum 0x000000Number of DCbitless LSA 0Number of indication LSA 0Number of DoNotAge LSA 0Flood list length 0通过以上输出信息,可以得知OSPF采用简单口令认证方式。
OSPF 的四种认证方式OSPF的四种认证,基于区域的认证两种:简单口令认证,MD5。
基于链路的认证有两种:简单口令认证,MD5。
简单介绍一下:基于区域的简单口令认证:在R2上的配置如下:Router(config)#router ospf 100Router(config-router)#area 0 authenticationRouter(config)#int s1/3Router(config-if)#ip ospf authentication-key tyt在R3上的配置也是一样的,当你配置完一方时,邻居关系会断掉,另一方配置完后,邻居关系会重启,再者两边的密码一定要一样,不然不行。
基于区域的MD5认证:在R2上的配置如下:Router(config)#router ospf 100Router(config-router)#area 0 authentication message-digestRouter(config)#int s1/3Router(config-if)#ip ospf message-digest-key 1 md5 tyt在R3上的配置也是一样的,当你配置完一方时,邻居关系会断掉,另一方配置完后,邻居关系会重启,再者两边的密码一定要一样,不然不行。
基于链路的简单口令认证:在R2上的配置如下:Router(config)#int s1/3Router(config-if)#ip ospf authenticationRouter(config-if)#ip ospf authentication-key tyt这个很简单,在R3上的配置也是这样的基于链路的MD5认证的配置:在R2上的配置如下:Router(config)#int s1/3Router(config-if)#ip ospf authentication message-digestRouter(config-if)#ip ospf message-digest-key 1 md5 tyt其实在认证配置方面很简单!因为文档太小的话,文库会不认上传,所以在后面加些无关紧要的东西,可以删掉!实验 1-2:在NAT中使用Access List 和Route Maps【实验目的】:在本次实验中,你需要使用网络地址转换(NAT)去允许内网路由器(PxR3 和 PxR4)从TFTP服务器下载配置文件为了完成本次实验,你需要完成下列任务:∙建立在NAT中需要使用的访问控制列表∙在NAT中使用ROUTE-MAPS执行分开的并发地址转换。
OSPF 的四种认证方式OSPF的四种认证,基于区域的认证两种:简单口令认证,MD5。
基于链路的认证有两种:简单口令认证,MD5。
简单介绍一下:基于区域的简单口令认证:在R2上的配置如下:Router(config)#router ospf 100Router(config-router)#area 0 authenticationRouter(config)#int s1/3Router(config-if)#ip ospf authentication-key tyt在R3上的配置也是一样的,当你配置完一方时,邻居关系会断掉,另一方配置完后,邻居关系会重启,再者两边的密码一定要一样,不然不行。
基于区域的MD5认证:在R2上的配置如下:Router(config)#router ospf 100Router(config-router)#area 0 authentication message-digestRouter(config)#int s1/3Router(config-if)#ip ospf message-digest-key 1 md5 tyt在R3上的配置也是一样的,当你配置完一方时,邻居关系会断掉,另一方配置完后,邻居关系会重启,再者两边的密码一定要一样,不然不行。
基于链路的简单口令认证:在R2上的配置如下:Router(config)#int s1/3Router(config-if)#ip ospf authenticationRouter(config-if)#ip ospf authentication-key tyt这个很简单,在R3上的配置也是这样的基于链路的MD5认证的配置:在R2上的配置如下:Router(config)#int s1/3Router(config-if)#ip ospf authentication message-digestRouter(config-if)#ip ospf message-digest-key 1 md5 tyt其实在认证配置方面很简单!因为文档太小的话,文库会不认上传,所以在后面加些无关紧要的东西,可以删掉!实验 1-2:在NAT中使用Access List 和Route Maps【实验目的】:在本次实验中,你需要使用网络地址转换(NAT)去允许内网路由器(PxR3 和 PxR4)从TFTP服务器下载配置文件为了完成本次实验,你需要完成下列任务:•建立在NAT中需要使用的访问控制列表•在NAT中使用ROUTE-MAPS执行分开的并发地址转换。
OSPF总共两种认证方法:明文认证,MD5认证。
每个OSPF接口都可以设置一个认证口令,路由器使用该口令向与该接口相同网段中的其他所有路由器发送OSPF信息。
认证口令在路由器之间必须是相同的。
认证口令产生一段认证数据,存放在OSPF包头中,密码最多8个字符。
在一个Area中,只能采用同一种认证方式(这个实验已经证明),并且一个Area中,如果有Router配置了认证,则该区域内所有Router都要配置认证,否则未配置认证的Router失效(先配置RouterA和RouterB,则RouterC中debug ip ospf adj,会出现Serial2/0接口失效的提示)。
实验配置:RouterB的配置:Router#conf tEnter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fastethernet0/0Router(config-if)#ip address 192.168.30.1 255.255.255.0 Router(config-if)#no shutdownRouter(config-if)#interface serial2/0Router(config-if)#clock rate 9600Router(config-if)#ip address 192.168.20.2 255.255.255.0 Router(config-if)#ip ospf authentication-key sujianRouter(config-if)#no shutdownRouter(config-if)#interface serial3/0Router(config-if)#clock rate 9600Router(config-if)#ip address 192.168.40.1 255.255.255.0 Router(config-if)#ip ospf authentication-key sujianRouter(config-if)#no shutdownRouter(config-if)#exitRouter(config)#router ospf 1Router(config-router)#network 192.168.20.2 0.0.0.0 area 0 Router(config-router)#network 192.168.30.1 0.0.0.0 area 0 Router(config-router)#network 192.168.40.1 0.0.0.0 area 0 Router(config-router)#area 0 authenticationRouter(config-router)#exitRouter(config)#interface Loopback 1Router(config-if)#ip address 172.16.20.1 255.255.0.0Router(config-if)#no shutdownRouter(config-if)#end%SYS-5-CONFIG_I: Configured from console by console Router#copy running-config startup-configDestination filename [startup-config]?Building configuration...RouterA的配置:Router#conf tEnter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fastethernet0/0Router(config-if)#ip address 192.168.10.1 255.255.255.0 Router(config-if)#no shutdown%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to upRouter(config-if)#interface serial2/0Router(config-if)#clock rate 9600Router(config-if)#ip address 192.168.20.1 255.255.255.0Router(config-if)#ip ospf authentication-key sujianRouter(config-if)#no shutdown%LINK-5-CHANGED: Interface Serial2/0, changed state to down Router(config-if)#exitRouter(config)#router ospf 1Router(config-router)#network 192.168.10.1 0.0.0.0 area 0Router(config-router)#network 192.168.20.1 0.0.0.0 area 0Router(config-router)#area 0 authenticationRouter(config-router)#exitRouter(config)#interface Loopback 1%LINK-5-CHANGED: Interface Loopback1, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to upRouter(config-if)#ip address 172.16.10.1 255.255.0.0Router(config-if)#no shutdownRouter(config-if)#end%SYS-5-CONFIG_I: Configured from console by consoleRouter#copy running-config startup-configDestination filename [startup-config]?Building configuration...RouterC的配置:Router(config)#interface fastethernet0/0Router(config-if)#ip address 192.168.50.1 255.255.255.0Router(config-if)#no shutdown%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to upRouter(config-if)#interface serial2/0Router(config-if)#clock rate 9600Router(config-if)#ip address 192.168.40.2 255.255.255.0Router(config-if)#ip ospf authentication-key sujianRouter(config-if)#no shutdown%LINK-5-CHANGED: Interface Serial2/0, changed state to upRouter(config-if)#exitRouter(config)#router ospf 1Router(config-router)#network 192.168.50.1 0.0.0.0 area 0Router(config-router)#network 192.168.40.2 0.0.0.0 area 0Router(config-router)#area 0 authenticationRouter(config-router)#exitRouter(config)#interface Loopback 1%LINK-5-CHANGED: Interface Loopback1, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to upRouter(config-if)#ip address 172.16.30.1 255.255.0.0Router(config-if)#no shutdownRouter(config-if)#end%SYS-5-CONFIG_I: Configured from console by consoleRouter#copy running-config startup-configDestination filename [startup-config]?Building configuration...调试与验证提示R1-7010#debug ip ospf adjOSPF: Send with youngest Key 1OSPF: Receive dbd from 70.70.70.70 seq 0xEDCOSPF: 2 Way Communication to neighbor 70.70.70.70OSPF: send DBD packet to 192.16.64.2 seq 0x9A3OSPF: Send with youngest Key 1OSPF: Receive dbd from 70.70.70.70 seq 0x9A3OSPF: NBR Negotiation Done We are the MASTEROSPF: send DBD packet to 192.16.64.2 seq 0x9A4OSPF: Send with youngest Key 1OSPF: Send with youngest Key 1OSPF: Database request to 70.70.70.70OSPF: sent LS REQ packet to 192.16.64.2, length 12OSPF: Receive dbd from 70.70.70.70 seq 0x9A4OSPF: send DBD packet to 192.16.64.2 seq 0x9A5OSPF: Send with youngest Key 1OSPF: Send with youngest Key 1OSPF: Receive dbd from 70.70.70.70 seq 0x9A5OSPF: Exchange Done with neighbor 70.70.70.70OSPF: Synchronized with neighbor 70.70.70.70, state:FULLOSPF: Build router LSA, router ID 172.16.13.1R1-7010#show ip ospf neighborNeighbor ID Pri State DeadTime Address Interface70.70.70.701FULL/-00:00:38192.16.64.2Serial1/0R1-7010#show ip routeO70.70.70.70 [110/65] via 192.16.64.2, 00:00:59, Serial1/0 C192.16.64.0/24 is directly connected, Serial1/0。
【实验名称】OSPF基本配置和认证【实验目标】链路状态路由选择协议概述OSPF开放式最短路径优先OSPF区域(areas)OSPF邻接关系OSPF的SPF算法单区域OSPF配置OSPF认证配置【实验原理】OSPF与RIP的比较OSPF没有条数的限制,RIP只有15跳;OSPF支持变长子网掩码并支持汇聚;OSPF收敛速度比RIP快得多,OSPF采用触发更新;OSPF最多可支持六条相同代价路径和负载均衡;OSPF具有认证功能,RIPV2也有,但RIPV1不支持;OSPF配置,监测和故障排除有比RIP好得多的IOS工具库。
OSPF缺点:配置复杂;技术水平要求高;对内存和CPU要求高。
链路状态路由选择协议概述链路状态路由选择协议中的数据结构:邻居表:所有已知的邻居的数据库拓扑表:包括了在同一区域或网络里的所有路由器以及相关链路的状态信息同一区域内的所有路由器都有同样的一张LSDB路由表:路由表也叫转发数据库forwarding database (使用SPF计算出的最短路径)OSPF网络层次化设计:Link-state路由在设计时要求需要一个层次性的网络结构。
OSPF网络有以下2个级别的层次:骨干区域(backbone or area 0)非骨干区域(nonbackbone areas)OSPF区域划分及路由器的类型OSPF邻居表:路由器通过交换hello包来发现邻居关系路由器在核实hello包的特定参数后再宣布邻居关系Point-to-point WAN links:邻居之间形成邻接关系LAN links:邻接是和邻居的DR和BDR形成的;和其他的路由器形成two-way的状态。
路由更新和拓扑信息只能在邻接的路由器传输。
OSPF邻接关系路由器之间通过发送hello包来形成邻接关系。
一旦成为邻接关系:路由器之间同步链路状态数据库;LSA数据包依靠邻接关系在网络或区域中泛洪。
关键术语:DR:主要用于与其他路由器建立邻接关系,第二担任LSA信息的集中点;BDR:LSA的第二个集中点,通过计时器监测DR的更新活动。
实验四OSPF认证一.实验目的掌握OSPF接口认证和区域认证的配置方法二、实验拓扑图三、实验步骤及要求1.配置各台路由器的IP地址R1(config)#interface loopback 0R1(config-if)#ip address 10.1.1.1 255.255.255.0R1(config)#interface loopback 1R1(config-if)#ip address 10.1.2.1 255.255.255.0R1(config)#interface serial 2/0R1(config-if)#ip address 192.168.1.1 255.255.255.252 R1(config-if)#no shutdownRouter(config)#hostname r2r2(config)#interface serial 2/0r2(config-if)#ip address 192.168.1.2 255.255.255.252 r2(config-if)#clock rate 64000r2(config-if)#no shutdownr2(config-if)#exitr2(config)#interface serial 3/0r2(config-if)#ip address 192.168.1.5 255.255.255.252 r2(config-if)#clock rate 64000r2(config-if)#no shutdownr2(config-if)#exitRouter(config)#hostname r3r3(config)#interface serial 3/0r3(config-if)#ip address 192.168.1.6 255.255.255.252r3(config-if)#exitr3(config)#interface serial 3/0r3(config-if)#no shutdownr3(config)#interface serial 2/0r3(config-if)#ip address 192.168.1.9 255.255.255.252r3(config-if)#clock rate 64000r3(config-if)#no shutdownRouter(config)#hostname r4r4(config)#interface serial 2/0r4(config-if)#ip address 192.168.1.10 255.255.255.252r4(config-if)#no shutdownr4(config-if)#exitr4(config)#interface loopback 0r4(config-if)#ip address 172.16.1.1 255.255.255.0r4(config-if)#exitr4(config)#interface loopback 1r4(config-if)#ip address 172.16.2.1 255.255.255.02.在r1上进行area1区域OSPF配置Router(config)#hostname r1r1(config)#router ospf 1r1(config-router)#network 10.1.2.0 0.0.0.255 area 1r1(config-router)#network 10.1.1.0 0.0.0.255 area 1r1(config-router)#network 192.168.1.0 0.0.0.3 area 1r1(config-router)#exit3.在r2上进行area1与area0的区域边界路由器(ABR)的OSPF配置r2(config)#router ospf 1r2(config-router)#network 192.168.1.0 0.0.0.3 area 1r2(config-router)#network 192.168.1.4 0.0.0.3 area 0r2(config-router)#exit4. 在r4上进行area2区域OSPF配置r4(config)#router ospf 1r4(config-router)#network 172.16.1.0 0.0.0.255 area 2r4(config-router)#network 172.16.2.0 0.0.0.255 area 2r4(config-router)#network 192.168.1.8 0.0.0.3 area 2r4(config-router)#exit在r3上进行area2与area0的区域边界路由器(ABR)的OSPF配置r3(config)#router ospf 1r3(config-router)#network 192.168.1.8 0.0.0.3 area 2r3(config-router)#network 192.168.1.4 0.0.0.3 area 0r3(config-router)#exit5. 在任一路由器上查看OSPF邻居表r2#show ip ospf neighborNeighbor ID Pri State Dead Time Address Interface 10.1.2.1 0 FULL/ - 00:00:38 192.168.1.1 Serial2/0 192.168.1.9 0 FULL/ - 00:00:39 192.168.1.6 Serial3/0 R2路由器已经成功与r1和r3路由器建立邻居关系6.查看r1的路由表,观察其他区域的路由r1#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area* - candidate default, U - per-user static route, o - ODRP - periodic downloaded static routeGateway of last resort is not set10.0.0.0/24 is subnetted, 2 subnetsC 10.1.1.0 is directly connected, Loopback0C 10.1.2.0 is directly connected, Loopback1172.16.0.0/32 is subnetted, 2 subnetsO IA 172.16.1.1 [110/2344] via 192.168.1.2, 00:00:05, Serial2/0O IA 172.16.2.1 [110/2344] via 192.168.1.2, 00:00:05, Serial2/0192.168.1.0/30 is subnetted, 3 subnetsC 192.168.1.0 is directly connected, Serial2/0O IA 192.168.1.4 [110/1562] via 192.168.1.2, 00:00:05, Serial2/0O IA 192.168.1.8 [110/2343] via 192.168.1.2, 00:00:05, Serial2/0查看r2的路由表r2#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area* - candidate default, U - per-user static route, o - ODRP - periodic downloaded static routeGateway of last resort is not set172.16.0.0/32 is subnetted, 2 subnetsO IA 172.16.1.1 [110/1563] via 192.168.1.6, 00:04:12, Serial3/0O IA 172.16.2.1 [110/1563] via 192.168.1.6, 00:04:12, Serial3/0192.168.1.0/30 is subnetted, 3 subnetsC 192.168.1.0 is directly connected, Serial2/0C 192.168.1.4 is directly connected, Serial3/0O IA 192.168.1.8 [110/1562] via 192.168.1.6, 00:04:22, Serial3/07.在r1上启用ospf的明文认证r1(config)#interface serial 2/0r1(config-if)#ip ospf authentication 启用ospf认证r1(config-if)#ip ospf authentication-key cisco 使用明文密码进行认证8.配置完成后,打开debug观察系统提示r1#debug ip ospf events 显示与ospf相关的事件,如建立邻接关系、扩散信息、DR选举和SPF计算OSPF events debugging is onr1#00:08:30: OSPF: Rcv pkt from 192.168.1.2, Serial2/0 : Mismatch Authentication type. Input packet specified type 0, we use type 100:08:40: OSPF: Rcv pkt from 192.168.1.2, Serial2/0 : Mismatch Authentication type. Input packet specified type 0, we use type 100:08:50: OSPF: Rcv pkt from 192.168.1.2, Serial2/0 : Mismatch Authentication type. Input packet specified type 0, we use type 100:09:00: OSPF: Rcv pkt from 192.168.1.2, Serial2/0 : Mismatch Authentication type. Input packet specified type 0, we use type 1r1#undebug all 关闭调试9.在r2上启用ospf的认证r2(config)#interface serial 2/0r2(config-if)#ip ospf authenticationr2(config-if)#ip ospf authentication-key cisco10.查看r1的debug信息和路由表信息r1#debug ip ospf eventsOSPF events debugging is onr1#00:22:21: OSPF: Rcv hello from 192.168.1.5 area 1 from Serial2/0 192.168.1.200:22:21: OSPF: End of hello processing00:22:31: OSPF: Rcv hello from 192.168.1.5 area 1 from Serial2/0 192.168.1.200:22:31: OSPF: End of hello processingr1#show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area* - candidate default, U - per-user static route, o - ODRP - periodic downloaded static routeGateway of last resort is not set10.0.0.0/24 is subnetted, 2 subnetsC 10.1.1.0 is directly connected, Loopback0C 10.1.2.0 is directly connected, Loopback1172.16.0.0/32 is subnetted, 2 subnetsO IA 172.16.1.1 [110/2344] via 192.168.1.2, 00:09:47, Serial2/0O IA 172.16.2.1 [110/2344] via 192.168.1.2, 00:09:47, Serial2/0192.168.1.0/30 is subnetted, 3 subnetsC 192.168.1.0 is directly connected, Serial2/0O IA 192.168.1.4 [110/1562] via 192.168.1.2, 00:09:47, Serial2/0O IA 192.168.1.8 [110/2343] via 192.168.1.2, 00:09:47, Serial2/0由于认证成功,r1再次学习到网络的路由去掉认证,用下面的命令r1(config)#interface serial 2/0r1(config-if)#no ip ospf authenticationr2显示以下信息00:33:48: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.2.1 on Serial2/0 from FULL to DOWN, Neighbor Down: Dead timer expired00:33:48: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.2.1 on Serial2/0 from FULL to Down: Interface down or detached11.配置基于md5的密码接口认证如下,配置完成后,请自行检查确认r1(config)#interface serial 2/0r1(config-if)#ip ospf authentication message-digestr1(config-if)#ip ospf message-digest-key 1 md5 ciscor2(config)#interface serial 2/0r2(config-if)#ip ospf authentication message-digestr2(config-if)#ip ospf message-digest-key 1 md5 cisco12. no掉之前配置的明文或是md5的接口认证13.在r1上启用区域的明文认证,配置如下:r1(config)#router ospf 1r1(config-router)#area 1 authentication 为区域1启用ospf的认证r1(config-router)#exitr1(config)#interface serial 2/0r1(config-if)#ip ospf authentication-key cisco 在接口下配置区域认证的明文密码14.在R1配置完成后,稍等几秒后,会在R1的路由器上出现如下信息:01:07:04: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.5 on Serial2/0 from FULL to DOWN, Neighbor Down: Dead timer expired01:07:04: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.1.5 on Serial2/0 from FULL to Down: Interface down or detached出现down的状态,是因为R2没有配置正确的认证。