路由器動態路由的配置方法


一、實驗目的:

  1.理解動態路由的工作原理;

  2. 學習並掌握動態路由協議RIP的配置;

  3.學習並掌握動態路由協議OSPF的配置;

  4.進一步學習路由器的配置命令。

二、實驗原理:

  RIP:Routing Information Protocol,路由信息協議,是應用較早、使用較普遍的IGP內部網關協議,適用於小型同類網絡,是典型的距離矢量協議。

  RIP協議跳數作為衡量路徑開銷的,RIP協議里規定最大跳數為15。

  RIP協議有兩個版本RIPv1和RIPv2。

  RIPv1屬於有類路由協議,不支持VLSM(變長子網掩碼),RIPv1是以廣播的形式進行路由信息的更新的;更新周期為30秒。

  RIPv2屬於無類路由協議,支持VLSM(變長子網掩碼),RIPv2是以組播的形式進行路由信息的更新的,組播地址是224.0.0.9。RIPv2還支持基於端口的認證,提高網絡的安全性。

  OSPF協議用鏈路狀態來評估路由,可用於規模很大的網絡。

  OSPF可通過區域划分網絡,對於規模較小的網絡一般只設置一個區域0,對於規模較大的網絡,可划分多個區域,其中區域0是必不可少的,它用於連接其它各區域。

  OSPF協議采用組播方式進行OSPF包交換,組播地址為224.0.0.5(全部OSPF路由器)和224.0.06(指定路由器)。

  OSPF協議的管理距離是110,低於RIP協議的120,所以如果設備同時運行OSPF協議和RIP協議,則OSPF協議產生的路由優先級高。

 

三、實驗設備:

  Pc機、路由器、三層交換機

四、實驗拓撲圖

 

五、實驗過程:

1、基本配置

1)三層交換機的基本配置

Switch(config)#vlan 10                        !新建VLAN10

Switch(config)#interface fastethernet0/1      !將F0/1放入VLAN10

Switch(config-if)#switchport access vlan 10

Switch(config)#vlan 50                        !新建VLAN50

Switch(config)#interface fastethernet0/5      !將F0/5放入VLAN50

Switch(config-if)#switchport access vlan 50

Switch(config-if)#exit

Switch(config)#interface vlan 10

Switch(config-if)#ip address 192.168.1.2  255.255.255.0

Switch(config-if)#no shutdown                  !創建VLAN 10虛擬接口,並配置IP

Switch(config-if)#exit

Switch(config)#interface vlan 50

Switch(config-if)#ip address 192.168.5.1  255.255.255.0

Switch(config-if)#no shutdown                  !創建VLAN 50虛擬接口,並配置IP

 

2)   路由器基本配置

在路由器A上配置端口IP

RA(config)#interface fastethernet 1/0

RA(config-if)#ip address 192.168.1.1  255.255.255.0

RA(config-if)#no shutdown

RA(config)#interface serial 2/0

RA(config-if)#ip address 192.168.2.1  255.255.255.0

RA(config-if)# Clock rate 64000      !配置其時鍾頻率64000

RA(config-if)#no shutdown

在路由器B上配置端口IP

RB(config)#interface fastethernet 1/0

RB(config-if)#ip address 192.168.3.1  255.255.255.0

RB(config-if)#no shutdown

RB(config)#interface serial 2/0

RB(config-if)#ip address 192.168.2.2  255.255.255.0

RB(config-if)#no shutdown

 

 

2、配置RIPv2路由協議

1)三層交換機配置RIP協議

Switch(config)#router rip

Switch(config-router)#network 192.168.1.0            !申明本設備的直連網段

Switch(config-router)#network 192.168.5.0

Switch(config-router)#version 2

 

2)RA配置RIP v2協議

RA(config)#router rip

RA(config-router)#network 192.168.1.0              

RA(config-router)#network 192.168.2.0

RA(config-router)#version 2

RA(config-router)#no auto-summary                  !關閉路由信息的自動匯總功能

 

3)RB配置RIP v2協議

RB(config)#router rip

RB(config-router)#network 192.168.2.0              

RB(config-router)#network 192.168.3.0

RB(config-router)#version 2

RB(config-router)#no auto-summary               

 

 

3、驗證三台路由設備的路由表,查看是否自動學習了其他網段的路由信息。

Switch#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

 

C    192.168.1.0/24 is directly connected, Vlan10

R    192.168.2.0/24 [120/1] via 192.168.1.1, 00:00:26, Vlan10

R    192.168.3.0/24 [120/2] via 192.168.1.1, 00:00:26, Vlan10

C    192.168.5.0/24 is directly connected, Vlan50

 

RA#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

 

C    192.168.1.0/24 is directly connected, FastEthernet1/0

C    192.168.2.0/24 is directly connected, Serial2/0

R    192.168.3.0/24 [120/1] via 192.168.2.2, 00:00:24, Serial2/0

R    192.168.5.0/24 [120/1] via 192.168.1.2, 00:00:18, FastEthernet1/0

 

RB#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

 

R    192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:17, Serial2/0

C    192.168.2.0/24 is directly connected, Serial2/0

C    192.168.3.0/24 is directly connected, FastEthernet1/0

R    192.168.5.0/24 [120/2] via 192.168.2.1, 00:00:17, Serial2/0

 

4、配置OSPF路由協議

1) 在交換機上配置OSPF路由協議。

Switch>enable

Switch#config

Configuring from terminal, memory, or network [terminal]?

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#route ospf 1

Switch(config-router)#network 192.168.5.0 0.0.0.255 area 0

Switch(config-router)#network 192.168.1.0 0.0.0.255 area 0

Switch(config-router)#end

Switch#

%SYS-5-CONFIG_I: Configured from console by console

Switch#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

 

C    192.168.1.0/24 is directly connected, Vlan10

R    192.168.2.0/24 [120/1] via 192.168.1.1, 00:00:20, Vlan10

R    192.168.3.0/24 [120/2] via 192.168.1.1, 00:00:20, Vlan10

C    192.168.5.0/24 is directly connected, Vlan50

 

2) 在路由器RA上配置OSPF路由協議。

RA>enable

RA#config

Configuring from terminal, memory, or network [terminal]?

Enter configuration commands, one per line.  End with CNTL/Z.

RA(config)#route ospf 1

RA(config-router)#network 192.168.1.0 0.0.0.255 area 0

RA(config-router)#network 192.168.2.0 0.0.0.255 area 0

RA(config-router)#end

 

3) 在路由器RB上配置OSPF路由協議。

RB>enable

RB#config

Configuring from terminal, memory, or network [terminal]?

Enter configuration commands, one per line.  End with CNTL/Z.

RB(config)#router ospf 1

RB(config-router)#network 192.168.2.0 0.0.0.255 area 0

RB(config-router)#network 192.168.3.0 0.0.0.255 area 0

RB(config-router)#end

 

 

5、將PC0、PC1主機默認網關設置為與直連網路設備接口IP地址。

  

 

 

 

6、測試網絡的連通性

從pc0 ping pc1

 

網絡跟蹤命令:

 

 

 

六、實驗總結:

  本次實驗遇到的最大的問題是在前期准備階段,畫好拓撲圖並進行連接的時候,即便我按照實驗指導配好了相關的指令,還是不能連通路由器RB和PC1,后來索性換了一根線纜,就妥了。

  首先百度得知,直通線是用來連接直通線是將不同設備連接在一起,比如電腦和交換機,而交叉線是用來連接相同類型的設備的。后來通過進一步的了解得知,現在較新設備的網口都支持自動識別直通線或交叉線,因而交叉線正在逐漸消亡。雖然依然很迷,但是起碼它最后還是通了。

  配置OSPF協議也是完全通過百度搜相關資料才解決的。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM