监测清单11-3监测Router们和邻接关系的建立 R2(config)#int loop0 R2(config-if)#ip addr 10.1.1.1 255.255.255.0 R2(config-if)#int loop1 R2(config-if)#ip addr 10.1.2.1 255.255.255.0 R2(config-if)#exit R2(config)#logg console R2(config)#no router ospf 100 R2#debug ip ospf adj OSPF adjacency events debugging is on R2#conf t Enter configuration commands, one per line. End with CNTL/Z. R2(config)#router ospf 100 R2(config-router)#netw 192@168.1.2 0.0.0.0 area 0 R2(config-router)#^Z R2# 01:05:32: OSPF:Interface Serial1 going UP 01:05:33: OSPF:Build router LSA for area 0,router ID 10.1.2.1,seq 0x80000001 01:05:33: OSPF:2 Way Communication to 192.168.1.1 on Serial1,state 2WAY 01:05:33: OSPF:Send DBD to 192.168.1.1 on Serial1 seq OxIOA opt 0x42 flag 0x7 len 32 ' 01:05:33: OSPF:Rcv DBD from 192.168.1.1 on Serial1 seq Ox23F4 opt 0x42 flag 0x7 len 32 mtu 1500 EXSTART 01:05:33: OSPF: NBR Negotiation Done. We are the SLAVE 01:05:33: OSPF: Send DBD to 192.168.1.1 on Seriall seq Ox23F4 opt 0x42 flag 0x2 len 52 01:05:33: OSPF: Rev DBD from 192.168.1.1 on Seriall seq Ox23F5 opt 0x42 flag 0x3 len 72 mtu 1500 state EXCHANGE 01:05:33: OSPF: Send DBD to 192.168.1.1 on Seriall seq Ox23F5 opt 0x42 flag 0x0 len 32 01:05:33: OSPF: Database request to 192.168.1.1 01:05:33: OSPF: sent LS REQ packet to 192.168.1.1,length 24 01:05:34: OSPF: Rev DBD from 192.168.1.1 on Seriall seq Ox23F6 opt 0x42 flag 0x1 len 32 mtu 1500 state EXCHANGE 01:05:34: OSPF:Exchange Done with 192.168.1.1 on Serial1 01:05:34: OSPF: Send DBD to 192.168.1.1 on Seriall seq Ox23F6 opt 0x42 flag 0x0 len 32 01:05:34: OSPF:Synchronized with 192.168.1.1 on Serial1,state FULL 01:05:34: %OSPF-5-ADJCHG: PRocess 100,Nbr 192.168.1.1 on Serial1 from LOADING to FULL, Loading Done R2# R2#sh ip ospf 100 Routing Process "ospf 100" with ID 10.1.2.1 and Domain ID 0.0.0.100 Supports only single TOS(TOSO) routes Supports opaque LSA ... (此处省略)
R2# Term_Server>1 [Resuming connection 1 to r1 ... ] R1#sh ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 10.1.2.1 1 FULL/- 00:.00:29 192.168.1.2 Serial1 R1#
以下使用debug ip ospf events和debug ip ospf packet命令监测OSPF相关事件和相关数据包的传输。 监测清单11-4记录了有关操作及监测结果。
监测清单11-4监测OSPF事件和数据包 R1(config)#logg console R1(config)#^Z R1#debug ip ospf events OSPF events debuggmg is on R1# 02:08:50: OSPF: Rev hello from 10,1.2.1 area 0 from Serial1 192.168.1.2 02:08:50: OSPF: End of hello processing 02:09:00: OSPF: Rev hello from 10.1.2.1 area 0 from Serial1 192.168.1.2 02:09:00: OSPF: End of hello processing 02:09:10: OSPF: Rcv hello from 10.1.2.1 area 0 from Serial1 192.168.1.2 02:09:10: OSPF: End of hello processing 02:09:20:'OSPF: Rcv hello from 10.1.2.1 area 0 from Serial1 192.168.1.2 02:09:20: OSPF: End of hello processing R1#undebug all All possible debugging has been turned off R1#debug ip ospf packet OSPF packet debugging is on R1# 02:11:40: OSPF: rev. v:21:1 1:48 rid: 10.1.2.1 aid:0.0.0.0.chk:2DF3 aut:0 auk: from Serial1 02:11:50: OSPF: rev. v:21:1 1:48 rid: 10.1.2.1 aid:0.0.0.0 chk:2DF3 aut:0 auk: from Serial 1 02:12:00: OSPF: rev. v:2 t:1 1:48 rid: 10.1.2.1 aid:0.0.0.0 chk:2DF3 aut:0 auk: from Serial 1 02:12:10: OSPF: rev. v:2 t:1 1:48 rid:10.1.2.1 aid:0.0.0.0 ehk:2DF3 aut:0 auk: from Serial 1 02:12:20: OSPF: rev. v:2 t:1 1:48 rid: 10.1.2.1 aid:0.0.0.0 ehk:2DF3 aut:0 auk: from Serial 1 RS#undebug all All possible debugging has been turned off (1)在R1路由器上,首先打开对OSPF事件的Debug,监测结果显示了接收一系列的Hello包,其源地址是192.168.1.2,即R2的IP地址。 注重到Hello包之间的时间间隔是10秒,这是因为在点到点链路中,Hello包每隔10秒发送一次。 (2)关闭Debug。然后打开对OSPF包的监测,其命令是debug ip ospf packet。 R1路由器监测到从R2传来的一系列的OSPF包,这些包实际上就是每10秒接收1个的Hello包。
第3部分:调整带宽参数更改cost值
路由器接口的带宽参数对链路cost有直接的影响。 监测清单11-5是有关操作及监测结果的记录。
监测清单11-5更改带宽参数以影响cost值
让我们用实验来进行演示。
第1段:查看接口带宽与链路Cost R2#conft Enter configuration commands, one per line. End with CNTL/Z. R2(config)#router ospf 100 R2(config-router)#netw 192.168.1.5 0.0.0.0 area 0 R2(config"router)#^Z R2# R2#sh ip route ospf 172.16.0.0/24 is subnetted, 2 subnets O 172.16.1.0 [110/11] via 192.168.1.1, 00:00:33, Serial1 O 172.16.3.0 [110/11 via 192.168.1.6, 00:00:33, Serial0 R2#sh int s0 Serial0 is up, line protocol is up Hardware is HD64570 Internet address is 192.168.1.5/30 MTU 1500 DLY 20000 usec, reliability 255/255, txioad 1/255, rxioad 1/255 ... (此处删节) R2#sh int s1 Serial 1 is up, line protocol is up Hardware is HD64570 Internet address is 192.168.1.2/30 MTU 1500 bytes,BW 1544 Kbit,DLY 20000 usec, reliability 255/255, txioad 1/255, rxioad 1/255 ... (此处删节) R2#sh ip ospf int s0 Serial0 is up, line protocol is up Internet Address 192.168.1.5/30, Area 0 Process ID 100, Router ID 10.1.2.1, Network Type POINT_TO_POINT,Cost:64 ... (此处删节) R2#sh ip ospf int s1 Serial 1 is up, line protocol is up Internet Address 192.168.1.2/30, Area 0 Process ID 100, Router ID 10.1.2.1, Network Type POINT_TOJPOINT,Cost:64 Transmit Delay is 1 sec. State POINT_TO_POINT, ...(此处删节) R2# Term_Server>1 [Resuming connection 1 to r1 ... ] R1#sh ip ospf int e0 Ethernet0 is up, line protocol is up Internet Address 172.16.1.1/24, Area 0 Process ID 100, Router ID 192.168.1.1, Network Type BROADCAST,Cist:10 Transmit Delay is 1 sec. State DR, Priority 1 ... (此处删节) R1# 第2段:更改接口带宽以影响链路Cost Term_Server>2 [Resuming connection 2 to r2 ... ] R2#conft Enter configuration commands, one per line. End with CNTL/Z. R2(config)#int s0 R2(config-if)#bandwidth 64 R2(config-if)#int si R2(config-if)#bandwidth 125 R2(config-if)#^Z R2#sh ip route ospf 172.16.0.0/24 is subnetted, 2 subnets O 172.16.1.0 [110/810] via 192.168.1.1, 00:00:09, Serial1 O 172.16.3.0 [110/1572] via 192.168.1.6, 00:00:09, Serial0 R2#sh int s0 Serial0 is up, line protocol is up Hardware is HD64570 Internet address is 192.168.1.5/30 MTU 1500 bytes,BW 64 Kbit,DLY 20000 usec, reliability 255/255, txioad 1/255, rxioad 1/255 ... (此处删节) R2#sh int s1 Serial1 is up, line protocol is up Hardware is HD64570 Internet address is 192.168.1.2/30 MTU 1500 bytes,BW 125 Kbit,DLY 20000 usec, reliability 255/255, txioad 1/255, rxioad 1/255 ...(此处删节) R2#sh ip ospf int s0 Serial0 is up, line protocol is up Internet Address 192.168.1.5/30, Area 0 Process ID 100, Router ID 10.1.2.1, Network Type POINT_TO_POINT,Cost:1562 Transmit Delay is 1 sec. State POINT_TO_POINT, ... (此处删节) R2#sh ip ospf int s1 Serial 1 is up, line protocol is up Internet Address 192.168.1.2/30, Area 0 Process ID 100, Router ID 10.1.2.1, Network Type POINT_TO_POINT,Cost:800 Transmit Delay is 1 sec. State POINT_TO_POINT, ... (此处删节) R2# 第3段:直接更改接口相关Cost R2(config)#int s0 R2(config-if)#ip ospfcost 200 R2(config-if)#^Z R2#sh ip ospf int s0 Serial0 is up, line protocol is up Internet Address 192.168.1.5/30, Area 0 Process ID 100, Router ID 10.1.2.1, Network Type POINT_TO_POINT,Cost:200 Transmit Delay is 1 sec. State POINT_TO_POINT, Timer intervals configured. Hello 10, Dead 40, Wait 40, Retransmit 5 Hello due in 00:00:05 Index 2/2, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 4 msec Neighbor Count is 1, Adjacent neighbor count is 1 Adjacent with neighbor 192.168.1.6 Suppress hello for 0 neighbor(s) R2#sh ip route ospf 172.16.0.0/24 is subnetted, 2 subnets O 172.16.1.0 [110/1572] via 192.168.1.1, 00:00:11, Serial1 O 172.16.3.0 [110/210] via 192.168.1.6, 00:00:11, Serial0 R2# (1)在第1段开始时,首先在R2路由器上把S0接口加入到OSPF路由进程中,恢复全网的连通性。 使用show ip route ospf命令查看OSPF路由表,会看到经由S0和S1的2条路由的Cost值均为74。 这一结果是我们在以前的实验中没有注重到的,显然它不是我们所希望看到的,因为我们预期中的Cost值是S1比S0低,因为S1的带宽(125kbit/s)要比S0的带宽(64kbit/s)高。 (2)通过发出show interface命令对S0和S1的带宽进行考察发现,它们的带宽(BW)均为1544kbit/s,这是串行接口的缺省带宽。可见路由器并不能根据时钟的设置而自动更改带宽的设置。 (3)show ip ospf interface命令给出了S0和S1接口的Cost值,它们也为相同的64。 (4)细心的读者可能产生了一个疑问,即:为什么在路由表中显示的Cost(74)与接口的Cost(64)之间不同? 为说明问题,切换到R1路由器上,查看OSPF接口信息,表明其E0接口的Cost为10。 从R2路由器到172.16.1.0/24网段需要经过R1、R2之间的串行链路和R2的以太网接口,所以最终的Cost值为两个链路的Cost值相加,为74。对于到172.16.30/24网段的路由而言,其结果相同。 (5)在第2段中,通过更改相应接口的带宽参数来影响Cost值。 在R2路由器上,使用bandwidth命令,设置S0接口的带宽为64kbit/s,S1接口的带宽为125kbit/s。 查看OSPF路由表,结果显示相应的Cost己经更改为1572(S0接口)和810(S1接口)。 分别查看接口信息和OSPF接口信息,表明带宽和Cost值已经产生应有的变化,Cost值分别是1562(S0接口)和800(S1接口)。 (6)有一种更为直接的更改Cost值的方法,那就是第3段中演示的在接口配置模式下使 用ip ospfcost命令定义Cost的方法。 实验中我们把S0接口的Cost设定为200。相应的命令显示设置是成功的。 ip ospf cost命令不管相应接口的带宽为多少,人工设定一个Cost值,并立即生效,参与路由的计算。
第1段:R1路由器的配置清单 Current configuration : 642 bytes ! version 12.1 service timestamps debug uptime service timestamps log uptime no service passWord-encryption ! hostname R1 ip subnet-zero ! interface Ethemet0 ip address 172.16.1.1255.255.255.0 no keepalive ! interface Serial0 no ip address shutdown ! interface Serial 1 bandwidth 125 ip address 192.168.1.1255.255.255.252 clockrate 125000 ! router ospf 100 network 172.16.1.1 0.0.0.0 area 0 network 192.168.1.1 0.0.0.0 area 0 ! ip classless ip http server ! line con 0 line aux 0 line vty 0 4 login ! end
第2段:R2路由器的配置清单 Current configuration : 618 bytes ! version 12.1 service timestamps debug uptime service timestamps log uptime no service password-encryption hostname R2 ! ip subnet-zero ! interface Ethemet0 no ip address shutdown ! interface Serial0 bandwidth 64 ip address 192.168.1.5 255.255.255.252 ! interface Serial 1 bandwidth 125 ip address 192.168.1.2 255.255.255.252 ! router ospf 100 network 192.168.1.2 0.0.0.0 area 0 network 192.168.1.5 0.0.0.0 area 0 ! ip classless ip http server ! line con 0 line aux 0 line vty 0 4 login ! end 第3段:R3路由器的配置清单 Current configuration : 678 bytes version 12.1 service timestamps debug uptime service timestamps log uptime no service password-encryption ! hostname R3 ! ip subnet-zero ! interface Ethemet0 ip address 172.16.3.1255.255.255.0 no keepalive ! interface Serial0 bandwidth 64 ip address 192.168.1.6 255.255.25.5.252 clockrate 64000 ! interface Serial 1 no ip address shutdown ! router ospf 100 network 172.16.3.1 0.0.0.0 area 0 network 192.168.1.6 0.0.0.0 area 0 ! ip classless ip http server ! line con 0 line aux 0 line vty 0 4 login ! end