ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

5个超经典实验,老杨带你高效进阶OSPF

2021-11-10 12:03:01  阅读:159  来源: 互联网

标签:FR 进阶 R2 config ip router OSPF 杨带 R1


今天咱们来继续讲讲OSPF。

其实,关于OSPF,我讲的很多了,老粉应该看过不少。

OSPF是一种基于链路状态的路由协议,也是专为 IP 开发的路由协议,直接运行在 IP 层上面。它从设计上保证了无路由环路。除此之外,IS-IS也是很常见的链路状态协议。

OSPF路由协议的应用面非常广,认可度也很高,毕竟的确是好用的。所以,在网络部署IGP协议的时候,很多网工都会优先考虑用OSPF组网。

之前写过不少文章都是关于它,但今天想讲讲实操,让你更好理解。配合五个实验,手把手带你系统理解OSPF的各方面配置。

01 点到点型网络配置单区域ospf和MD5认证

R1配置:

R1#conf t

R1(config)#hostname R1

R1(config)#int lo0

R1(config-if)#ip add 1.1.1.1255.255.255.0

R1(config-if)#ex

R1(config)#int s1/0

R1(config-if)#ip add 192.168.12.1255.255.255.0

R1(config-if)#clock rate 64000 //串口连接配置时钟频率64000

R1(config-if)#ip ospf authenticationmessage-digest//激活接口下的OSPF认证,

R1(config-if)#ip ospfmessage-digest-key 1 md5 kkfloat//设置MD5认证的密码为kkfloat

R1(config-if)#no sh

R1(config-if)#ex

R1(config)#router ospf 1

R1(config-router)#network192.168.12.0 255.255.255.0 area 1

R1(config-router)#network 1.1.1.0255.255.255.0 area 1

R1(config-router)#area 1authentication message-digest//开启区域0认证,所有处于区域0的接口都需要配置同样的认证

R1(config-router)#ex

R2配置:

R2#conf t

R2(config)#int lo0

R2(config-if)#ip add 2.2.2.2255.255.255.0

R2(config-if)#ex

R2(config)#int s1/0

R2(config-if)#ip add 192.168.12.2255.255.255.0

R2(config-if)#clock rate 64000

R2(config-if)#ip ospf authenticationmessage-digest

R2(config-if)#ip ospfmessage-digest-key 1 md5 kkfloat

R2(config-if)#ex

R2(config)#int s1/1

R2(config-if)#ip add 192.168.23.2255.255.255.0

R2(config-if)#clock rate 64000

R2(config-if)#ip ospf authenticationmessage-digest

R2(config-if)#ip ospfmessage-digest-key 1 md5 kkfloat

R2(config-if)#ex

R2(config)#router ospf 1

R2(config-router)#net 2.2.2.0255.255.255.0 area 1

R2(config-router)#net 192.168.12.0255.255.255.0 area 1

R2(config-router)#network192.168.23.0 255.255.255.0 area 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#area 1authentication message-digest

R3配置:

R3#conf t

Enter configuration commands, oneper line. End with CNTL/Z.

R3(config)#int lo0

R3(config-if)#ip add 3.3.3.3255.255.255.0

R3(config-if)#no sh

R3(config-if)#ex

R3(config)#int s1/0

R3(config-if)#ip add 192.168.23.1255.255.255.0

R3(config-if)#clo

R3(config-if)#clock R

R3(config-if)#clock Rate 64000

R3(config-if)#ip ospf authenticationmessage-digest

R3(config-if)#ip ospfmessage-digest-key 1 md5 kkfloat

R3(config-if)#ex

R3(config)#router ospf 1

R3(config-router)#net 3.3.3.0255.255.255.0 area 1

R3(config-router)#net 192.168.23.0255.255.255.0 area 1

R3(config-router)#roouter-id 3.3.3.3

R3(config-router)#area 1authentication message-digest

检查各个路由器ospf学习到的路由信息,ospf的邻居信息,ospf的数据库。测试全网互通性。

Show ip route ospf

Show ip ospf nei

Show ip ospf database

debug ip ospfevents

总结该模式的特点:

  • 通过点到点子接口的部分全互连逻辑拓扑或星型拓扑

  • 不需要手工配置邻居

  • 不选举DR/BDR

  • 各个子接口属于不同的子网

02 广播型网络配置单区域OSPF

R4配置:

R4#conf t

R4(config)#int lo0

R4(config-if)#ip add

R4(config-if)#ip add4.4.4.4 255.255.255.0

R4(config-if)#int e0/0

R4(config-if)#ip add192.168.1.4 255.255.255.0

R4(config-if)#no sh

R4(config-if)#ex

R4(config)#router ospf 1

R4(config-router)#network4.4.4.0 255.255.255.0 a 1

R4(config-router)#network192.168.1.0 255.255.255.0 a 1

R4(config-router)#router-id4.4.4.4

R5配置:

R5#conf t

R5(config)#int lo0

R5(config-if)#ip add5.5.5.5 255.255.255.0

R5(config-if)#ex

R5(config)#int e0/0

R5(config-if)#ip add192.168.1.5 255.255.255.0

R5(config-if)#no sh

R5(config-if)#ex

R5(config)#router ospf 1

R5(config-router)#net5.5.5.0 255.255.255.0 area 1

R5(config-router)#net192.168.1.0 255.255.255.0 a 1

R5(config-router)#router-id5.5.5.5

R5(config-router)#

R6配置:

R6#conf t

R6(config)#int lo0

R6(config-if)#ip add6.6.6.6 255.255.255.0

R6(config-if)#ex

R6(config)#int e0/0

R6(config-if)#ip add192.168.1.6 255.255.255.0

R6(config-if)#no sh

R6(config-if)#ex

R6(config)#router os

R6(config)#router ospf 1

R6(config-router)#net6.6.6.0 255.255.255.0 a 1

R6(config-router)#net192.168.1.0 255.255.255.0 a 1

R6(config-router)#router-id6.6.6.6

R7配置:

R7#conf t

R7(config)#int lo0

R7(config-if)#ip add

R7(config-if)#ip add7.7.7.7 255.255.255.0

R7(config-if)#ex

R7(config)#int e0/0

R7(config-if)#ip add192.168.1.7 255.255.255.0

R7(config-if)#no sh

R7(config-if)#ex

R7(config)#router ospf 1

R7(config-router)#net7.7.7.0 255.255.255.0 a

R7(config-router)#net7.7.7.0 255.255.255.0 area 1

R7(config-router)#net192.168.1.0 255.255.255.0 a 1

在这个时间间隔内,路由器相互监听hello包中的dr和bdr字段,并且服从优先级原则,这个时间间隔与dead interval时间相同都是40S。

因为刚开机时是一台路由器接下一台这样配置的,所以最先启动的路由器就认为自己是DR了。

而且OSPF没有DR,BDR的抢占机制,也就是说我们配置完成后,必须重启所有路由器或者重启所有路由器的ospf路由器协议

Show ip route ospf

Show ip ospf nei

Show ip ospf database

debug ip ospf events

此时我们还可以通过更改端口优先级,来更改谁是DR和BDR,甚至不参与DR与BDR选举。

03 NBMA配置单区域OSPF

实验以帧中继网络中的NBMA(非广播多路访问网络)为例,NBMA用于精确模型X.25和帧中继环境,这些模型不具备内部广播和多点传送能力。

帧中继是一种高性能的WAN协议,它运行在OSI参考模型的物理层和数据链路层。它是一种数据包交换技术,是X.25的简化版本。

它省略了X.25的一些强健功能,如提供窗口技术和数据重发技术,而是依靠高层协议提供纠错功能。

这是因为帧中继工作在更好的WAN设备上,这些设备较之X.25的WAN设备具有更可靠的连接服务和更高的可靠性,它严格地对应于OSI参考模型的最低二层,而X.25还提供第三层的服务。

所以,帧中继比X.25具有更高的性能和更有效的传输效率。

在此注意,OSPF运行在物理接口上,默认的运行模式即NBMA模式,因此不需要明确使用Ip OSPF network non-broadcast。

FR配置:

FR#conf t

FR(config)#frame-relayswitching//开启帧中继交换功能

FR(config)#int s0/1

FR(config-if)#encapsulationframe-relay ietf//配置接口帧中继封装模式

FR(config-if)#frame-relaylmi-type ansi//配置LMI类型

FR(config-if)#frame intf-typedce //帧中继接口缺省接口类型为 DTE ,DCE类型只有在设备用作帧中继交换或者模拟帧中继局方设备时才使用的

FR(config-if)#clock rate64000 //设置时钟频率,串口同步时间

FR(config-if)#frame-relayroute 102 interface s0/2 201//配置本地端口DLIC值及虚链路对应出口和对端DLIC

FR(config-if)#frame-relayroute 103 interface s0/3 301

FR(config-if)#no sh

FR(config-if)#exit

FR(config)#int s0/2

FR(config-if)#encapsulationframe-relay ietf

FR(config-if)#frame-relaylmi-type ansi

FR(config-if)#frameintf-type dce

FR(config-if)#clock rate64000

FR(config-if)#frame-relayroute 201 int s0/1 102

FR(config-if)#frame-relayroute 203 int s0/3 302

FR(config-if)#no sh

FR(config-if)#exit

FR(config)#int s0/3

FR(config-if)#encapsulationframe-relay ietf

FR(config-if)#frame-relaylmi-type ansi

FR(config-if)#frameintf-type dce

FR(config-if)#clock rate64000

FR(config-if)#frame-relayroute 301 int s0/1 103

FR(config-if)#frame-relayroute 302 int s0/2 203

FR(config-if)#no sh

FR(config-if)#exit

配置R1:

R1#conf t

R1(config)#int lo0

R1(config-if)#ip add 1.1.1.1255.255.255.0

R1(co2nfig-if)#int s0/1

R1(config-if)#encapsulationframe-relay itef

R1(config-if)#frame-relaylmi-type ansi

R1(config-if)#ip add192.168.0.1 255.255.255.0

R1(config-if)#no frame-relayinverse-arp //关闭动态反向ARP映射

R1(config-if)#frame-relaymap ip 192.168.0.2 102 //手动添加对端IP与本地DLIC映射

R1(config-if)#frame-relaymap ip 192.168.0.3 103

R1(config-if)#no sh

R1(config-if)#exit

配置R2:

R2#conf t

R2(config)#int lo0

R2(config-if)#ip add 2.2.2.2255.255.255.0

R2(config-if)#int s0/2

R2(config-if)#encapsulationframe-relay itef //设置帧中继封装类型

R2(config-if)#frame-relaylmi-type ansi //设置帧中继LMI类型

R2(config-if)#ip add192.168.0.2 255.255.255.0

R2(config-if)#no frame-relayinverse-arp//关闭动态反向ARP映射

R2(config-if)#frame-relaymap ip 192.168.0.1 201//手动添加对端IP与本地DLIC映射

R2(config-if)#frame-relaymap ip 192.168.0.3 203

R2(config-if)#no sh

R2(config-if)#exit

R3配置:

R3#conf t

R3(config)#int lo0

R3(config-if)#ip add 3.3.3.3255.255.255.0

R3(config-if)#int s0/3

R3(config-if)#encapsulationframe-relay itef //设置帧中继封装类型

R3(config-if)#frame-relaylmi-type ansi //设置帧中继LMI类型

R3(config-if)#ip add192.168.0.3 255.255.255.0

R3(config-if)#no frame-relayinverse-arp//关闭动态反向ARP映射

R3(config-if)#frame-relaymap ip 192.168.0.1 301//手动添加对端IP与本地DLIC映射

R3(config-if)#frame-relaymap ip 192.168.0.2 302

R3(config-if)#no sh

R3(config-if)#exit

查看各个路由器帧中继网络的映射,此时各个路由外部接口应该是互通的。但是却不能ping通内部的地址。

此时,我们使用平时的方法配置opsf动态路由协议,看看情况如何:

R1(config)#router ospf 1

R1(config-router)#net1.1.1.0 255.255.255.0 area 1

R1(config-router)#router-id1.1.1.1

R1(config-router)#net192.168.0.0 255.255.255.0 area 1

R2(config)#router ospf 1

R2(config-router)#net2.2.2.0 255.255.255.0 a 1

R2(config-router)#net192.168.0.0 255.255.255.0 a 1

R2(config-router)#router-id2.2.2.2

R3(config)#router ospf 1

R3(config-router)#net3.3.3.0 255.255.255.0 a 1

R3(config-router)#net192.168.0.0 255.255.255.0 a 1

R3(config-router)#router-id3.3.3.3

完成配置后查看R1、R2、R3的路由表你会发现根本没有OSPF学习到的路由也没有邻居

sh ip route ospf

sh ip ospf neighbor

debug ip ospf events

原因是由于NBMA网络中允许存在多台Router,物理上链路共享,通过二层虚链路(VC)建立逻辑上的连接,此时网络不是没有广播的能力,而是广播针对每一条VC发送,这样就使得一台路由器在不是Full-Mesh的NBMA拓扑中,发送的广播或组播分组可能无法到达其他所有路由器,而OSPF路由协议是依靠组播去发现邻居和传送LSA包的。

所以,OSPF正常就要手动指定邻居:

R1(config)#router ospf 1

R1(config-router)#nei 192.168.0.2

R1(config-router)#nei 192.168.0.3

R1(config-router)#exit

R1(config)#exit

R1#clear ip ospf process

R2(config)#router ospf 1

R2(config-router)#nei 192.168.0.1

R2(config-router)#nei 192.168.0.3

R2(config-router)#exit

R2(config)#exit

R2#clear ip ospf process

R3(config)#router ospf 1

R3(config-router)#nei 192.168.0.1

R3(config-router)#nei 192.168.0.2

R3(config-router)#exit

R3(config)#exit

R3#clear ip ospf process

此时我们再查看R1,R2,R3路由表,和ospf邻居关系表和数据库,就正常了

sh ip route ospf

sh ip ospf neighbor

sh ip ospf database

debug ip ospf events

如此同时我们也发现,此NBMA网络选举了R3作为DR,R2作为BDR,R1作为DROTHER.路由器间使用单播地址而不是使用组播建立邻居关系和交换路由信息。

标签:FR,进阶,R2,config,ip,router,OSPF,杨带,R1
来源: https://blog.csdn.net/SPOTO2021/article/details/121245413

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有