OSPF基础(ip网络基础实验07)

实验拓扑图
gns3文件资源已上传,欢迎下载交流学习!
(点击下方目录可直接跳转!)

一、前言

1.OSPF是链路状态路由协议,具有下面的优点:

  • 适应大规模网络
  • 支持区域划分
  • 更快的收敛速度
  • 组播报文发送
  • 支持VLSM和CIDR
  • 路由分级管理
  • 无路由自环

2.Router ID

32bit的无符号整数,一台路由器的唯一标识,在整个自治系统内唯一。

3.协议号

OSPF 是一种链接-状态路由协议,依靠协议号是89的IP报文来承载。

4.OSPF域的分层

在这里插入图片描述

5.概念图

在这里插入图片描述

二、实验步骤

1.规划IP地址,为3台PC机配置IP地址及网关

PC1> ip 192.168.1.2/24 192.168.1.1
Checking for duplicate address...
PC1 : 192.168.1.2 255.255.255.0 gateway 192.168.1.1

PC1> save
Saving startup configuration to startup.vpc
.  done

save命令用于保存配置

PC1 配置命令如上,PC2,PC3同理配置好后,用show命令查询可得:

PC2> show

NAME   IP/MASK              GATEWAY           MAC                LPORT  RHOST:PORT
PC2    192.168.2.2/24       192.168.2.1       00:50:79:66:68:01  10032  127.0.0.1:10033
       fe80::250:79ff:fe66:6801/64
PC3> show

NAME   IP/MASK              GATEWAY           MAC                LPORT  RHOST:PORT
PC3    192.168.3.2/24       192.168.3.1       00:50:79:66:68:02  10034  127.0.0.1:10035
       fe80::250:79ff:fe66:6802/64

2.配置R2

R2#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int loopback1(创建虚拟接口loopback1,并为其配置IP地址)
R2(config-if)#ip addr 10.1.1.2 255.255.255.0
R2(config-if)#exit
R2(config)#router ospf 10(这个进程数可以是十进制的任意数)
R2(config-router)#router-id 10.1.1.2
R2(config-router)#network 192.168.1.0 0.0.0.255 area 1(网段192.168.1.0在area 1中)
R2(config-router)#network 192.168.4.0 0.0.0.255 area 1(网段192.168.4.0在area 1中)
R2(config-router)#exit
R2(config)#int f0/0(为接口f0/0配置IP地址)
R2(config-if)#ip addr 192.168.1.1 255.255.255.0
R2(config-if)#no shut(打开接口)
R2(config-if)#exit
R2(config)#int f1/0(为接口f1/0配置IP地址)
R2(config-if)#ip addr 192.168.4.1 255.255.255.0
R2(config-if)#no shut(打开接口)
R2(config-if)#exit

R2配置完成,用show命令查看接口状态:

R2#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.1     YES manual up                    up  
FastEthernet1/0            192.168.4.1     YES manual up                    up  
FastEthernet1/1            unassigned      YES unset  administratively down down
Loopback1                  10.1.1.2        YES manual up                    up  

3.配置R1

R1,R2,R3,R4的配置方法本质上没有差别,展示如下:
(area 0表示骨干网)

R1#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int loopback1(创建虚拟接口loopback1,并为其配置IP地址)
R1(config-if)#ip addr 10.1.2.2 255.255.255.0
R1(config-if)#exit
R1(config)#router ospf 10(这个进程数可以是十进制的任意数)
R1(config-router)#router-id 10.1.2.2
R1(config-router)#network 192.168.4.0 0.0.0.255 area 1(网段192.168.4.0在area 1中)
R1(config-router)#network 192.168.2.0 0.0.0.255 area 0(网段192.168.2.0在area 0中)
R1(config-router)#network 192.168.5.0 0.0.0.255 area 0(网段192.168.5.0在area 0中)
R1(config-router)#exit
R1(config)#int f1/0(为接口f1/0配置IP地址)
R1(config-if)#ip addr 192.168.4.2 255.255.255.0
R1(config-if)#no shut(打开接口)
R1(config-if)#exit
R1(config)#int f0/0(为接口f0/0配置IP地址)
R1(config-if)#ip addr 192.168.2.1 255.255.255.0
R1(config-if)#no shut(打开接口)
R1(config-if)#exit
R1(config)#int f1/1(为接口f1/1配置IP地址)
R1(config-if)#ip addr 192.168.5.1 255.255.255.0
R1(config-if)#no shut(打开接口)
R1(config-if)#exit

R1配置完成,用show命令查看接口状态:

R1#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.2.1     YES manual up                    up  
FastEthernet1/0            192.168.4.2     YES manual up                    up  
FastEthernet1/1            192.168.5.1     YES manual up                    up  
Loopback1                  10.1.2.2        YES manual up                    up  

4.配置R3

R3#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int loopback1(创建虚拟接口loopback1,并为其配置IP地址)
R3(config-if)#ip addr 10.1.3.2 255.255.255.0
R3(config-if)#exit
R3(config)#router ospf 10(这个进程数可以是十进制的任意数)
R3(config-router)#router-id 10.1.3.2
R3(config-router)#network 192.168.5.0 0.0.0.255 area 0(网段192.168.5.0在area 0中)
R3(config-router)#network 192.168.6.0 0.0.0.255 area 2(网段192.168.6.0在area 2中)
R3(config-router)#exit
R3(config)#int f1/1(为接口f1/1配置IP地址)
R3(config-if)#ip addr 192.168.5.2 255.255.255.0
R3(config-if)#no shut(打开接口)
R3(config-if)#exit
R3(config)#int f1/0(为接口f1/0配置IP地址)
R3(config-if)#ip addr 192.168.6.1 255.255.255.0
R3(config-if)#no shut(打开接口)
R3(config-if)#exit

R3配置完成,用show命令查看接口状态:

R3#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down
FastEthernet1/0            192.168.6.1     YES manual up                    up  
FastEthernet1/1            192.168.5.2     YES manual up                    up  
Loopback1                  10.1.3.2        YES manual up                    up  

5.配置R4

R3#config t
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#int loopback1(创建虚拟接口loopback1,并为其配置IP地址)
R4(config-if)#ip addr 10.1.4.2 255.255.255.0
R4(config-if)#exit
R4(config)#router ospf 10(这个进程数可以是十进制的任意数)
R4(config-router)#router-id 10.1.4.2
R4(config-router)#network 192.168.6.0 0.0.0.255 area 2(网段192.168.6.0在area 2中)
R4(config-router)#network 192.168.3.0 0.0.0.255 area 2(网段192.168.3.0在area 2中)
R4(config-router)#exit
R4(config)#int f1/0(为接口f1/0配置IP地址)
R4(config-if)#ip addr 192.168.6.2 255.255.255.0
R4(config-if)#no shut(打开接口)
R4(config-if)#exit
R4(config)#int f0/0(为接口f0/0配置IP地址)
R4(config-if)#ip addr 192.168.3.1 255.255.255.0
R4(config-if)#no shut(打开接口)
R4(config-if)#exit

R4配置完成,用show命令查看接口状态:

R4#show ip int bri
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.3.1     YES manual up                    up  
FastEthernet1/0            192.168.6.2     YES manual up                    up  
FastEthernet1/1            unassigned      YES unset  administratively down down
Loopback0                  10.1.4.2        YES manual up                    up 

三、实验结果

测试:PC1,PC2,PC3之间能否正常通信

互相ping主机的IP地址即可。
若ping通则证明通信正常。

四、思考与总结

一些OSPF的show命令的使用

show ip ospf neighbor /(查看OSPF邻居状态指令,FULL就是OK)
show ip ospf database /(查看OSPF链路状态数据库指令)
show ip ospf interface f0/0 /(查看指定接口的OSPF配置信息)

1.比较RIP和OSPF的异同和优劣

RIP 协议和 OSPF 协议是两种内部网关协议 (IGP),它们在计算机网络中大量使用,用于指定数据传输的最佳路由。
在这里插入图片描述

RIP 协议的优缺点:
++优点:
1.RIP 协议非常适合小型网络 - 易于理解和配置。
2.RIP 路由保证支持几乎所有的路由器。
3.RIP 不需要每次网络拓扑更改时都进行更新。
++缺点:
1.RIP 可能会造成流量瓶颈,因为它每 30 秒广播一次更新,由于 RIP 中的任何路由更新都会占用大量带宽,因此关键 IT 流程的资源是有限的。
RIP 的跳数限制为 15 跳,因此超出该距离的任何路由器都被视为无穷大,因此无法访问。
2.收敛速度很慢,当任何链接出现故障时,选择替代路线需要花费大量时间。
3.RIP 不支持同一路由上的多条路径,这可能会产生更多的路由环路,使用固定跳数度量来选择最佳路由时,根据实时数据比较路由时,RIP 无法工作,由于重复的过程,这会导致数据包丢失和网络操作过载。

OSPF协议的优缺点:
++优点:
1.OSPF 路由协议具有完整的网络拓扑知识,允许路由器根据传入的请求计算路由。
2.OSPF协议没有跳数限制,不像RIP协议最多只有15跳,所以 OSPF 的收敛速度比 RIP 快,并且具有更好的负载均衡。
3.OSPF 多播链路状态更新并仅在网络发生变化时发送更新。
++缺点:
1.OSPF 协议需要有关复杂网络的高级知识,因此不像其他一些协议那样容易学习。
2.当有更多路由器添加到网络时,OSPF 路由不会扩展。OSPF 协议缺乏可扩展性使其不适合跨 Internet 路由。
3.OSPF 协议维护路由信息的多个副本,增加了所需的内存量。

2.假如在实验中两台路由器的邻居状态始终进入不到2-way状态,请分析可能的原因。

原因1:在所有路由器上都配置了优先级0
如果一个以太网段中所有的路由器都配置了优先级0,那么这个网段上将无法进行DR、BDR的选择,因此也就会卡在2-way状态,无法进入下一个状态。

原因2:没有手动配置邻居关系
双方都互相收到对方的hello报文,此时接口接入2-way状态,也就是说双方建立了邻居关系。 OSPF进程状态启动会自动向多播地址发送Hello包,但是对于非广播-多路访问网络即NBMA型网络,由于不支持广播和多播,Hello包是单播地址送出的,所以必须手动配置邻居关系。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HAL9000pp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值