赞
踩
目录
路由器向邻居发送报文,报文中包含自己所知道的路由信息,与邻居形成邻居表,后路由器之间发送链路状态通告告知邻居自己的链路连接状态,形成LSDB拓扑表,后形成路由表。
1.协议范围是IGP内部网关协议,协议算法采用链路状态型路由协议,传递网络掩码(无类别的路由协议) ,基于IP协议封装,IP层协议号为89。
2.OSPF是一种链路状态型协议(既传递路由信息也传递拓扑信息),传递的是 LSA (链路状态通告 共6种类型LSA1 2 3 4 5 7) 。
3.OSPF 更新方式: 触发更新 + 30分钟的周期链路状态刷新 。触发更新—网络结构稳定的时候不发数据,网络结构产生变化(网段数量或信息变化,接口状态变化等)时发数据,OSPF 更新地址: 224.0.0.5/6
4.OSPF 支持区域划分,比较消耗路由器资源。
5.开销值计算方式为100Mbps(参照带宽)/真实带宽,若产生小数点直接舍弃
限制LSA的传播范围
减少LSA的数量
十进制数或者类似于IP地址形式
骨干区域(0区域)
非骨干区域 (非0区域)
区域设计原则:
OSPF网络中必须存在并且唯一的骨干区域(单区域可以不为骨干区域 )
有非骨干区域时,非骨干区域必须与骨干区域直接相连
骨干路由器:路由器所有接口都属于骨干区域
非骨干路由器:路由器接口都不属于骨干区域
ABR:区域边界路由器,骨干区域和非骨干区域的接界
ASBR:自治系统边界路由器,位于使用不同协议的路由器边界上,将路由引入为对方能够学习成功的路由
- [r1]display ip interface brief
- Interface IP Address/Mask Physical Protocol
- GigabitEthernet0/0/0 10.1.1.1/24 up up
- LoopBack0 1.1.1.1/24 up up(s)
- [r2]display ip interface brief
- Interface IP Address/Mask Physical Protocol
- GigabitEthernet0/0/0 20.1.1.1/24 up up
- GigabitEthernet0/0/1 10.1.1.2/24 up up
- LoopBack0 2.2.2.2/24 up up(s)
- [r3]display ip interface brief
- Interface IP Address/Mask Physical Protocol
- GigabitEthernet0/0/1 20.1.1.2/24 up up
- LoopBack0 3.3.3.3/24 up up(s)
(1)启用ospf指定进程号(和rip协议相同,进程号只具有本地意义),指定router id(路由标识符),必须书写,代表着该设备在ospf网络中的唯一性,有两种方式——手工指定,这是最简易的也是最优先的;自动选取环回接口/物理接口最大的作为标识
- [r1]ospf 100 router-id 91.1.1.1
- [r2]ospf 100 router-id 92.1.1.1
- [r3]ospf 100 router-id 93.1.1.1
(2)进入ospf区域(以全区域为例)
- [r1-ospf-100]area 0
- [r1-ospf-100-area-0.0.0.0]
- [r2-ospf-100]area 0
- [r2-ospf-100-area-0.0.0.0]
- [r3-ospf-100]area 0
- [r3-ospf-100-area-0.0.0.0]
(3)network通告,使用反掩码,实现精确通告,连续的0和连续的1组成,0代表固定位,1代表可变位,仅告知是否可变,不告知网络/主机位
- [r1-ospf-100-area-0.0.0.0]network 1.1.1.1 0.0.0.0
- [r1-ospf-100-area-0.0.0.0]network 10.1.1.1 0.0.0.0
- [r2-ospf-100-area-0.0.0.0]network 2.2.2.2 0.0.0.0
- [r2-ospf-100-area-0.0.0.0]network 10.1.1.2 0.0.0.0
- [r2-ospf-100-area-0.0.0.0]network 20.1.1.1 0.0.0.0
- [r3-ospf-100-area-0.0.0.0]network 3.3.3.3 0.0.0.0
- [r3-ospf-100-area-0.0.0.0]network 20.1.1.2 0.0.0.0
(4)查表
邻居表
- [r1-ospf-100-area-0.0.0.0]display ospf peer brief
-
- OSPF Process 100 with Router ID 91.1.1.1
- Peer Statistic Information
- ----------------------------------------------------------------------------
- Area Id Interface Neighbor id State
- 0.0.0.0 GigabitEthernet0/0/0 92.1.1.1 Full
- ----------------------------------------------------------------------------
- [r2-ospf-100-area-0.0.0.0]display ospf peer brief
-
- OSPF Process 100 with Router ID 92.1.1.1
- Peer Statistic Information
- ----------------------------------------------------------------------------
- Area Id Interface Neighbor id State
- 0.0.0.0 GigabitEthernet0/0/1 91.1.1.1 Full
- 0.0.0.0 GigabitEthernet0/0/0 93.1.1.1 Full
- ----------------------------------------------------------------------------
- [r3-ospf-100-area-0.0.0.0]display ospf peer brief
-
- OSPF Process 100 with Router ID 93.1.1.1
- Peer Statistic Information
- ----------------------------------------------------------------------------
- Area Id Interface Neighbor id State
- 0.0.0.0 GigabitEthernet0/0/1 92.1.1.1 Full
- ----------------------------------------------------------------------------
LSDB表
- [r1-ospf-100-area-0.0.0.0]display ospf lsdb
-
- OSPF Process 100 with Router ID 91.1.1.1
- Link State Database
-
- Area: 0.0.0.0
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 93.1.1.1 93.1.1.1 284 48 80000005 1
- Router 92.1.1.1 92.1.1.1 292 60 80000009 1
- Router 91.1.1.1 91.1.1.1 428 48 80000005 1
- Network 10.1.1.2 92.1.1.1 422 32 80000002 0
- Network 20.1.1.2 93.1.1.1 284 32 80000002 0
- [r2-ospf-100-area-0.0.0.0]display ospf lsdb
-
- OSPF Process 100 with Router ID 92.1.1.1
- Link State Database
-
- Area: 0.0.0.0
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 93.1.1.1 93.1.1.1 302 48 80000005 1
- Router 92.1.1.1 92.1.1.1 310 60 80000009 1
- Router 91.1.1.1 91.1.1.1 448 48 80000005 1
- Network 10.1.1.2 92.1.1.1 440 32 80000002 0
- Network 20.1.1.2 93.1.1.1 302 32 80000002 0
-
- [r3-ospf-100-area-0.0.0.0]display ospf lsdb
-
- OSPF Process 100 with Router ID 93.1.1.1
- Link State Database
-
- Area: 0.0.0.0
- Type LinkState ID AdvRouter Age Len Sequence Metric
- Router 93.1.1.1 93.1.1.1 317 48 80000005 1
- Router 92.1.1.1 92.1.1.1 327 60 80000009 1
- Router 91.1.1.1 91.1.1.1 465 48 80000005 1
- Network 10.1.1.2 92.1.1.1 457 32 80000002 0
- Network 20.1.1.2 93.1.1.1 317 32 80000002 0
路由表
- [r1-ospf-100-area-0.0.0.0]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 3 Routes : 3
-
- OSPF routing table status : <Active>
- Destinations : 3 Routes : 3
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 2.2.2.2/32 OSPF 10 1 D 10.1.1.2 GigabitEthernet
- 0/0/0
- 3.3.3.3/32 OSPF 10 2 D 10.1.1.2 GigabitEthernet
- 0/0/0
- 20.1.1.0/24 OSPF 10 2 D 10.1.1.2 GigabitEthernet
- 0/0/0
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
- [r2-ospf-100-area-0.0.0.0]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 2 Routes : 2
-
- OSPF routing table status : <Active>
- Destinations : 2 Routes : 2
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 1.1.1.1/32 OSPF 10 1 D 10.1.1.1 GigabitEthernet
- 0/0/1
- 3.3.3.3/32 OSPF 10 1 D 20.1.1.2 GigabitEthernet
- 0/0/0
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
-
- [r3-ospf-100-area-0.0.0.0]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 3 Routes : 3
-
- OSPF routing table status : <Active>
- Destinations : 3 Routes : 3
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 1.1.1.1/32 OSPF 10 2 D 20.1.1.1 GigabitEthernet
- 0/0/1
- 2.2.2.2/32 OSPF 10 1 D 20.1.1.1 GigabitEthernet
- 0/0/1
- 10.1.1.0/24 OSPF 10 2 D 20.1.1.1 GigabitEthernet
- 0/0/1
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
可以注意到表内环回接口掩码被标注为32位,表示一条主机路由,固定为一个主机,是由于OSPF测试到你是一个环回接口,默认给你识别为32位。进入环回更改network类型即可还原真实网络掩码。
- [r1]interface LoopBack 0
- [r1-LoopBack0]ospf network-type broadcast
- [r2]interface LoopBack 0
- [r2-LoopBack0]ospf network-type broadcast
- [r3]interface LoopBack 0
- [r3-LoopBack0]ospf network-type broadcast
- [r1]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 3 Routes : 3
-
- OSPF routing table status : <Active>
- Destinations : 3 Routes : 3
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 2.2.2.0/24 OSPF 10 1 D 10.1.1.2 GigabitEthernet
- 0/0/0
- 3.3.3.0/24 OSPF 10 2 D 10.1.1.2 GigabitEthernet
- 0/0/0
- 20.1.1.0/24 OSPF 10 2 D 10.1.1.2 GigabitEthernet
- 0/0/0
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
- [r2]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 2 Routes : 2
-
- OSPF routing table status : <Active>
- Destinations : 2 Routes : 2
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 1.1.1.0/24 OSPF 10 1 D 10.1.1.1 GigabitEthernet
- 0/0/1
- 3.3.3.0/24 OSPF 10 1 D 20.1.1.2 GigabitEthernet
- 0/0/0
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
- [r3]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 3 Routes : 3
-
- OSPF routing table status : <Active>
- Destinations : 3 Routes : 3
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 1.1.1.0/24 OSPF 10 2 D 20.1.1.1 GigabitEthernet
- 0/0/1
- 2.2.2.0/24 OSPF 10 1 D 20.1.1.1 GigabitEthernet
- 0/0/1
- 10.1.1.0/24 OSPF 10 2 D 20.1.1.1 GigabitEthernet
- 0/0/1
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
在边界路由器上新建一个环回接口,此时其他路由器不能到达
(1)强制产生
进入ospf进行配置强制产生
- [r1]ospf 100
- [r1-ospf-100]default-route-advertise always
- [r2]display ip routing-table protocol ospf
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : OSPF
- Destinations : 3 Routes : 3
-
- OSPF routing table status : <Active>
- Destinations : 3 Routes : 3
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 0.0.0.0/0 O_ASE 150 1 D 10.1.1.1 GigabitEthernet
- 0/0/1
- 1.1.1.0/24 OSPF 10 1 D 10.1.1.1 GigabitEthernet
- 0/0/1
- 3.3.3.0/24 OSPF 10 1 D 20.1.1.2 GigabitEthernet
- 0/0/0
-
- OSPF routing table status : <Inactive>
- Destinations : 0 Routes : 0
-
- [r2]ping 6.6.6.6
- PING 6.6.6.6: 56 data bytes, press CTRL_C to break
- Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=255 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=2 ttl=255 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=3 ttl=255 time=30 ms
- Reply from 6.6.6.6: bytes=56 Sequence=4 ttl=255 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=5 ttl=255 time=20 ms
-
- --- 6.6.6.6 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 20/22/30 ms
- [r3]ping 6.6.6.6
- PING 6.6.6.6: 56 data bytes, press CTRL_C to break
- Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=254 time=40 ms
- Reply from 6.6.6.6: bytes=56 Sequence=2 ttl=254 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=3 ttl=254 time=30 ms
- Reply from 6.6.6.6: bytes=56 Sequence=4 ttl=254 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=5 ttl=254 time=20 ms
-
- --- 6.6.6.6 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 20/26/40 ms
(2)新建或已存在其它类型的缺省
进入ospf进行配置
- [r1]display ip interface brief
- Interface IP Address/Mask Physical Protocol
- GigabitEthernet0/0/0 10.1.1.1/24 up up
- GigabitEthernet0/0/1 unassigned down down
- GigabitEthernet0/0/2 unassigned down down
- LoopBack0 1.1.1.1/24 up up(s)
- LoopBack1 6.6.6.6/24 up up(s)
- NULL0 unassigned up up(s)
- [r1]ospf 100
- [r1-ospf-100]default-route-advertise
- [r1]ip route-static 0.0.0.0 0.0.0.0 LoopBack 1
- [r1]display ip routing-table protocol static
- Route Flags: R - relay, D - download to fib
- ------------------------------------------------------------------------------
- Public routing table : Static
- Destinations : 1 Routes : 1 Configured Routes : 1
-
- Static routing table status : <Active>
- Destinations : 1 Routes : 1
-
- Destination/Mask Proto Pre Cost Flags NextHop Interface
-
- 0.0.0.0/0 Static 60 0 D 6.6.6.6 LoopBack1
-
- Static routing table status : <Inactive>
- Destinations : 0 Routes : 0
- [r2]ping 6.6.6.6
- PING 6.6.6.6: 56 data bytes, press CTRL_C to break
- Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=255 time=30 ms
- Reply from 6.6.6.6: bytes=56 Sequence=2 ttl=255 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=3 ttl=255 time=30 ms
- Reply from 6.6.6.6: bytes=56 Sequence=4 ttl=255 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=5 ttl=255 time=20 ms
-
- --- 6.6.6.6 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 20/24/30 ms
-
- [r3]ping 6.6.6.6
- PING 6.6.6.6: 56 data bytes, press CTRL_C to break
- Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=254 time=40 ms
- Reply from 6.6.6.6: bytes=56 Sequence=2 ttl=254 time=30 ms
- Reply from 6.6.6.6: bytes=56 Sequence=3 ttl=254 time=30 ms
- Reply from 6.6.6.6: bytes=56 Sequence=4 ttl=254 time=20 ms
- Reply from 6.6.6.6: bytes=56 Sequence=5 ttl=254 time=30 ms
-
- --- 6.6.6.6 ping statistics ---
- 5 packet(s) transmitted
- 5 packet(s) received
- 0.00% packet loss
- round-trip min/avg/max = 20/30/40 ms
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。