天天看點

路由重釋出實驗

實驗拓撲:

路由重釋出實驗

試驗要求:R1與R2運作RIP,R3與R2之間運作OSPF,要求在R2上配置路由重釋出,使R1能夠學習到R3的路由,同樣R3能夠學到R1上的路由。并且配置彙總路由。

試驗目的:掌握路由重釋出的基本配置與在配置路由重釋出之前應該注意的地方。

試驗配置:

R1:

R1(config)#int s1/0

R1(config-if)#ip add 199.99.1.2 255.255.255.0

R1(config-if)#no shu

R1(config-if)#exit

R1(config)#int loop0

R1(config-if)#ip add 192.168.1.1 255.255.255.224

R1(config)#int loop1

R1(config-if)#ip add 192.168.1.33 255.255.255.224

R1(config)#int loop2

R1(config-if)#ip add 192.168.1.65 255.255.255.224

R1(config)#router rip

R1(config-router)#version 2

R1(config-router)#network 199.99.1.0

R1(config-router)#network 192.168.1.0

R1(config-router)#network 192.168.1.32

R1(config-router)#network 192.168.1.64

R1(config-router)#no auto-summary

R1(config-router)#exit

R2:

R2(config)#int s1/0

R2(config-if)#ip add 199.99.1.1 255.255.255.0

R2(config-if)#clock rate 64000

R2(config-if)#no shu

R2(config-if)#exit

R2(config)#int s1/1

R2(config-if)#ip add 199.99.2.1 255.255.255.0

R2(config)#router rip

R2(config-router)#network 199.99.1.0

R2(config-router)#version 2

R2(config-router)#no auto-summary

R2(config-router)#exit

R2(config)#router ospf 100

R2(config-router)#network 199.99.2.0 0.0.0.255 a 0

R2(config-router)#end

R3:

R3(config)#int s1/0

R3(config-if)#ip add 199.99.2.2 255.255.255.0

R3(config-if)#no shu

R3(config-if)#exit

R3(config)#int loop0

R3(config-if)#ip add 172.16.1.1 255.255.255.0

R3(config-if)#exit       

R3(config)#int loop1

R3(config-if)#ip add 172.16.2.1 255.255.255.0

R3(config)#int loop2

R3(config-if)#ip add 172.16.3.1 255.255.255.0

R3(config)#router ospf 100

R3(config-router)#network 199.99.2.0 0.0.0.255 a 0

R3(config-router)#network 172.16.1.0 0.0.0.255 a 1

R3(config-router)#network 172.16.2.0 0.0.0.255 a 1

R3(config-router)#network 172.16.3.0 0.0.0.255 a 1

R3(config-router)#exit

好了,以上為基本的配置,下面我們在每台路由器上檢視一下路由表:

R1#show ip route

C    199.99.1.0/24 is directly connected, Serial1/0

     192.168.1.0/27 is subnetted, 3 subnets

C       192.168.1.64 is directly connected, Loopback2

C       192.168.1.32 is directly connected, Loopback1

C       192.168.1.0 is directly connected, Loopback0

R2#show ip route

     172.16.0.0/32 is subnetted, 3 subnets

O IA    172.16.1.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1

O IA    172.16.3.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1

O IA    172.16.2.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1

C    199.99.2.0/24 is directly connected, Serial1/1

R       192.168.1.64 [120/1] via 199.99.1.2, 00:00:05, Serial1/0

R       192.168.1.32 [120/1] via 199.99.1.2, 00:00:05, Serial1/0

R       192.168.1.0 [120/1] via 199.99.1.2, 00:00:05, Serial1/0

R3#show ip route

     172.16.0.0/24 is subnetted, 3 subnets

C       172.16.1.0 is directly connected, Loopback0

C       172.16.2.0 is directly connected, Loopback1

C       172.16.3.0 is directly connected, Loopback2

C    199.99.2.0/24 is directly connected, Serial1/0

可以看到R1上隻顯示了自己直連的路由,R2上顯示了通過RIP和OSPF學到的所有路由,R3上也隻有自己直連的路由,下面在R2上配之路由重釋出,在配置之前需要注意的是在把其他路由協定重釋出到RIP,IGRP,EIGRP的時候,是需要手動添加度量,否則度量為無窮,但是重釋出直連和靜态路由時,度量預設為1, 在把其他路由協定重釋出到OSPF時,可以不用手動添加路徑成本,預設OSPF為重釋出的路由配置設定的路徑成本為20:

R2(config-router)#redistribute ospf 100 metric 3

這樣配置完成後就把OSPF 100的路由重釋出到RIP路由協定中,并且定義路徑成本為3跳,然後在R1上檢視路由表:

R1#show ip route

R       172.16.1.1 [120/3] via 199.99.1.1, 00:00:05, Serial1/0

R       172.16.3.1 [120/3] via 199.99.1.1, 00:00:05, Serial1/0

R       172.16.2.1 [120/3] via 199.99.1.1, 00:00:05, Serial1/0

R    199.99.2.0/24 [120/3] via 199.99.1.1, 00:00:05, Serial1/0

C       192.168.1.0 is directly connected, Loopback0

OK,學到了到R3上的路由,然後我們在R2上配置,把RIP重釋出到OSPF中:

R2(config-router)#redistribute rip subnets

在重釋出到OSPF中時,需要帶subnets參數,然後我們在R3上檢視路由表:

R3#show ip route 

O E2 199.99.1.0/24 [110/20] via 199.99.2.1, 00:00:09, Serial1/0

O E2    192.168.1.64 [110/20] via 199.99.2.1, 00:00:04, Serial1/0

O E2    192.168.1.32 [110/20] via 199.99.2.1, 00:00:03, Serial1/0

O E2    192.168.1.0 [110/20] via 199.99.2.1, 00:00:03, Serial1/0

好的,可以看到有O E2的路由了,表示OSPF自治系統外部路由,是從RIP重釋出過來的。是類型2的外部路由,我們可以手動修改:

R2(config-router)#redistribute rip metric 40 metric-type 1 subnets

然後再到R3上檢視路由表:

R3#show ip route 

O E1 199.99.1.0/24 [110/104] via 199.99.2.1, 00:00:00, Serial1/0

O E1    192.168.1.64 [110/104] via 199.99.2.1, 00:00:00, Serial1/0

O E1    192.168.1.32 [110/104] via 199.99.2.1, 00:00:00, Serial1/0

O E1    192.168.1.0 [110/104] via 199.99.2.1, 00:00:00, Serial1/0

類型變成1類外部路由,路徑成本也變大了。

下面我們開始路由彙總的配置,首先在R1上彙總RIP路由:

R1(config-if)#ip summary-address rip 192.168.1.0 255.255.255.0

然後在R2和R3上驗證:

R2#show ip route  

     172.16.0.0/32 is subnetted, 3 subnets

R    192.168.1.0/24 [120/1] via 199.99.1.2, 00:00:09, Serial1/0

O E1 199.99.1.0/24 [110/104] via 199.99.2.1, 00:00:48, Serial1/0

O E1 192.168.1.0/24 [110/104] via 199.99.2.1, 00:00:33, Serial1/0

現在從RIP學到的路由變成了一條彙總的路由,注意在彙總路由時應注意,子網路遮罩應該大于或者等于預設主網絡掩碼。然後我們在R3上做彙總:

R3(config-router)#area 1 rang 172.16.0.0 255.255.0.0

這裡值得注意的問題:使用該指令時有 Summarize routes matching address/mask (border routers only) 也就是說隻有邊界路由器可以用range 172.16.0.0 255.255.0.0

border router (邊界路由器)-----通常在開放最短路徑優先 (OSPF)中定義為連接配接一個地區到骨幹區的路由器,是以彙總的路由需是在非骨幹區域的其他區域

然後我們在R1和R2上驗證:

O IA 172.16.0.0/16 [110/65] via 199.99.2.2, 00:00:22, Serial1/1

R    192.168.1.0/24 [120/1] via 199.99.1.2, 00:00:04, Serial1/0

R1#show ip route  

R    172.16.0.0/16 [120/3] via 199.99.1.1, 00:00:07, Serial1/0

R    199.99.2.0/24 [120/3] via 199.99.1.1, 00:00:07, Serial1/0

現在從OSPF重釋出的路由也變成了一條預設路由。

繼續閱讀