OSPF 基本配置

【實驗目的】

掌握在路由器上配置 OSPF 單區域。

【背景描述】

假設校園網通過 1 臺三層交換機連到校園網出口路由器,路由器再和校園外的另 1 臺

路由器連接,現做適當配置,實現校園網內部主機與校園網外部主機的相互通信。

本實驗以兩臺路由器、1 臺三層交換機爲例。S3550 上劃分有 VLAN10 和 VLAN50,

其中 VLAN10 用於連接 RA,VLAN50 用於連接校園網主機。

【需求分析】

需要在路由器和交換機上配置 OSPF 路 由協議,使全網互通,從而實現信息的共享和

傳遞。

【實驗設備】

三層交換機 1 臺

路由器 2 臺

交叉線或直連線 3 條

【預備知識】

路由器基本配置知識、OSPF

【實驗原理】

OSPF(Open Shortest Path First,開放式最短路徑優先)協議,是目前網絡中應用最

廣泛的路由協議之一。屬於內部網關路由協議,能夠適應各種規模的網絡環境,是典型的鏈

路狀態(link-state)協議。

OSPF 路由協議通過向全網擴散本設備的鏈路狀態信息,使網絡中每臺設備最終同步一

個具有全網鏈路狀態的數據庫(LSDB),然後路由器採用 SPF 算法,以自己爲根,計算到

達其他網絡的最短路徑,最終形成全網路由信息。

OSPF 屬於無類路由協議,支持 VLSM(變長子網掩碼)。OSPF 是以組播的形式進行

鏈路狀態的通告的。

在大模型的網絡環境中,OSPF 支持區域的劃分,將網絡進行合理規劃。劃分區域時必

須存在 area0(骨幹區域)。其他區域和骨幹區域直接相連,或通過虛鏈路的方式連接。

【實驗步驟】

第一步:在路由器和三層交換機配置 IP  地址

switch#configure terminal

switch(config)#hostname S3750

S3750(config)#vlan 10

S3750(config-vlan)#exit

S3750(config)#vlan 50

S3750(config-vlan)#exit

S3750(config)#interface f0/1

S3750(config-if)#switchport access vlan 10

S3750(config-if)#exit

S3750(config)#interface f0/2

S3750(config-if)#switchport access vlan 50

S3750(config-if)#exit

S3750(config)#interface vlan 10

S3750(config-if)#ip address 172.16.1.2 255.255.255.0

S3750(config-if)#no shutdown

S3750(config-if)#exit

S3750(config)#interface vlan 50

S3750(config-if)#ip address 172.16.5.1 255.255.255.0

S3750(config-if)#no shutdown

S3750(config-if)#exit

RouterA(config)# interface fastethernet 0/1

RouterA(config-if)# ip address 172.16.1.1 255.255.255.0

RouterA(config-if)# no shutdown

RouterA(config-if)#exit

RouterA(config)# interface fastethernet 0/0

RouterA(config-if)# ip address 172.16.2.1 255.255.255.0

RouterB(config-if)# no shutdown

RouterB(config)# interface fastethernet 0/1

RouterB(config-if)# ip address 172.16.3.1 255.255.255.0

RouterB(config-if)# no shutdown

RouterB(config-if)#exit

RouterB(config)# interface fastethernet 0/0

RouterB(config-if)# ip address 172.16.2.2 255.255.255.0

RouterB(config-if)# no shutdown

第二步:配置 OSPF  路由協議

S3750(config)#router ospf

S3750(config-router)#network 172.16.5.0 0.0.0.255 area 0

S3750(config-router)#network 172.16.1.0 0.0.0.255 area 0

S3750(config-router)#end

RouterA(config)# router ospf

RouterA(config-router)#network 172.16.1.0 0.0.0.255 area 0

RouterA(config-router)#network 172.16.2.0 0.0.0.255 area 0

RouterA(config-router)#end

RouterB(config)#router ospf

RouterB(config-router)#network 172.16.2.0 0.0.0.255 area 0

RouterB(config-router)#network 172.16.3.0 0.0.0.255 area 0

RouterB(config-router)#end

第三步:驗證測試

S3750#show vlan

VLAN Name Status Ports

---- -------------------------------- --------- -----------------------------------

1 VLAN0001 STATIC Fa0/3, Fa0/4, Fa0/5, Fa0/6

Fa0/7, Fa0/8, Fa0/9, Fa0/10

Fa0/11, Fa0/12, Fa0/13,

Fa0/14 Fa0/15, Fa0/16,

Fa0/17, Fa0/18, Fa0/22

Fa0/19, Fa0/20, Fa0/21,

Fa0/23, Fa0/24, Gi0/25,

Gi0/26 ,Gi0/27, Gi0/28

10 VLAN0010 STATIC Fa0/1

50 VLAN0050 STATIC Fa0/2

S3750#show ip interface brief

Interface IP-Address(Pri) OK? Status

VLAN 10 172.16.1.2/24 YES UP

VLAN 50 172.16.5.1/24 YES UP

RA#show ip interface brief

Interface IP-Address(Pri) OK? Status

FastEthernet 0/0 172.16.2.1/24 YES UP

FastEthernet 0/1 172.16.1.1/24 YES UP

RB#show ip interface brief

Interface IP-Address(Pri) OK? Status

FastEthernet 0/0 172.16.2.2/24 YES UP

FastEthernet 0/1 172.16.1.3/24 YES UP

Loopback 0 no address YES DOWN

S3750#show ip route

Codes: C - connected, S - static, R - RIP B - BGP

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

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default

Gateway of last resort is no set

C 172.16.1.0/24 is directly connected, VLAN 10

C 172.16.1.2/32 is local host.

O 172.16.2.0/24 [110/2] via 172.16.1.1, 00:14:09, VLAN 10

O 172.16.3.0/24 [110/3] via 172.16.1.1, 00:04:39, VLAN 10

C 172.16.5.0/24 is directly connected, VLAN 50

C 172.16.5.1/32 is local host.

RA#show ip route

Codes: C - connected, S - static, R - RIP B - BGP

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

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default

Gateway of last resort is no set

C 172.16.1.0/24 is directly connected, FastEthernet 0/1

C 172.16.1.1/32 is local host.

C 172.16.2.0/24 is directly connected, FastEthernet 0/0

C 172.16.2.1/32 is local host.

O 172.16.3.0/24 [110/2] via 172.16.2.2, 00:05:21, FastEthernet 0/0

O 172.16.5.0/24 [110/2] via 172.16.1.2, 00:14:51, FastEthernet 0/1

RB#show ip route

Codes: C - connected, S - static, R - RIP B - BGP

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

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default

Gateway of last resort is no set

O 172.16.1.0/24 [110/2] via 172.16.2.1, 00:05:58, FastEthernet 0/0

C 172.16.2.0/24 is directly connected, FastEthernet 0/0

C 172.16.2.2/32 is local host.

C 172.16.3.0/24 is directly connected, FastEthernet 0/1

C 172.16.3.1/32 is local host.

O 172.16.5.0/24 [110/3] via 172.16.2.1, 00:15:22, FastEthernet 0/0

RA#show ip ospf neighbor

OSPF process 1:

Neighbor ID Pri State Dead Time Address Interface

172.16.5.1 1 Full/DR 00:00:38 172.16.1.2 FastEthernet 0/1

172.16.2.2 1 Full/DR 00:00:36 172.16.2.2 FastEthernet 0/0

RA#show ip ospf interface fastEthernet 0/0

FastEthernet 0/0 is up, line protocol is up

Internet Address 172.16.2.1/24, Ifindex 1, Area 0.0.0.0, MTU 1500

Matching network config: 172.16.2.0/24

Process ID 1, Router ID 172.167.1.1, Network Type BROADCAST, Cost: 1

Transmit Delay is 1 sec, State BDR, Priority 1

Designated Router (ID) 172.16.2.2, Interface Address 172.16.2.2

Backup Designated Router (ID) 172.167.1.1, Interface Address 172.16.2.1

Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

Hello due in 00:00:05

Neighbor Count is 1, Adjacent neighbor count is 1

Crypt Sequence Number is 82589

Hello received 114 sent 115, DD received 4 sent 5

LS-Req received 1 sent 1, LS-Upd received 5 sent 9

LS-Ack received 6 sent 4, Discarded 0

【注意事項】

1、在申明直連網段時,注意要寫該網段的反掩碼。

2、在申明直連網段時,必須指明所屬的區域。

【參考配置】

S3750#show running-config

Building configuration...

Current configuration : 1399 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 19:51:54 CST 2007

-ubu6server)

hostname S3750

!

vlan 1

!

vlan 10

!

vlan 50

!

interface FastEthernet 0/1

switchport access vlan 10

!

interface FastEthernet 0/2

switchport access vlan 50

!

interface FastEthernet 0/3

!

interface FastEthernet 0/4

!

interface FastEthernet 0/5

!

interface FastEthernet 0/6

!

interface FastEthernet 0/7

!

interface FastEthernet 0/8

!

interface FastEthernet 0/9

!

interface FastEthernet 0/10

!

interface FastEthernet 0/11

!

interface FastEthernet 0/12

!

interface FastEthernet 0/13

!

interface FastEthernet 0/14

!

interface FastEthernet 0/15

!

interface FastEthernet 0/16

!

interface FastEthernet 0/17

!

interface FastEthernet 0/18

!

interface FastEthernet 0/19

!

interface FastEthernet 0/20

!

interface FastEthernet 0/21

!

interface FastEthernet 0/22

!

interface FastEthernet 0/23

!

interface FastEthernet 0/24

!

interface GigabitEthernet 0/25

!

interface GigabitEthernet 0/26

!

interface GigabitEthernet 0/27

!

interface GigabitEthernet 0/28

!

interface VLAN 10

ip address 172.16.1.2 255.255.255.0

!

interface VLAN 50

ip address 172.16.5.1 255.255.255.0

!

router ospf 1

network 172.16.1.0 0.0.0.255 area 0

network 172.16.5.0 0.0.0.255 area 0

!

line con 0

line vty 0 4

login

!

end

RB#show running-config

Building configuration...

Current configuration : 579 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 20:50:30 CST 2007

-ubu1server)

hostname RB

!

interface FastEthernet 0/0

ip address 172.16.2.2 255.255.255.0

duplex auto

speed auto

!

interface FastEthernet 0/1

ip address 172.16.3.1 255.255.255.0

duplex auto

speed auto

!

interface Loopback 0

!

router ospf 1

network 172.16.2.0 0.0.0.255 area 0

network 172.16.3.0 0.0.0.255 area 0

!

line con 0

line aux 0

line vty 0 4

login

!

end

RA#show running-config

Building configuration...

Current configuration : 554 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 20:50:30 CST 2007

-ubu1server)

hostname RA

!

interface FastEthernet 0/0

ip address 172.16.2.1 255.255.255.0

duplex auto

speed auto

!

interface FastEthernet 0/1

ip address 172.16.1.1 255.255.255.0

duplex auto

speed auto

!

router ospf 1

network 172.16.1.0 0.0.0.255 area 0

network 172.16.2.0 0.0.0.255 area 0

!

line con 0

line aux 0

line vty 0 4

login

!

end

wKioL1gqgv2gdpX0AAAOEgYbRck792.png-wh_50

wKioL1gqgv2AvxzdAAAOEgYbRck963.png-wh_50

wKiom1gqgv3j75K3AAAIiBYVf_g919.png-wh_50

wKiom1gqgv7ga_80AAAIiBYVf_g062.png-wh_50

wKioL1gqgv-wIA0ZAAAOfYjh2PQ143.png-wh_50

wKioL1gqgv-wkVHnAAAOfYjh2PQ561.png-wh_50

wKiom1gqgv_if_uxAAAbE4gYj7Y785.png-wh_50

wKioL1gqgv_Az8-WAAAbE4gYj7Y689.png-wh_50

wKiom1gqgwDyXMa4AAANpOrwelI825.png-wh_50

wKiom1gqgwDCZCbdAAANpOrwelI528.png-wh_50

wKioL1gqgwCieiyVAAAL8ihsZq4564.png-wh_50

wKioL1gqgwDgXBdRAAAL8ihsZq4139.png-wh_50

wKiom1gqgwGS0V7-AAAQ_0pgU2w927.png-wh_50

wKiom1gqgwGy8hy2AAAQ_0pgU2w797.png-wh_50

wKioL1gqgwHSIyhWAAAY8EPqWTM563.png-wh_50

wKioL1gqgwHglbIPAAAY8EPqWTM373.png-wh_50

wKiom1gqgwGwXkuWAAAOiFoo_ts833.png-wh_50

wKioL1gqgwKwqAkpAAAKxvuXDdg915.png-wh_50

wKiom1gqgwKxj9XdAAAKxvuXDdg137.png-wh_50

wKioL1gqgwKzJCTtAAAtwYwNr20370.png-wh_50

wKiom1gqgwLxysf4AAAtwYwNr20646.png-wh_50

wKiom1gqgwODEstOAAAgeLujJqo001.png-wh_50

wKioL1gqgwOzZOmdAAAgeLujJqo178.png-wh_50

wKioL1gqgwOR4O2vAAAag8Eq_9w070.png-wh_50

wKiom1gqgwPArHQgAAAfsGJiVLk960.png-wh_50


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章