三、ospf协议
有关命令
基本配置举例
使用身份验证
ospf(open shortest path first)是一个内部网关协议(interior gateway protocol,简称igp),用于在单一自治系统(autonomous system,as)内决策路由。与rip相对,ospf是链路状态路有协议,而rip是距离向量路由协议。
链路是路由器接口的另一种说法,因此ospf也称为接口状态路由协议。ospf通过路由器之间通告网络接口的状态来建立链路状态数据库,生成最短路径树,每个ospf路由器使用这些最短路径构造路由表。
文档见rfc2178.
1.有关命令
全局设置
任务
命令
指定使用ospf协议
router ospf process-id1
指定与该路由器相连的网络
network address wildcard-mask area area-id2
指定与该路由器相邻的节点地址
neighbor ip-address
注:1、ospf路由进程process-id必须指定范围在1-65535,多个ospf进程可以在同一个路由器上配置,但最好不这样做。多个ospf 进程需要多个ospf数据库的副本,必须运行多个最短路径算法的副本。process-id只在路由器内部起作用,不同路由器的process-id可以不同。
2、wildcard-mask 是子网掩码的反码, 网络区域id area-id在0-4294967295内的十进制数,也可以是带有ip地址格式的x.x.x.x.当网络区域id为0或0.0.0.0时为主干域。不同网络区域的路由器通过主干域学习路由信息。
go top
2.基本配置举例:
| router1: interface ethernet 0 ip address 192.1.0.129 255.255.255.192 ! interface serial 0 ip address 192.200.10.5 255.255.255.252 ! router ospf 100 network 192.200.10.4 0.0.0.3 area 0 network 192.1.0.128 0.0.0.63 area 1 ! router2: interface ethernet 0 ip address 192.1.0.65 255.255.255.192 ! interface serial 0 ip address 192.200.10.6 255.255.255.252 ! router ospf 200 network 192.200.10.4 0.0.0.3 area 0 network 192.1.0.64 0.0.0.63 area 2 ! router3: interface ethernet 0 ip address 192.1.0.130 255.255.255.192 ! router ospf 300network 192.1.0.128 0.0.0.63 area 1 ! router4:interface ethernet 0 ip address 192.1.0.66 255.255.255.192 ! router ospf 400 network 192.1.0.64 0.0.0.63 area 1 ! |
相关调试命令:
| debug ip ospf eventsdebug ip ospf packetshow ip ospfshow ip ospf databaseshow ip ospf interfaceshow ip ospf neighborshow ip routego top |