ospf简介: 开放式最短路径优先协议ospf是一个内部网关协议,它总坐在一个自制系统中,用于自制系统内部的路由选择信息交换.协议号89. ospf协议特点: 1:可使用大规模网络,没有跳数限制. 2:路由收敛速度块. 3:无路由环路产生. 4:支持变长子网掩码VLSM. 5:采用组播地址发送协议报文,节省了链路资源. 6:基于路由器的每个端口的代价来决定最有路径的.cost=100/链路带宽. 7:支持区域划分,简便了在大规模网络中的管理. 8:支持等代价负载均衡. 9:支持验证. ospf的报文类型: 1:HELLO报文:用来发现及维持邻居关系 2:数据库描述报文(DBD):用来描述本地路由器LSDB的情况. 3:链路状态请求报文(LSR):用来请求本地路由器没有的LSA. 4:链路状态更新报文(LSU):用来发送对端路由器的请求的LSA. 5:链路状态确认报文(LSAck):当路由器收到LSU后,发送LSAck进行确认. ospf的三张表格: 1:邻居表:通过hello包来建立邻居关系. 2:链路状态数据库(LSDB):ospf通过LSA学习到其他路由器和信息,存储在 LSDB中。 3:路由表:通过SPF算法,根据LSDB算出路由表. ospf的网络类型: 1:广播网络:需要进行DR和BDR的选举。选举主要比较路由器的优先级和router-id,优先考虑优先级,优先级高的DR,其次为BDR。网络中的路由器只需要与DR和BDR建 立邻居关系,新加入的路由器只需要与DR进行数据同步即可,不需要与网络中的其他路由器同步,节省了网路资源。非DR/BDR路由器通过组播地址224.0.0.6将 链路信息发给DR/BDR,然后DR/BDR通过224.0.0.5将链路信息发送给非DR/BDR。hello包的发送间隔是10秒,宕机时间40秒 2:无广播多路访问(NBMA):在帧中继、ATM和X.25这样的网络中不支持广播,ospf在这些网络当中也要选举出DR/BDR。hello包的发送间隔时间是30秒,宕机时间间隔是 120秒 3:点到点:点到点网络一般采用ppp或者hdlc来进行数据的封装。ospf的hello包的发送间隔10秒,宕机间隔40秒 4:点到多点:不需要DR和BDR的选举,邻居是自动发现的,默认的hello间隔是30秒,宕机间隔120秒 ospf的路由器类型: 1:内部路由器:不与区域外部的路由器相连,只维护本区域内的链路状态信息 2:区域边界路由器(ABR):连接不同区域的路由器,需要维护多个区域的链路状态信息。 3:骨干路由器:处于骨干区域(area 0)的路由器,只需要维护骨干区域的链路状态信息 4:自治系统边界路由器(ASBR):连接不同自治系统的路由器,通常需要在ASBR上运行多种协议。 ospf区域: 1:骨干区域(area 0):一个自治系统只能有一个骨干区域,且每一个非骨干局域都需要和骨干区域相连。骨干区域起到了数据中转的作用,在此区域的路由器运行速度快、稳 定、路由器较少。 2:标准区域:骨干区域以外的区域称为标准区域,每一个标准区域都要和骨干区域相连。如果没有直接相连则需要在与骨干区域相连的区域上配置虚链路,配置命令 Router(config-router)#area area-id virtual-link router-id 3:末节区域:为了减少路由条目,末节区域只接受域间路由和默认路由。配置命令:(在所有末节区域的路由器上都要配置此命令) Router(config-router)#area area-id stub 4:完全末节区域:为了减少路由条目,完全末节区域只接受默认路由,通过默认路由向外转发数据。配置命令 Router(config-router)#area area-id stub no-summary 单区域配置实例: 1:在单区域实现网络的互通 2:拓扑方案: 配置: R1: R1#conf t
R1(config)#int s0/0
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int loop 0
R1(config-if)#ip add 192.168.1.1 255.255.0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router ospf 100
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0 (通告ospf网络)
R1(config-router)#network 192.168.2.0 0.0.0.255 area 0 (通告ospf网络)
显示路由表信息 R2: R2#conf t
R2(config)#int ser 0/0
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int loop 0
R2(config-if)#ip add 192.168.3.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#router ospf 200
R2(config-router)#network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0 显示路由表信息 多区域配置实例: 1:配置ospf多区域。配置多区域时,各个标准区域必须与骨干区域相连 2:拓扑方案: 3:配置 R1: R1#conf t
R1(config)#int loop 0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no shut
R1(config)#int s0/0
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#no shut
R1(config)#router ospf 100
R1(config-router)#network 192.168.1.0 0.0.0.25
R1(config-router)#network 192.168.1.0 0.0.0.255 area 1 (通告ospf网络,区域1)
R1(config-router)#network 192.168.2.0 0.0.0.255 area 1 (通告ospf网络,区域1) 显示路由表信息 R2: R2#conf t
R2(config)#int ser 0/0
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2(config-if)#no shut
R2(config)#int ser 0/1
R2(config-if)#ip add 192.168.3.1 255.255.255.0
R2(config-if)#no shut
R2(config)#router ospf 200
R2(config-router)#network 192.168.2.0 0.0.0.255 area 1 (通告ospf网络,网络所在区域1)
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0 (通告ospf网络,网络所在区域0) 显示路由表信息: R3: R3#conf t
R3(config)#int ser 0/0
R3(config-if)#ip add 192.168.3.2 255.255.255.0
R3(config-if)#no shut
R3(config)#int ser 0/1
R3(config-if)#ip add 192.168.4.1 255.255.255.0
R3(config-if)#no shut
R3(config)#router ospf 300
R3(config-router)#network 192.168.3.0 0.0.0.255 area 0 (通告ospf网络,网络所在区域0)
R3(config-router)#network 192.168.4.0 0.0.0.255 area 2 (通告ospf网络,网络所在区域2)
显示路由表信息
R4: R4#conf t
R4(config)#int ser 0/0
R4(config-if)#ip add 192.168.4.2 255.255.255.0
R4(config-if)#no shut
R4(config)#int loop 0
R4(config-if)#ip add 192.168.5.1 255.255.255.0
R4(config-if)#no shut
R4(config)#router ospf 400
R4(config-router)#network 192.168.4.0 0.0.0.255 area 2 (通告ospf网络,网络所在区域2)
R4(config-router)#network 192.168.5.0 0.0.0.255 area 2 (通告ospf网络,网络所在区域2) 显示路由表信息 多区域路由引入(末节网络、完全末节网络)实例: 1:配置ospf多区域,并且实现ASBR上的路由引入,以及在末节网络和完全末节网络上减小路由表项 2:拓扑方案: 3:配置 R1 R1#conf t R1(config)#int loo 0 R1(config-if)#ip add 192.168.1.1 255.255.255.0 R1(config-if)#no shut R1(config)#int ser 0/0 R1(config-if)#ip add 192.168.2.1 255.255.255.0 R1(config-if)#no shut R1(config)#router ospf 100 R1(config-router)#network 192.168.1.0 0.0.0.255 area 1 (通告ospf网路,区域1) R1(config-router)#network 192.168.2.0 0.0.0.255 area 1 (通告ospf网络,区域1) 显示路由表信息: R2 R2#conf t R2(config)#int se 0/0 R2(config-if)#ip add 192.168.2.2 255.255.255.0 R2(config-if)#no shut R2(config)#int ser 0/1 R2(config-if)#ip add 192.168.3.1 255.255.255.0 R2(config-if)#no shut R2(config)#int e1/0 R2(config-if)#ip add 192.168.6.1 255.255.255.0 R2(config-if)#no shut R2(config)#router ospf 200 R2(config-router)#network 192.168.2.0 0.0.0.255 area 1 (通告ospf网络,区域1) R2(config-router)#network 192.168.3.0 0.0.0.255 area 0 (通告ospf网络,区域0) R2(config)#router ospf 200 R2(config-router)#redistribute rip (向ospf中引入rip协议) R2(config)#router rip R2(config-router)#network 192.168.6.0 R2(config-router)#redistribute ospf 200 metric 1000 200 255 1 1500 (向rip中引入ospf协议) 显示路由表信息 R3 R3#conf t R3(config)#int ser 0/0 R3(config-if)#ip add 192.168.3.2 255.255.255.0 R3(config-if)#no shut R3(config)#int ser 0/1 R3(config-if)#ip add 192.168.4.1 255.255.255.0 R3(config-if)#no shut R3(config)#router ospf 300 R3(config-router)#network 192.168.3.0 0.0.0.255 area 0 R3(config-router)#network 192.168.4.0 0.0.0.255 area 2 R3(config)#router ospf 300 R3(config-router)#area 2 stub (配置末节区域,在R4中观察路由表信息) R3(config)#router ospf 300 R3(config-router)#area 2 stub no-summary (配置完全末节区域,在R4中观察路由表信息) 显示路由表信息 R4 R4#conf t R4(config)#int ser 0/0 R4(config-if)#ip add 192.168.4.2 255.255.255.0 R4(config-if)#no shut R4(config)#int loo 0 R4(config-if)#ip add 192.168.5.1 255.255.255.0 R4(config-if)#no shut R4(config)#router ospf 400 R4(config-router)#network 192.168.4.0 0.0.0.255 area 2 R4(config-router)#network 192.168.5.0 0.0.0.255 area 2 R4(config)#router ospf 400 R4(config-router)#area 2 stub (配置末节区域,在R4中观察路由表信息) 路由引入后显示路由表信息 配置成末节区域后,路由表信息 配置成完全末节区域后显示路由表信息 R5 R5(config)#int e 1/0 R5(config-if)#ip add 192.168.6.2 255.255.255.0 R5(config-if)#no shut R5(config)#int se 0/0 R5(config-if)#ip add 192.168.7.1 255.255.255.0 R5(config-if)#no shut R5(config)#router rip R5(config-router)#network 192.168.6.0 R5(config-router)#network 192.168.7.0 显示路由表信息 R6 R6(config)#int ser 0/0 R6(config-if)#ip add 192.168.7.2 255.255.255.0 R6(config-if)#no shut R6(config)#int loo 0 R6(config-if)#ip add 192.168.8.1 255.255.255.0 R6(config-if)#no shut R6(config)#router rip R6(config-router)#network 192.168.7.0 R6(config-router)#network 192.168.8.0 显示路由表信息
该贴已经同步到 qingmosk的微博 |