实验TOP:

 

实验目的:学习ospf stub的配置和作用。

 

 

一、              路由器初始配置:

1.      R1上的初始配置

R1(config-line)#int s2/1

R1(config-if)#ip add 12.0.0.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#int lo 0

R1(config-if)#ip add 1.1.1.1 255.255.255.0

R1(config-if)#router os 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#net 1.1.1.1 0.0.0.0 a1

R1(config-router)#net 12.0.0.1 0.0.0.0 a 1

2.      R2上的初始配置:

R2(config-line)#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

R2(config-if)#int lo 0

R2(config-if)#ip add 2.2.2.2 255.255.255.0

R2(config-if)#router os 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#net 2.2.2.2 0.0.0.0 a 0

R2(config-router)#net 12.0.0.2 0.0.0.0 a 1

R2(config-router)#net 23.0.0.2 0.0.0.0 a 0

3.      R3上的初始配置:

R3(config-line)#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

R3(config-if)#int lo 0

R3(config-if)#ip add 3.3.3.3 255.255.255.0

R3(config-if)#router os 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#net 3.3.3.3 0.0.0.0 a 0

R3(config-router)#net 23.0.0.3 0.0.0.0 a 0

R3(config-router)#net 34.0.0.3 0.0.0.0 a 2

4.      R4上的初始配置:

R4(config-line)#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 lo 0

R4(config-if)#ip add 4.4.4.4 255.255.255.0

R4(config-if)#router os 1

R4(config-router)#router-id 4.4.4.4

R4(config-router)#net 4.4.4.4 0.0.0.0 a2

R4(config-router)#net 34.0.0.4 0.0.0.0 a 2

5.      查看OSPF的运行情况: 

R2(config-router)#do sh ip os ne

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

3.3.3.3           0   FULL/  -        00:00:31    23.0.0.3        Serial2/2

1.1.1.1           0   FULL/  -        00:00:31    12.0.0.1        Serial2/1

//查看R2上路由表信息

R2(config-router)#do sh ip rout

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/128] via 23.0.0.3, 00:05:19, Serial2/2

     1.0.0.0/32 is subnetted, 1 subnets

O       1.1.1.1 [110/65] via 12.0.0.1, 00:06:02, 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:05:19, Serial2/2

     4.0.0.0/32 is subnetted, 1 subnets

O IA    4.4.4.4 [110/129] via 23.0.0.3, 00:04:52, 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

//查看R1上的路由表信息

R1(config-router)#do sh ip rout

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:00:36, 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:01:23, 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:51, 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:14, 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:01:23, Serial2/1

     12.0.0.0/24 is subnetted, 1 subnets

C       12.0.0.0 is directly connected, Serial2/1

二、              实验过程:

将区域1配置为STUB区域:

R1(config-router)#area 1 stub//在R1上将区域1配置为STUB

R2(config-router)#area 1 stub//在R2上将区域1配置为STUB

三、              实验调试:

1. 重新查看R2上路由表信息

R2(config-router)#do sh ip rout

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/128] via 23.0.0.3, 00:02:54, Serial2/2

     1.0.0.0/32 is subnetted, 1 subnets

O       1.1.1.1 [110/65] via 12.0.0.1, 00:02:54, 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:03:09, Serial2/2

     4.0.0.0/32 is subnetted, 1 subnets

O IA    4.4.4.4 [110/129] via 23.0.0.3, 00:02:54, 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

2. 查看R1上的路由表变化:

R1(config-router)#do 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:04:08, 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:04:08, 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:08, 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:04:08, 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:04:08, Serial2/1

     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:04:09, Serial2/1

以上输出结果表明,R1增加了一条默认路由,指向R2的S2/1接口,如果在区域0或者1重发布其它路由信息,R1上也只会有这条默认路由。

3. 验证,在R4上重发布直连路由,在R1上查看路由表

//在R4上重建两条直连路由,并重分布到OSPF路由内

R4(config-if)#int lo 1

R4(config-if)#ip add 192.168.1.1 255.255.255.0

R4(config-if)#int lo 2

R4(config-if)#ip add 192.168.2.1 255.255.255.0

R4(config-if)#router os 1

R4(config-router)#redistribute connected subnets

//在R1上继续查看路由表

R1(config-router)#do sh ip rout

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:11:55, 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:11:55, 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:55, 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:11:55, 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:11:55, Serial2/1

     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:11:55, Serial2/1

以上结果表明,STUB区域过滤外部路由信息,并自动添加一条默认路由用于路由到远程网络。