Packet Tracer 5.0實驗(十) 路由器OSPF動態路由配置


一、實驗目標

  • 掌握OSPF協議的配置方法;
  • 掌握查看通過動態路由協議OSPF學習產生的路由;
  • 熟悉廣域網線纜的連接方式;

二、實驗背景

假設某公司通過一台三層交換機連到公司出口路由器上,路由器再和公司外的另一台路由器連接。現要做適當配置,實現公司內部主機與公司外部主機之間的相互通信。為了簡化網管的管理維護工作,公司決定采用OSPF協議實現互通。

三、技術原理

OSPF開放式最短路徑優先協議,是目前網絡中應用最廣泛的路由協議之一。屬於內部網關路由協議,能夠適應各種規模的網絡環境,是典型的鏈路狀態協議。OSPF路由協議通過向全網擴散設備的鏈路狀態信息,使網絡中每台設備最終同步一個具有全網鏈路狀態的數據庫,然后路由器采用SPF算法,以自己為根,計算到達其他網絡的最短路徑,最終形成全網路由信息。

四、實驗步驟

實驗拓撲

1、在三層交換機上划分VLAN10和VLAN20,其中VLAN10用於連接校園網主機,VLAN20用於連接R1;

2、路由器之間通過V.35電纜通過串口連接,DCE端連接在R1上,配置其時間頻率為64000;

3、主機和交換機通過直連線連接,主機與路由器通過交叉線連接;

4、在S3560上配置OSPF路由協議;

5、在路由器R1、R2上配置OSPF路由協議;

6、將PC1、PC2主機默認網關分別設置為與直連網絡設備接口IP地址;

7、驗證PC1、PC2主機之間可以互相通信;

S3560:

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname S3560
S3560(config)#vlan 10
S3560(config-vlan)#exit
S3560(config)#vlan 20
S3560(config-vlan)#exit
S3560(config)#interface fa0/10
S3560(config-if)#switchport access vlan 10
S3560(config-if)#exit
S3560(config)#interface fa0/20
S3560(config-if)#switchport access vlan 20
S3560(config-if)#exit
S3560(config)#interface vlan 10
S3560(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

S3560(config-if)#ip address 192.168.1.1 255.255.255.0
S3560(config-if)#exit
S3560(config)#interface vlan 20

%LINK-5-CHANGED: Interface Vlan20, changed state to up
S3560(config-if)#ip address 192.168.3.1 255.255.255.0
S3560(config-if)#exit
S3560(config)#router ospf ?
  <1-65535>  Process ID
S3560(config)#router ospf 1
S3560(config-router)#network 192.168.1.0 ?
  A.B.C.D  OSPF wild card bits
S3560(config-router)#network 192.168.1.0 0.0.0.255 ?
  area  Set the OSPF area ID
S3560(config-router)#network 192.168.1.0 0.0.0.255 area ?
  <0-4294967295>  OSPF area ID as a decimal value
  A.B.C.D         OSPF area ID in IP address format
S3560(config-router)#network 192.168.1.0 0.0.0.255 area 0
S3560(config-router)#network 192.168.3.0 0.0.0.255 area 0 S3560(config-router)#end S3560# %SYS-5-CONFIG_I: Configured from console by console S3560#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 C 192.168.3.0/24 is directly connected, Vlan20 S3560# 00:10:01: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.4.1 on Vlan20 from LOADING to FULL, Loading Done S3560#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 O 192.168.2.0/24 [110/783] via 192.168.3.2, 00:00:00, Vlan20 C 192.168.3.0/24 is directly connected, Vlan20 O 192.168.4.0/24 [110/782] via 192.168.3.2, 00:01:40, Vlan20 S3560#

R1:

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R1
R1(config)#interface fa0/0
R1(config-if)#no shutdown 

R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R1(config-if)#ip address 192.168.3.2 255.255.255.0
R1(config-if)#exit
R1(config)#interface serial 2/0
R1(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Serial2/0, changed state to down
R1(config-if)#clock rate 64000
R1(config-if)#ip address 192.168.4.1 255.255.255.0
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#network 192.168.3.0 0.0.0.255 area 0
R1(config-router)#network 192.168.4.0 0.0.0.255 area 0
R1(config-router)#
00:09:57: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.3.1 on FastEthernet0/0 from LOADING to FULL, Loading Done

R1(config-router)#end

%SYS-5-CONFIG_I: Configured from console by console
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

O    192.168.1.0/24 [110/2] via 192.168.3.1, 00:00:09, FastEthernet0/0
C    192.168.3.0/24 is directly connected, FastEthernet0/0
R1#
%LINK-5-CHANGED: Interface Serial2/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up

00:12:53: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.4.2 on Serial2/0 from LOADING to FULL, Loading Done

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

O    192.168.1.0/24 [110/2] via 192.168.3.1, 00:02:58, FastEthernet0/0
O    192.168.2.0/24 [110/782] via 192.168.4.2, 00:00:02, Serial2/0
C    192.168.3.0/24 is directly connected, FastEthernet0/0
C    192.168.4.0/24 is directly connected, Serial2/0
R1#

R2:

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname R2
R2(config)#interface fa0/0
R2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R2(config-if)#ip address 192.168.2.1 255.255.255.0
R2(config-if)#exit
R2(config)#interface serial 2/0
R2(config-if)#no shutdown 

%LINK-5-CHANGED: Interface Serial2/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
R2(config-if)#ip address 192.168.4.2 255.255.255.0 R2(config-if)#exit R2(config)#router ospf 1 R2(config-router)#network 192.168.2.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 %SYS-5-CONFIG_I: Configured from console by console 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 C 192.168.2.0/24 is directly connected, FastEthernet0/0 C 192.168.4.0/24 is directly connected, Serial2/0 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 O 192.168.1.0/24 [110/783] via 192.168.4.1, 00:00:01, Serial2/0 C 192.168.2.0/24 is directly connected, FastEthernet0/0 O 192.168.3.0/24 [110/782] via 192.168.4.1, 00:00:01, Serial2/0 C 192.168.4.0/24 is directly connected, Serial2/0 R2#

五、測試

Packet Tracer PC Command Line 1.0
PC>ipconfig

IP Address......................: 192.168.1.2
Subnet Mask.....................: 255.255.255.0
Default Gateway.................: 192.168.1.1

PC>ping 192.168.2.2

Pinging 192.168.2.2 with 32 bytes of data:

Reply from 192.168.2.2: bytes=32 time=11ms TTL=125
Reply from 192.168.2.2: bytes=32 time=15ms TTL=125
Reply from 192.168.2.2: bytes=32 time=14ms TTL=125
Reply from 192.168.2.2: bytes=32 time=14ms TTL=125

Ping statistics for 192.168.2.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 11ms, Maximum = 15ms, Average = 13ms

PC>


免責聲明!

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



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