CCNA--OSPFv2:开放最短路径优先
无类别链路状态路由协议 协议号 89
更新机制 触发更新 存在周期更新 30min 组播更新 更新的是链路状态
224.0.0.5 串行链路中
224.0.0.6 DR/BDR 在以太网环境中
更新内容 LSA
LSA 链路状态通告,路由器两边的IP地址
LSDB 链路状态数据库
OSPF有12类LSA,1,2,3,4,5,7.六类经常用。
支持等开销负载均衡,默认4条,最大6条,IOS版本12.4以后16条
Ospf的数据包
Hello 发现 维持 创建邻居关系
DBD:数据库摘要信息,基本信息
LSR:链路状态请求 通过该报文跟邻居索要LSA
LSU:链路状态更新 回应LSR 承载LSA
LSACK:确认 DBD LSR LSU
Router ID:路由器里边ospf的名字,用来标识路由器 (名字) 默认使用最大环回地址 若没有环回使用最大的物理接口地址 建议手动修改R-ID
Hello and dead intervals:hello时间10s,死亡时间40s
Neighbours:回复hello包
Area ID:区域号
Cost值计算方法=参考带宽/实际带宽
参考带宽默认100M 实际带宽是接口的实际带宽
OSPF出环概率很低
面试重点
*OSPF建邻过程
Down 开始发送hello但是没有收到邻居发来的hello 当收到对方发来hello 进入下一状态
Init 当收到对方发来的hello中有自己的Router-ID (Router-ID不能一至)进入下一状态
Two-way 邻居关系建立完成 进行选举 选举结束 进入下一状态 DR-other之间的稳定状态
Exstart 选举主从关系 master先发DBD Router-ID大的优先
Exchange 交换DBD
Loading 交换LSA 通过LSR去要LSA 对方通过LSU更新LSA
Full 邻接关系建立 启动SPF算法 计算路径 DR,BDR,DRother之间的是邻接关系
配置
R1(config)#router ospf 100 创建/进入OSPF进程100
R1(config-router)#router-id 1.1.1.1 指定Router-id
R1(config-router)#network 12.1.1.1 0.0.0.0 area 0 子网 反掩码 OSPF只支持精确宣告
反掩码中1表示不关注,0表示关注
宣告直连的作用:1.路由功能 2.**作用使该接口具备接受和发送ospf的能力,不宣告直连的话不能接受OSPF和更新 1、路由 2、** 3、区域
R3(config-router)#network 0.0.0.0 255.255.255.255 偷懒式宣告,表示宣告所有人试验中才能用。
Ospf的邻居表
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/ - 00:00:32 12.1.1.2 Serial1/1
Ospf的路由表
R1#show ip route ospf
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.1.1.2, 00:21:29, Serial1/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/129] via 12.1.1.2, 00:21:29, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/128] via 12.1.1.2, 00:21:29, Serial1/1
R2#show ip ospf route
OSPF Router with ID (2.2.2.2) (Process ID 100)
Area BACKBONE(0)
Intra-area Route List
* 12.1.1.0/24, Intra, cost 1, area 0, Connected
via 12.1.1.2, FastEthernet1/0
* 23.1.1.0/24, Intra, cost 1, area 0, Connected
via 23.1.1.2, FastEthernet1/1
*> 1.1.1.1/32, Intra, cost 2, area 0
via 12.1.1.1, FastEthernet1/0
* 2.2.2.2/32, Intra, cost 1, area 0, Connected
via 2.2.2.2, Loopback0
OSPF拓扑表/数据库表
R2#show ip ospf database
OSPF Router with ID (2.2.2.2) (Process ID 100)
Router Link States (Area 0)(一类SLA,连路两边的IP地址)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 90 0x80000005 0x00BF34 2
2.2.2.2 2.2.2.2 458 0x80000003 0x00BA04 3
Net Link States (Area 0) (二类LSA,
Link ID ADV Router Age Seq# Checksum
12.1.1.1 1.1.1.1 470 0x80000001 0x004AD0
区域划分的规则:
1、星型结构 其他区域要和骨干域相连
2、需要存在ABR 区域边界路由器
通告者 内容
1类LSA router 路由器本身 链路状态(链路两边的IP地址)
2类LSA network DR 描述MA网络(除了直连外的其他的连接地址)
3类LSA sumary ABR 路由条目(从哪个接口进那个接口出)
区域边界路由器
干涉选择方法:
比较router-id,router-id大的是DR,小的是BDR
1.修改DR优先级最大,BDR次大;该选举非抢占,故必须手动重启所有设备进程
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: y
优先级越大越优。
2、修改DR优先级最大,BDR次大;将其他路由器修改为0
R2(config)#int f0/0
R2(config-if)#ip ospf p
R2(config-if)#ip ospf priority 0
进接口,修改ospf优先级
扩展配置:
1、认证
明文认证:
R2(config)#int s1/0
R2(config-if)#ip ospf authentication
R2(config-if)#ip ospf authentication-key 1 cisco
密文认证:
R2(config)#int f0/0
R2(config-if)#ip ospf authentication message-digest
R2(config-if)#ip ospf message-digest-key 1 md5 cisco
区域明文认证:
R3(config)#router ospf 100
R3(config-router)#area 0 authentication
区域密文认证:
R1(config)#router ospf 100
R1(config-router)#area 1 authentication message-digest
2、被动接口(只能使用在连接客户的接口)
R1(config)#router ospf 100
R1(config-router)#passive-interface loopback 0
3、加快收敛速度,只能加快hello时间
R1(config)#int s1/1
R1(config-if)#ip ospf hello-interval 5 修改hello时间为5s dead time自动四倍关系
R1(config-if)#ip ospf dead-interval 20
链路两端必须一致
https://pan.baidu.com/s/1REE8IIZv-_X4ueki0SJcaw
4、缺省路由
必须自己有才能下放
R1(config)#router ospf 100
R1(config-router)#default-information originate
需要有缺省路由指向ISP
R1(config)#ip route 0.0.0.0 0.0.0.0 loopback 10
强制下放缺省
R1(config)#router ospf 100
R1(config-router)#default-information originate always