赞
踩
过程
建立邻居关系——>建立邻接关系,交互LAS并且同步LSDB——>基于最短路径树得出路由表
度量值为cost
cost=10^8/BW
最短路径是基于接口指定的代价cost
十兆=10
百兆=1
千兆=0.1
越小越好
距离矢量路由协议: RIP1/2、BGP (路径矢量协议)、EIGRP ( 高级距离矢量协议)
路由器对全网拓扑不完全了解。是“传说的路由”,A发路由信息给B,B加上自己的度量值又发给C,路由表里的条目是听来的。
链路状态路由协议: OSPF、ISIS
路由器对全网拓扑完全了解。是“传信的路由",A将信息放在一封信里发给B,B对其不做任何改变,拷贝下来,并将自己的信息放在另一封信里,两封信一起给C,这样,信息没有任何改变和丢失,最后所有路由器都收到相同的一堆信,这一堆信就是LSDB。 然后,每个路由器运用相同的SPF算法,以自己为根,计算出SPF Tree (即到达目的地的各个方案),选出最佳路径,放入路由表中。
为了适应大型的网络, OSPF在AS内划分多个区域。
每个OSPF路由器只维护所在区域的完整链路状态信息。
区域ID可以表示成一个十进制的数字。
也可以表示成一个IP。
骨干区域Area 0
作为中央实体,其他区域与之相连,骨干区域编号为 0,在该区域中,各种类型的 LSA 均允许发布。
非骨干区域
通过一个非骨干区域连接一个区域到骨干区域
通过一个非骨干区域连接-一个分段的骨干区域两边的部分区域
选取路由器loopback接口.上数值最高的IP地址。
如果没有loopback接口,在物理端口中选取IP地址最高的。
可以使用router-id命令指定Router ID。
优先级范围是0~ 255,数值越大,优先级越高,默认为1。
如果优先级相同,则需要比较Router ID。
如果路由器的优先级被设置为0,它将不参与DR和DBR的选举。
224.0.0.5是选举时,发送第一个Hello包和DRothers监控时所用地址。
224.0.06是DR和BDR监控时所用地址。
OSPF的特点
邻居列表
链路状态数据库
路由表
OSPF将网络划分为4种类型
封装在IP数据包内,协议号89
类型 | 功能 |
---|---|
Hello包 | 用于发现和维持邻居关系,选举DR和BDR |
数据库描述包(DBD) | 用于向邻居发送摘要信息以同步链路状态数据库 |
链路状态请求包(LSR) | 在路由器收到包含新信息的DBD后发送,用于请求更详细的信息 |
链路状态更新包(LSU) | 收到LSR后发送链路状态通告(LSA) ,一个LSU数据包可能包含几个LSA |
链路状态确认包(LSAck) | 确认已经收到DBD/ LSU,每个LSA需要被分别确认 |
OSPF6种LSA类型
类型代码 | 描述 | 用途 |
---|---|---|
Type 1 | 路由器LSA | 由区域内的路由器发出的,描述了路由器的的链路状态和花费,传递到整个区域内 |
Type 2 | 网络LSA | 由区域内的DR发出的,描述了区域内变更信息,传递到整个区域内 |
Type 3 | 网络汇总LSA | ABR发出的,其他区域的汇总链路通告,描述了其他区域内某一网段的路由,区域间传递 |
Type 4 | ASBR汇总LSA | ABR发出的,用于通告ASBR信息,确定ASBR的位置,不会出现在ASBR所属区域之内 |
Type 5 | AS外部LSA | ASBR发出的,用于通告外部路由,告诉相同AS的路由器通往外部AS的路径,在整个AS中进行泛洪 |
Type 7 | NSSA外部LSA | NSSA区域内的ASBR发出的,用于通告本区域连接的外部路由,与Type 5类似,仅在非纯末梢区域内进行泛洪,传递时会被ABR转换为LSA5 |
每一种区域中允许泛洪的LSA | ||
区域类型 | 1&2 | 3 |
– | – | – |
骨干区域(区域0) | 允许 | 允许 |
非骨干区域,非末梢区域 | 允许 | 允许 |
末梢区域 | 允许 | 允许 |
完全末梢区域 | 允许 | 不允许* |
NSSA | 允许 | 允许 |
OSPF7种状态
邻居状态机:
R1
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int loop0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]network 1.1.1.1 0.0.0.0
[Huawei-ospf-1-area-0.0.0.2]network 12.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.2]q
R2
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int loop0
[Huawei-LoopBack0]ip add 2.2.2.2 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 23.0.0.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf
[Huawei-ospf-1]area 2
[Huawei-ospf-1-area-0.0.0.2]network 12.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.2]net
[Huawei-ospf-1-area-0.0.0.2]network 2.2.2.2 0.0.0.0
[Huawei-ospf-1-area-0.0.0.2]q
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net
[Huawei-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
R3
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int loop0
[Huawei-LoopBack0]ip add 3.3.3.3 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 23.0.0.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 34.0.0.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
R4
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int loop0
[Huawei-LoopBack0]ip add 4.4.4.4 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 34.0.0.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 45.0.0.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-]ospf
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]un network 45.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]q
R5
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int loop0
[Huawei-LoopBack0]ip add 5.5.5.5 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 45.0.0.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 56.0.0.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ospf
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]network 5.5.5.5 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]network 45.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]network 56.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]q
R6
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int loop 0
[Huawei-LoopBack0]ip add 6.6.6.6 32
[Huawei-LoopBack0]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 56.0.0.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ospf
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]network 6.6.6.6 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]network 56.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]q
R1
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.10.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int loop0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]q
ip route-static 0.0.0.0 0 192.168.10.1
R2
u tm
Error: File can’t be found
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.10.1 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.20.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip add 2.2.2.2 32
[Huawei-LoopBack0]q
[Huawei]ospf
[Huawei-ospf-1]a 1
[Huawei-ospf-1-area-0.0.0.1]net 192.168.20.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]net 2.2.2.2 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]q
[Huawei-ospf-1]q
[Huawei]ip route-static 1.1.1.1 32 192.168.10.2
[Huawei]ospf
[Huawei-ospf-1]import-route static
[Huawei-ospf-1]import-route direct
[Huawei-ospf-1]dis th
R3
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.30.1 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.20.2 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 192.168.40.1 24
[Huawei-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[Huawei-GigabitEthernet0/0/2]int loop0
[Huawei-LoopBack0]ip add 3.3.3.3 32
[Huawei-LoopBack0]q
[Huawei]ospf
[Huawei-ospf-1]a 0
[Huawei-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]a 1
[Huawei-ospf-1-area-0.0.0.1]net 192.168.20.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]net 3.3.3.3 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]q
[Huawei-ospf-1]q
[Huawei]ip route-static 0.0.0.0 0 192.168.40.2
[Huawei]q
[Huawei]ospf
[Huawei-ospf-1]default-route-advertise always
[Huawei-ospf-1]import-route direct
[Huawei-ospf-1]q
R4
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.30.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.50.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip add 4.4.4.4 32
[Huawei-LoopBack0]q
[Huawei]ospf
[Huawei-ospf-1]a 0
[Huawei-ospf-1-area-0.0.0.0]network 192.168.30.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]rip
[Huawei-rip-1]net 192.168.50.0
[Huawei-rip-1]version 2
[Huawei-rip-1]un summary ri
[Huawei-rip-1]q
[Huawei]rip
[Huawei-rip-1]import-route ospf 1 cost 2
[Huawei-rip-1]ospf 1
[Huawei-ospf-1]import-route rip 1 type 1 cost 1
[Huawei-rip-1]default-route originate
[Huawei-rip-1]q
R5
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.40.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int loop0
[Huawei-LoopBack0]ip add 5.5.5.5 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 0.0.0.0 0 192.168.40.1
R6
u t m
Info: Current terminal monitor is off.
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.50.2 24
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int loop0
[Huawei-LoopBack0]ip add 6.6.6.6 32
[Huawei-LoopBack0]q
[Huawei]rip
[Huawei-rip-1]network 192.168.50.0
[Huawei-rip-1]network 6.0.0.0
[Huawei-rip-1]version 2
[Huawei-rip-1]un summary
[Huawei-rip-1]q
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。