1、RouterenRouter#conf tEnter configuration commands, one per line. End with CNTL/Z.Router(config)#no ip domain-lookup Router(config)#host R1R1(config)#int f0/0R1(config-if)#ip address 10.1.1.1 255.255.255.0 R1(config-if)#no shR1(config-if)#exitR1(config)#int loopback 0R1(config-if)#ip address 1.1.1.1
2、255.255.255.0R1(config)#router ospf 1R1(config-router)#network 10.1.1.0 0.0.0.255 aR1(config-router)#network 10.1.1.0 0.0.0.255 area 0R1(config-router)#network 1.1.1.0 0.0.0.255 area 0R1(config-router)#exitR2配置:Router(config)#host R2R2(config)#int f0/0R2(config-if)#ip address 10.1.1.2 255.255.255.0R
3、2(config-if)#no shR2(config-if)#exitR2(config)#int s1/0R2(config-if)#ip address 10.1.2.1 255.255.255.0R2(config)#int lo 0R2(config-if)#ip address 2.2.2.2 255.255.255.0R2(config)#router ospf 1R2(config-router)#network 10.1.1.0 0.0.0.255 a 0R2(config-router)#network 10.1.2.0 0.0.0.255 a 0R2(config-rou
4、ter)#network 2.2.2.0 0.0.0.255 a 0R2(config-router)#exitR3配置:Router(config)#no ip domain-lo Router(config)#host R3R3(config)#int s1/0R3(config-if)#ip address 10.1.2.2 255.255.255.0R3(config-if)#no shR3(config-if)#exitR3(config)#int lo 0R3(config-if)#ip address 3.3.3.3 255.255.255.0R3(config)#router
5、ospf 1R3(config-router)#network 10.1.2.0 0.0.0.255 a 0R3(config-router)#network 3.3.3.0 0.0.0.255 a 0R3(config-router)#exit通过show ip protocol 、show ip router ospf 、show ip ospf interface、show ip ospf等命令查看配置信息。R1#show ip protocols Routing Protocol is ospf 1 Outgoing update filter list for all interfa
6、ces 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.0 0.0.0.255 area 0 10.1.1.0 0.0.0.255 area 0 Reference bandwidth unit is 100 mbps Routing Information Sou
7、rces: Gateway Distance Last Update 3.3.3.3 110 00:02:36 2.2.2.2 110 00: Distance: (default is 110) 通过这个命令可以看到路由器配置的路由信息,这里可以看到配置的是ospf,并且进程ID是1。而ospf的RID是1.1.1.1。通过ospf通过的网络分别是1.1.1.0/24和10.1.1.0/24。R1#show ip route Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP
8、 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
9、o - ODR, P - periodic downloaded static routeGateway of last resort is not set 1.0.0.0/24 is subnetted, 1 subnetsC 1.1.1.0 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnetsO 2.2.2.2 110/2 via 10.1.1.2, 00:05:19, FastEthernet0/0 3.0.0.0/32 is subnetted, 1 subnetsO 3.3.3.3 110/66 via
10、 10.1.1.2, 00: 10.0.0.0/24 is subnetted, 2 subnetsO 10.1.2.0 110/65 via 10.1.1.2, 00:C 10.1.1.0 is directly connected, FastEthernet0/0 在R1上查看路由表,可以发现有三条的通过OSPF学到的路由,它们的AD都是110,metric分别是2、66、65。主要因为2.2.2.2和3.3.3.3是stub路由,所以metric为1,以太网链路的metric是1,而专线的metric是64。R1#show ip ospf neighbor Neighbor ID Pri
11、 State Dead Time Address Interface2.2.2.2 1 FULL/BDR 00:00:37 10.1.1.2 FastEthernet0/0R2#show ip ospf neighbor 3.3.3.3 0 FULL/ - 00:32 10.1.2.2 Serial1/01.1.1.1 1 FULL/DR 00:38 10.1.1.1 FastEthernet0/0R3#show ip ospf neighbor 2.2.2.2 0 FULL/ - 00:34 10.1.2.1 Serial1/0 分别在R1、R2、R3使用show ip ospf neigh
12、bor这条命令,其中R1和R3有一个邻居,R2有两个邻居。R1和R2因为是以太网链路,所以要选举DR和BDR,一般来说RID大的为DR,但由于R1比R2先启用OSPF的协议,所以成为了DR。而R3和R2是点对点链路,不需要选举DR和BDR。R1#show ip ospf Routing Process with ID 1.1.1.1 Start time: 00:07:36.520, Time elapsed:19:06.080 Supports only single TOS(TOS0) routes Supports opaque LSA Supports Link-local Signa
13、ling (LLS) Supports area transit capability Router is not originating router-LSAs with maximum metric Initial SPF schedule delay 5000 msecs Minimum hold time between two consecutive SPFs 10000 msecs Maximum wait time between two consecutive SPFs 10000 msecs Incremental-SPF disabled Minimum LSA inter
14、val 5 secs Minimum LSA arrival 1000 msecs 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 Numbe
15、r of DoNotAge external and opaque AS LSA 0 Number of areas transit capable is 0 External flood list length 0 IETF NSF helper support enabled Cisco NSF helper support enabled Area BACKBONE(0) Number of interfaces in this area is 2 (1 loopback) Area has no authentication SPF algorithm last executed 00
16、:14:14.748 ago SPF algorithm executed 6 times Area ranges are Number of LSA 4. Checksum Sum 0x02B6CC 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这个命令可以看到一些关于OSPF的信息。R2#show ip ospf
17、neighbor detail Neighbor 3.3.3.3, interface address 10.1.2.2 In the area 0 via interface Serial1/0 Neighbor priority is 0, State is FULL, 6 state changes DR is 0.0.0.0 BDR is 0.0.0.0 Options is 0x52 LLS Options is 0x1 (LR) Dead timer due in 00:31 Neighbor is up for 00:16:51 Index 2/2, retransmission
18、 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 1.1.1.1, interface address 10.1.1.1 In the area 0 via interface FastEthernet0/0 Neighbor priority
19、is 1, State is FULL, 6 state changes DR is 10.1.1.1 BDR is 10.1.1.23718:52 Index 1/1, retransmission queue length 0, number of retransmission 0 Last retransmission scan length is 0, maximum is 0Last retransmission scan time is 0 msec, maximum is 0 msec通过show ip ospf neighbor detail显示一个邻居列表,包括它们的OSPF
20、路由器ID,OSPF优先级,邻接关系(如init、预启动、完全连接等)及失效定时器。另外可以在路由模式下通过router-id A.B.C.D这个命令来设置RID,不过工程上一般上配置使用loopback接口的地址作为RID。2、验证性实验2.1、邻居状态验证2.1.1、OSPF邻居状态(init)拓扑如下图所示:图二OSPF的基本配置参考第1部分。首先不使用acl对数据包进行控制。两个路由器的配置如下R1:interface Loopback0 ip address 1.1.1.1 255.255.255.0!interface Serial1/0 ip address 10.1.1.1 2
21、55.255.255.0 serial restart-delay 0router ospf 1 log-adjacency-changes network 1.1.1.0 0.0.0.255 area 0 network 10.1.1.0 0.0.0.255 area 0R2: ip address 2.2.2.2 255.255.255.0 ip address 10.1.1.2 255.255.255.0 network 2.2.2.0 0.0.0.255 area 0 通过命令查看邻居情况R1#sh ip ospf neighbor 31 10.1.1.2 Serial1/0R2#sh
22、 ip ospf neighbor 1.1.1.1 0 FULL/ - 00:35 10.1.1.1 Serial1/0 可以看到两个路由器已经形成了邻居。这时通过ACL对通过路由器的数据包进行控制,配置如下:R1#conf tR1(config)#access-list 1 permit 2.2.2.2R1(config)#int s1/0R1(config-if)#ip access-group 1 in 这时再通过命令来查看邻接信息R1#1.1.1.1 0 INIT/ - 00:31 10.1.1.1 Serial1/0 在R1里没有发现邻居信息。而在R2上虽然可以看到R1但R1处于初始
23、化的状态,这样是不能形成邻接关系的,也不能交换各自的路由信息。这主要是因为R1上的ACL挡住了来自R2的Hello包,所以R1不能与R2形成邻居,而R2虽然收到R1的Hello,并发出了带R1的Hello包,但R1不收。2.1.2、OSPF邻居状态(two-way) 实验拓扑如下图所示:图三这个实验与2.1.1不同的是中间连接的链路变成了以太网。也就是所在two-way状态之后必须要选举DR和BDR。实验的基本配置:interface FastEthernet0/0 ip ospf priority 0 duplex auto speed auto 可以看到,这里更改了ospf接口的优先级,把两个路由器相连的接口都改为0了。然后再查看ospf的邻居表。2.2.2.2 0 2WAY/DROTHER 00:32 10.1.1.2 FastEthernet0/01.1.1.1 0 2WAY/DROTHER 00:31 10.1.1.1 FastEthernet0/0 可以看到,他们之间能成为two-way状态,并且由于不存在选举为DR和BDR的条件,所以停留在了two-way状态,而且都为DROTHER。2.1.3、OSPF邻居状态(Exstart) 首先在2.1.2的基础上把两个接口的优先级改为默认值。然后在R1的接口上修改MTU。配置如下:interface L
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2