做本实验一定要仔细,实验目的是解决R1是个特别低端的路由器,处理不了大量的路由信息,我们可以配置成STUB和totally stub区域来减少相关LSA的接收,以达到减少路由表的目的,从而达到低端路由器无用武之地的情况。 预配置 R1(config)#int lo0 R1(config-if)#ip add 1.1.1.1 255.255.255.0 R1(config-if)#int s2/1 R1(config-if)#ip add 12.0.0.1 255.255.255.0 R1(config-if)#no sh

R2(config)#int lo0 R2(config-if)#ip add 2.2.2.2 255.255.255.0 R2(config-if)#int s2/1 R2(config-if)#ip add 12.0.0.2 255.255.255.0 R2(config-if)#no sh R2(config-if)#int s2/2 R2(config-if)#ip add 23.0.0.2 255.255.255.0
R2(config-if)#no sh

R3(config)#int lo0 R3(config-if)#ip add 3.3.3.3 255.255.255.0 R3(config-if)#int s2/1 R3(config-if)#ip add 23.0.0.3 255.255.255.0 R3(config-if)#no sh R3(config-if)#int s2/2 R3(config-if)#ip add 34.0.0.3 255.255.255.0 R3(config-if)#no sh

R4(config)#int lo0 R4(config-if)#ip add 4.4.4.4 255.255.255.0 R4(config-if)#int s2/1 R4(config-if)#ip add 34.0.0.4 255.255.255.0 R4(config-if)#no sh R4(config-if)#int s2/2 R4(config-if)#ip add 45.0.0.4 255.255.255.0 R4(config-if)#no sh

R5(config)#int s2/2 R5(config-if)#ip add 45.0.0.5 255.255.255.0 R5(config-if)#no sh R5(config-if)#int l0 R5(config-if)#ip add 5.5.5.5 255.255.255.0 R5(config-if)#end


实验过程: 第一步:在各路由器配置ospf协议 R1(config)#router os 11 R1(config-router)#net 1.1.1.1 0.0.0.255 a 1 R1(config-router)#net 12.0.0.1 0.0.0.255 a 1

R2(config)#router os 11 R2(config-router)#net 2.2.2.2 0.0.0.255 a 0 R2(config-router)#net 12.0.0.2 0.0.0.255 a 1 R2(config-router)#net 23.0.0.3 0.0.0.255 a 0

R3(config)#router os 11 R3(config-router)#net 3.3.3.3 0.0.0.255 a 0 R3(config-router)#net 23.0.0.3 0.0.0.255 a 0 R3(config-router)#net 34.0.0.3 0.0.0.255 a 0

R4(config)#router os 11 R4(config-router)#net 4.4.4.4 0.0.0.255 a 0 R4(config-router)#net 45.0.0.4 0.0.0.255 a 2 R4(config-router)#net 34.0.0.4 0.0.0.255 a 0

R5(config)#router os 11 R5(config-router)#net 5.5.5.5 255.255.255.0 a 2 R5(config-router)#net 45.0.0.5 0.0.0.255 a 2 第二步:查看R1和R2的路由表 R1#sh ip rou ……………… 34.0.0.0/24 is subnetted, 1 subnets O IA 34.0.0.0 [110/192] via 12.0.0.2, 00:04:19, Serial2/1 1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets O IA 2.2.2.2 [110/65] via 12.0.0.2, 00:05:26, Serial2/1 3.0.0.0/32 is subnetted, 1 subnets O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:04:29, Serial2/1 4.0.0.0/32 is subnetted, 1 subnets O IA 4.4.4.4 [110/193] via 12.0.0.2, 00:02:48, Serial2/1 5.0.0.0/32 is subnetted, 1 subnets O IA 5.5.5.5 [110/257] via 12.0.0.2, 00:02:06, Serial2/1 23.0.0.0/24 is subnetted, 1 subnets O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:05:17, Serial2/1 12.0.0.0/24 is subnetted, 1 subnets C 12.0.0.0 is directly connected, Serial2/1 45.0.0.0/24 is subnetted, 1 subnets O IA 45.0.0.0 [110/256] via 12.0.0.2, 00:02:48, Serial2/1

R2#sh ip rou ……………… 34.0.0.0/24 is subnetted, 1 subnets O 34.0.0.0 [110/128] via 23.0.0.3, 00:01:48, Serial2/2 1.0.0.0/32 is subnetted, 1 subnets O 1.1.1.1 [110/65] via 12.0.0.1, 00:04:17, Serial2/1 2.0.0.0/24 is subnetted, 1 subnets C 2.2.2.0 is directly connected, Loopback0 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/65] via 23.0.0.3, 00:01:48, Serial2/2 4.0.0.0/32 is subnetted, 1 subnets O 4.4.4.4 [110/129] via 23.0.0.3, 00:01:48, Serial2/2 5.0.0.0/32 is subnetted, 1 subnets O IA 5.5.5.5 [110/193] via 23.0.0.3, 00:01:06, Serial2/2 23.0.0.0/24 is subnetted, 1 subnets C 23.0.0.0 is directly connected, Serial2/2 12.0.0.0/24 is subnetted, 1 subnets C 12.0.0.0 is directly connected, Serial2/1 45.0.0.0/24 is subnetted, 1 subnets 第三步:在R4上做重分布并查看数据库,目的是将直连引入路由 R4(config)#int lo1 R4(config-if)#ip add 4.4.5.4 255.255.255.0 R4(config-if)#int lo2
R4(config-if)#ip add 4.4.6.4 255.255.255.0 R4(config-if)#int lo3
R4(config-if)#ip add 4.4.7.4 255.255.255.0 R4(config-if)#int lo4
R4(config-if)#ip add 4.4.8.4 255.255.255.0 R4(config)#router os 11 **R4(config-router)#redistribute connected subnets ** R4(config-router)#end

R4#sh ip os d

OSPF Router with ID (4.4.4.4) (Process ID 11)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count 2.2.2.2 2.2.2.2 535 0x80000004 0x00A496 3 3.3.3.3 3.3.3.3 443 0x80000004 0x006AD2 5 4.4.4.4 4.4.4.4 70 0x80000004 0x007E8A 3

Summary Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum 1.1.1.1 2.2.2.2 579 0x80000001 0x00AB44 5.5.5.5 4.4.4.4 387 0x80000001 0x00B621 12.0.0.0 2.2.2.2 589 0x80000001 0x0033B5 45.0.0.0 4.4.4.4 461 0x80000001 0x004877

Router Link States (Area 2)

Link ID ADV Router Age Seq# Checksum Link count 4.4.4.4 4.4.4.4 70 0x80000003 0x0048C4 2 5.5.5.5 5.5.5.5 402 0x80000002 0x002BBB 3

Summary Net Link States (Area 2)

Link ID ADV Router Age Seq# Checksum 1.1.1.1 4.4.4.4 429 0x80000001 0x0074F2 2.2.2.2 4.4.4.4 430 0x80000001 0x00C3DF 3.3.3.3 4.4.4.4 430 0x80000001 0x0013CC 4.4.4.4 4.4.4.4 467 0x80000001 0x0062B9 12.0.0.0 4.4.4.4 430 0x80000001 0x00FB64 23.0.0.0 4.4.4.4 430 0x80000001 0x00E9AB 34.0.0.0 4.4.4.4 440 0x80000001 0x00D7F2

Type-5 AS External Link States //这里有5类的 Link ID ADV Router Age Seq# Checksum Tag 4.4.5.0 4.4.4.4 70 0x80000001 0x00D3AF 0 4.4.6.0 4.4.4.4 70 0x80000001 0x00C8B9 0 4.4.7.0 4.4.4.4 70 0x80000001 0x00BDC3 0 4.4.8.0 4.4.4.4 70 0x80000001 0x00B2CD 0 第四步:在R1上查看路由表 R1#sh ip rou Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - 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 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 o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

34.0.0.0/24 is subnetted, 1 subnets O IA 34.0.0.0 [110/192] via 12.0.0.2, 00:11:02, Serial2/1 1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets O IA 2.2.2.2 [110/65] via 12.0.0.2, 00:12:09, Serial2/1 3.0.0.0/32 is subnetted, 1 subnets O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:11:13, Serial2/1 4.0.0.0/8 is variably subnetted, 5 subnets, 2 masks O IA 4.4.4.4/32 [110/193] via 12.0.0.2, 00:09:31, Serial2/1 O E2 4.4.5.0/24 [110/20] via 12.0.0.2, 00:03:22, Serial2/1 O E2 4.4.6.0/24 [110/20] via 12.0.0.2, 00:03:22, Serial2/1 O E2 4.4.7.0/24 [110/20] via 12.0.0.2, 00:03:22, Serial2/1 O E2 4.4.8.0/24 [110/20] via 12.0.0.2, 00:03:23, Serial2/1 5.0.0.0/32 is subnetted, 1 subnets O IA 5.5.5.5 [110/257] via 12.0.0.2, 00:08:49, Serial2/1 23.0.0.0/24 is subnetted, 1 subnets O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:12:00, Serial2/1 12.0.0.0/24 is subnetted, 1 subnets C 12.0.0.0 is directly connected, Serial2/1 45.0.0.0/24 is subnetted, 1 subnets O IA 45.0.0.0 [110/256] via 12.0.0.2, 00:09:32, Serial2/1 //我们在这里看到了许多5类lsa产生的路由 第四步:将R2 R1的ospf area1区配置为stub区 R2(config)#router os 11 R2(config-router)#area 1 stub R1(config)#router os 11 R1(config-router)#area 1 stub

第五步:再查看R1上的路由表的数据库 R1#sh ip rou Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - 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 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 o - ODR, P - periodic downloaded static route

Gateway of last resort is 12.0.0.2 to network 0.0.0.0

34.0.0.0/24 is subnetted, 1 subnets O IA 34.0.0.0 [110/192] via 12.0.0.2, 00:00:06, Serial2/1 1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets O IA 2.2.2.2 [110/65] via 12.0.0.2, 00:00:06, Serial2/1 3.0.0.0/32 is subnetted, 1 subnets O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:00:06, Serial2/1 4.0.0.0/32 is subnetted, 1 subnets O IA 4.4.4.4 [110/193] via 12.0.0.2, 00:00:06, Serial2/1 5.0.0.0/32 is subnetted, 1 subnets O IA 5.5.5.5 [110/257] via 12.0.0.2, 00:00:06, Serial2/1 23.0.0.0/24 is subnetted, 1 subnets O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:00:07, Serial2/1 12.0.0.0/24 is subnetted, 1 subnets C 12.0.0.0 is directly connected, Serial2/1 45.0.0.0/24 is subnetted, 1 subnets O IA 45.0.0.0 [110/256] via 12.0.0.2, 00:00:07, Serial2/1 O*IA 0.0.0.0/0 [110/65] via 12.0.0.2, 00:00:07, Serial2/1 //现在R1已经没有了重发布的外部路由,取而代之的是一条指向12.0.0.2的默认路由, Cost等于64(R1与R2的接口cost)+1(默认stub cost)=65 R1#sh ip os d

OSPF Router with ID (1.1.1.1) (Process ID 11)

Router Link States (Area 1)

Link ID ADV Router Age Seq# Checksum Link count 1.1.1.1 1.1.1.1 24 0x80000005 0x000C58 3 2.2.2.2 2.2.2.2 24 0x80000003 0x007203 2

Summary Net Link States (Area 1)

Link ID ADV Router Age Seq# Checksum 0.0.0.0 2.2.2.2 70 0x80000001 0x0075C0 2.2.2.2 2.2.2.2 70 0x80000002 0x001716 3.3.3.3 2.2.2.2 70 0x80000002 0x006B7D 4.4.4.4 2.2.2.2 70 0x80000002 0x00BFE4 5.5.5.5 2.2.2.2 70 0x80000002 0x00144C 23.0.0.0 2.2.2.2 70 0x80000002 0x00BF1F 34.0.0.0 2.2.2.2 70 0x80000002 0x00B2E0 45.0.0.0 2.2.2.2 70 0x80000002 0x00A5A2 //我们在这里没的看到5类的lsa 但是R2上依然存在 第五步:在R1上做个测试 R1#ping
Protocol [ip]: Target IP address: 4.4.6.4 Repeat count [5]: Datagram size [100]: Timeout in seconds [2]: Extended commands [n]: y Source address or interface: Type of service [0]: Set DF bit in IP header? [no]: Validate reply data? [no]: Data pattern [0xABCD]: Loose, Strict, Record, Timestamp, Verbose[none]: r Number of hops [ 9 ]: Loose, Strict, Record, Timestamp, Verbose[RV]: Sweep range of sizes [n]: Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 4.4.6.4, timeout is 2 seconds: Packet has IP options: Total option bytes= 39, padded length=40 Record route: <*> (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0) (0.0.0.0)

Reply to request 0 (96 ms). Received packet has options Total option bytes= 40, padded length=40 Record route: (12.0.0.1) (23.0.0.2) (34.0.0.3) (4.4.6.4) (34.0.0.4) (23.0.0.3) (12.0.0.2) (12.0.0.1) <*> (0.0.0.0) End of list

Reply to request 1 (44 ms). Received packet has options Total option bytes= 40, padded length=40 Record route: (12.0.0.1) (23.0.0.2) (34.0.0.3) (4.4.6.4) (34.0.0.4) (23.0.0.3) (12.0.0.2) (12.0.0.1) <*> (0.0.0.0) End of list

Reply to request 2 (24 ms). Received packet has options Total option bytes= 40, padded length=40 Record route: (12.0.0.1) (23.0.0.2) (34.0.0.3) (4.4.6.4) (34.0.0.4) (23.0.0.3) (12.0.0.2) (12.0.0.1) <*> (0.0.0.0) End of list

Reply to request 3 (68 ms). Received packet has options Total option bytes= 40, padded length=40 Record route: (12.0.0.1) (23.0.0.2) (34.0.0.3) (4.4.6.4) (34.0.0.4) (23.0.0.3) (12.0.0.2) (12.0.0.1) <*> (0.0.0.0) End of list

Reply to request 4 (16 ms). Received packet has options Total option bytes= 40, padded length=40 Record route: (12.0.0.1) (23.0.0.2) (34.0.0.3) (4.4.6.4) (34.0.0.4) (23.0.0.3) (12.0.0.2) (12.0.0.1) <*> (0.0.0.0) End of list

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/49/96 ms //这里我们可以看到R1出发的路由表经过R1—R2—R3—R4—R3—R2—R1回来 简单总结:stub只对5类LSA过滤,其它的类型还在。



配置totally stub区域 我们先把以前的实验NO掉 第一步:在ospf 1 区上配置totally stub R1(config)#router os 11 R1(config-router)#area 1 stub no-summary

R2(config)#router os 11 R2(config-router)#area 1 stub no-summary 第二步:我们查看R1上的路由表和数据库 R1#sh ip rou ……………… 1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 12.0.0.0/24 is subnetted, 1 subnets C 12.0.0.0 is directly connected, Serial2/1 O*IA 0.0.0.0/0 [110/65] via 12.0.0.2, 00:01:04, Serial2/1 //这里可以看到的是:只有下一跳去往12.0.0.2的路由条目了

R1#sh ip o d

OSPF Router with ID (1.1.1.1) (Process ID 11)

Router Link States (Area 1)

Link ID ADV Router Age Seq# Checksum Link count 1.1.1.1 1.1.1.1 104 0x80000004 0x000E57 3 2.2.2.2 2.2.2.2 101 0x80000004 0x007004 2

Summary Net Link States (Area 1)

Link ID ADV Router Age Seq# Checksum 0.0.0.0 2.2.2.2 107 0x80000001 0x0075C0 R1#
第三步:测试 R1#ping 4.4.8.4

Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 4.4.8.4, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 24/54/92 ms R1# 简单总结:totally stub可以过滤3.4.5型的lsa