拓扑图:
要求:
理解 OSPF 协议的工作原理,并通过 OSPF 路由协议实现不同网络互通。
实验步骤: 1、配置好 PC 机的 IP 地址等参数。 PC 0>ipconfig IP Address......................: 172.16.0.2 Subnet Mask.....................: 255.255.255.0 Default Gateway.................: 172.16.0.1 2、配置路由器各个接口的 IP 地址等参数
2、配置交换机的 VLAN 信息(4 台二层交换机可以不做任何配置) 配置交换机的各端口的 VLAN 信息,使得PC0和 PC1 属于 VLAN10;PC2和 PC3属于 VLAN20;
PC4和 PC5属于 VLAN30;PC6 和 PC7 属于 VLAN40;配置完成后,各V LAN内部PC能互通,其它不能互通。
3、OSPF 路由协议配置 OSPF 的基本配置命令如下:
Router(config)#router ospf 1
Router(config-router)#network 192.168.1.0 0.0.0.255 area 0
Router(config-router)#router-id 10.1.1.1
配置命令:
(1)、在R1的配置:
Router(config)#hostname R1
R1(config)#inter f0/0
R1(config-if)#ip add 172.16.0.1 255.255.255.0
R1(config-if)#no shut
R1(config)#inter s1/0
R1(config-if)#ip add 192.168.0.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#clock rate 64000
R1(config-if)#no shut
R1(config)#router ospf 1
R1(config-router)#network 172.16.0.0 0.0.0.255 area 0
R1(config-router)#network 192.168.0.0 0.0.0.255 area 0
R1的路由表:
R1#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - 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 - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
O 10.1.1.0 [110/193] via 192.168.0.2, 00:08:13, Serial1/0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, FastEthernet0/0
172.17.0.0/24 is subnetted, 1 subnets
O 172.17.0.0 [110/65] via 192.168.0.2, 00:12:10, Serial1/0
172.18.0.0/24 is subnetted, 1 subnets
O 172.18.0.0 [110/129] via 192.168.0.2, 00:10:05, Serial1/0
C 192.168.0.0/24 is directly connected, Serial1/0
O 192.168.1.0/24 [110/128] via 192.168.0.2, 00:12:42, Serial1/0
O 192.168.2.0/24 [110/192] via 192.168.0.2, 00:10:27, Serial1/0
(2)、在R2上的配置:
Router(config)#hostname R2
R2(config)#inter s1/0
R2(config-if)#ip add 192.168.0.2 255.255.255.0
R2(config-if)#no shut
R2(config)#inter f0/0
R2(config-if)#ip add 172.17.0.1 255.255.255.0
R2(config-if)#no shut
R2(config)#inter s1/1
R2(config-if)#ip add 192.168.1.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#clock rate 64000
R2(config-if)#no shut
R2(config)#router ospf 1
R2(config-router)#network 192.168.0.0 0.0.0.255 area 0
R2(config-router)#network 192.168.1.0 0.0.0.255 area 0
R2(config-router)#network 172.17.0.0 0.0.0.255 area 0
R2的路由表:
R2#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - 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 - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
O 10.1.1.0 [110/129] via 192.168.1.2, 00:13:40, Serial1/1
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/65] via 192.168.0.1, 00:18:20, Serial1/0
172.17.0.0/24 is subnetted, 1 subnets
C 172.17.0.0 is directly connected, FastEthernet0/0
172.18.0.0/24 is subnetted, 1 subnets
O 172.18.0.0 [110/65] via 192.168.1.2, 00:15:32, Serial1/1
C 192.168.0.0/24 is directly connected, Serial1/0
C 192.168.1.0/24 is directly connected, Serial1/1
O 192.168.2.0/24 [110/128] via 192.168.1.2, 00:15:55, Serial1/1
(3)、在R3上的配置:
Router(config)#hostname R3
R3(config)#inter f0/0
R3(config-if)#ip add 172.18.0.1 255.255.255.0
R3(config-if)#no shut
R3(config)#inter s1/0
R3(config-if)#ip add 192.168.1.2 255.255.255.0
R3(config-if)#no shut
R3(config)#inter s1/1
R3(config-if)#ip add 192.168.2.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#clock rate 64000
R3(config-if)#no shut
R3(config)#router ospf 1
R3(config-router)#network 192.168.1.0 0.0.0.255 area 0
R3(config-router)#network 192.168.2.0 0.0.0.255 area 0
R3(config-router)#network 172.18.0.0 0.0.0.255 area 0
R3的路由表:
R3#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - 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 - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
O 10.1.1.0 [110/65] via 192.168.2.2, 00:10:53, Serial1/1
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/129] via 192.168.1.1, 00:13:17, Serial1/0
172.17.0.0/24 is subnetted, 1 subnets
O 172.17.0.0 [110/65] via 192.168.1.1, 00:13:17, Serial1/0
172.18.0.0/24 is subnetted, 1 subnets
C 172.18.0.0 is directly connected, FastEthernet0/0
O 192.168.0.0/24 [110/128] via 192.168.1.1, 00:13:17, Serial1/0
C 192.168.1.0/24 is directly connected, Serial1/0
C 192.168.2.0/24 is directly connected, Serial1/1
(4)、在R4的配置:
Router(config)#hostname R4
R4(config)#inter f0/0
R4(config-if)#ip add 10.1.1.1 255.255.255.0
R4(config-if)#no shut
R4(config)#inter s1/0
R4(config-if)#ip add 192.168.2.2 255.255.255.0
R4(config-if)#no shut
R4(config)#router ospf 1
R4(config-router)#network 10.1.1.0 0.0.0.255 area 0
R4(config-router)#network 192.168.2.0 0.0.0.255 area 0
R4的路由表:
R4#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - 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 - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/193] via 192.168.2.1, 00:14:31, Serial1/0
172.17.0.0/24 is subnetted, 1 subnets
O 172.17.0.0 [110/129] via 192.168.2.1, 00:14:31, Serial1/0
172.18.0.0/24 is subnetted, 1 subnets
O 172.18.0.0 [110/65] via 192.168.2.1, 00:14:31, Serial1/0
O 192.168.0.0/24 [110/192] via 192.168.2.1, 00:14:31, Serial1/0
O 192.168.1.0/24 [110/128] via 192.168.2.1, 00:14:31, Serial1/0
C 192.168.2.0/24 is directly connected, Serial1/0
PC>ping 172.17.0.2
Pinging 172.17.0.2 with 32 bytes of data:
Reply from 172.17.0.2: bytes=32 time=31ms TTL=126
Reply from 172.17.0.2: bytes=32 time=31ms TTL=126
Reply from 172.17.0.2: bytes=32 time=47ms TTL=126
Reply from 172.17.0.2: bytes=32 time=47ms TTL=126
Ping statistics for 172.17.0.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 31ms, Maximum = 47ms, Average = 39ms
(5)、运行结果分析:
PC>ping 172.18.0.2
Pinging 172.18.0.2 with 32 bytes of data:
Reply from 172.18.0.2: bytes=32 time=78ms TTL=125
Reply from 172.18.0.2: bytes=32 time=48ms TTL=125
Reply from 172.18.0.2: bytes=32 time=62ms TTL=125
Reply from 172.18.0.2: bytes=32 time=47ms TTL=125
Ping statistics for 172.18.0.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 47ms, Maximum = 78ms, Average = 58ms
PC>ping 10.1.1.2
Pinging 10.1.1.2 with 32 bytes of data:
Request timed out.
Reply from 10.1.1.2: bytes=32 time=78ms TTL=124
Reply from 10.1.1.2: bytes=32 time=79ms TTL=124
Reply from 10.1.1.2: bytes=32 time=78ms TTL=124
Ping statistics for 10.1.1.2:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 79ms, Average = 78ms
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/bluedream1219/article/details/46915635