一、實驗目標:
1. 掌握綜合路由的配置方法;
2. 掌握查看通過路由重發布學習產生的路由;
3. 熟悉廣域網線纜的連接方式;
二、實驗背景:
假設某公司通過一臺三層交換機連接到公司出口路由器R1上,路由器R1再和公司外的另一臺路由器R2連接。三層交換機與R1運行RIPv2路由協議,R1與R2運行OSPF路由協議。現要做適當配置,實現公司內部主機與公司外部主機之間的相互通信。
三、技術原理:
爲了支持本設備能夠運行多個路由協議進程,系統軟件提供了路由信息從一個路由進程重分佈到另一個路由進程的功能。比如你可以將OSPF路由域的路由衝刺年分佈後通告RIP路由域中,也可以將RIP路由域的路由重新分佈後通告OSPF路由域中。路由的相互重分佈可以在所有的IP路由協議之間進行。
要把路由從一個路由域分佈到另一個路由域,並且進行控制控制路由重分佈,在路由進程配置模式中執行以下命令:
Redistribute protocol
[medtric metric] [metric-type metric-type] [matchinternal | external type | nassa-external type] [tag tag] [route-map route-map-name] [subnets]
三、拓撲圖:
實驗步驟:
1、新建packet tracer拓撲圖。
2、PC1與交換機用直連線連接,PC2與路由器用交叉線連接,路由器與路由器之間用V.35線纜連接,R1設置時鐘。
3、在三層交換機上劃分2個VLAN ,運行RIPV2協議,R2運行OSPF協議。
4、在路由器R1上左側配置RIPV2協議,右側配置OSPF協議。
5、在R1路由進程中引入外部路由,進行路由重分佈。
6、將PC1、PC2主機默認網關分別設置爲直連網絡設備接口IP地址。
7、驗證PC1、PC2主機之間可以互相通信。
四、基本配置:
SW:
Switch>en
Switch#conf t
Switch(config)#host sw
sw(config)#vlan 2
sw(config-vlan)#exit
sw(config)#int fa 0/10
sw(config-if)#switchport access vlan 2
sw(config-if)#no sh
sw(config-if)#ip add 192.168.2.1 255.255.255.0
sw(config-if)#int vlan 1
sw(config-if)#no sh
sw(config-if)#ip add 192.168.1.1 255.255.255.0
sw#conf t
sw(config)#router rip
sw(config-router)#network 192.168.1.0
sw(config-router)#network 192.168.2.0
sw(config-router)#version 2
sw(config-router)#end
sw#copy run start
sw# sh 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
C 192.168.1.0/24 is directly connected, Vlan1
C 192.168.2.0/24 is directly connected, Vlan2
R1:
Router>en
Router#conf t
Router(config)#host R1
R1(config)#int fa0/0
R1(config-if)#no sh
R1(config-if)#ip add 192.168.2.2 255.255.255.0
R1(config-if)#exit
R1(config)#int serial 2/0
R1(config-if)#no sh
R1(config-if)#clock rate 64000
R1(config-if)#ip add 192.168.3.1 255.255.255.0
R1(config)#router rip
R1(config-router)#network 192.168.2.0
R1(config-router)#version 2
R1(config-router)#exit
R1(config)#router ospf 1
R1(config-router)#network 192.168.3.0 0.0.0.255 area 0
R1(config-router)#end
R1#copy run start
R1#sh 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
R 192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:11, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, Serial2/0
O 192.168.4.0/24 [110/782] via 192.168.3.2, 00:01:36, Serial
R2:
Router>en
Router#conf t
Router(config)#host R2
R2(config)#int fa1/0
R2(config-if)#no sh
R2(config-if)#ip add 192.168.4.1 255.255.255.0
R2(config-if)#exit
R2(config)#int serial 2/0
R2(config-if)#no sh
R2(config-if)#ip add 192.168.3.2 255.255.255.0
R2(config-if)#exit
R2(config)#router ospf 1
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0
R2(config-router)#network 192.168.4.0 0.0.0.255 area 0
R2(config-router)#end
R2#copy run start
R2#sh 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
O E2 192.168.1.0/24 [110/3] via 192.168.3.1, 00:01:29, Serial2/0
O E2 192.168.2.0/24 [110/3] via 192.168.3.1, 00:01:29, Serial2/0
C 192.168.3.0/24 is directly connected, Serial2/0
C 192.168.4.0/24 is directly connected, FastEthernet1/0
五、核心配置:
R1:
R1#conf t
R1(config)#router rip
R1(config-router)#redistribute ospf 1 metric 2
R1(config-router)#exit
R1(config)#router ospf 1
R1(config-router)#redistribute rip subnets
R1(config-router)#end
經過R1上路由的重發布之後,SW上的路由表如下:
sw#sh 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
C 192.168.1.0/24 is directly connected, Vlan1
C 192.168.2.0/24 is directly connected, Vlan2
R 192.168.3.0/24 [120/2] via 192.168.2.2, 00:03:16, Vlan2
R 192.168.4.0/24 [120/2] via 192.168.2.2, 00:03:16, Vlan2