OSPF 基本配置

网友投稿 239 2022-10-28


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


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:springboot项目不加端口号也可以访问项目的方法步骤分析
下一篇:16-11-14
相关文章

 发表评论

暂时没有评论,来抢沙发吧~