点到点链路上的 OSPF
一、 拓扑图
 

 
二、实验要求
1 、度量值COST的计算
2 、Hello相关参数的配置
3 、点到点链路上的OSPF的特征
4 、查看和调试OSPF路由协议相关信息
三、实验步骤
R1
R1(config-if)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 12.1.1.0 0.0.0.255 are 0
R1(config-router)#network 1.1.1.0 0.0.0.255 are 0
 
R2
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 12.1.1.0 0.0.0.255 are 0
R2(config-router)#network 23.1.1.0 0.0.0.255 are 0
R2(config-router)#net 2.2.2.0 0.0.0.255 are 0
 
R3
R3(config-if)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 23.1.1.0 0.0.0.255 ar 0
R3(config-router)#net 34.1.1.0 0.0.0.255 ar 0
R3(config-router)#net 3.3.3.0 0.0.0.255 ar 0
 
要点
1、        OSPF 路由进程ID的范围必须在1---65535之间,只在本地有意义。和EIGRP不同,要启用OSPF进程,至少有一个端口是UP的。
2、        区域ID是在0---4294967295之间,也可是IP地址的格式A.B.C.D,当区域ID为0 或0.0.0.0时称为骨干区域。
3、        在高版本的IOS中通告OSPF网络时,网络号的后面可以是网络掩码,也可以是反掩码。
4、        Router ID 遵循如下顺序:
 . 最优先的是“router-id”指定的路由器ID。
 . 如果没有指定,选择IP地址中最大的环回接口的IP。
 . 如果没有环回口,选择最大的活动的物理接口的IP。
为了增加路由器的稳定性,建议使用“router-id”指定RID。
四、调试实验
R2#show ip rout
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     34.0.0.0/24 is subnetted, 1 subnets
O       34.1.1.0 [110/128] via 23.1.1.3, 00:20:21, Serial0/1
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/65] via 12.1.1.1, 00:20:21, Serial0/0
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 23.1.1.3, 00:20:21, Serial0/1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/129] via 23.1.1.3, 00:20:21, Serial0/1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, Serial0/
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial0/0
同一区域内通过OSPF路由协议学习到的路由条目用代码“O”表示。
  说明
1.   环回接口ospf路由条目的掩码长度都是32,这是环回口的特性,解决方法是在环回下修改网络类型为“Point-to-Point”。
R2(config)#int lo0
R2(config-if)#ip ospf network point-to-point
2.   Cost 值的计算
可通过 show ip ospf interface 查看接口的cost值 。
R2# show ip ospf inter s0/0
Serial0/0 is up, line protocol is up
 Internet Address 12.1.1.2/24, Area 0
 Process ID 1, Router ID 2.2.2.2, Network Type POINT_TO_POINT, Cost: 64
 Transmit Delay is 1 sec, State POINT_TO_POINT,
 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:04
 Supports Link-local Signaling (LLS)
 Index 1/1, flood queue length 0
 Next 0x0(0)/0x0(0)
 Last flood scan length is 1, maximum is 1
 Last flood scan time is 0 msec, maximum is 4 msec
 Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 1.1.1.1
 Suppress hello for 0 neighbor(s)
Cost 值的计算
路由条目4.4.4.4的度量值为129,计算过程如下
Cost 的计算公式为108/带宽(Serial口为1544000bps),取整数,然后将所有链路入口的cost值相加所得的和。环回接口的cost值为1,路由条目4.4.4.4到路由器R2经过的入接口包括路由器R4的loopback 0,路由器R3的s0/0,路由器R2的s0/1,所以1+108/1544000+108/1544000=129。也可通过“ip ospf cost”设置cost的值,它是优先计算的cost值。
修改R2的s0/1接口的cost值为128
R2(config-if)#int s0/1       
R2(config-if)#no ip ospf cost 128
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/193] via 23.1.1.3, 00:00:12, Serial0/1
其度量值变为193。 1+64+128=193
R2#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
3.3.3.3           0   FULL/ -        00:00:35    23.1.1.3        Serial0/1
1.1.1.1           0   FULL/ -        00:00:38    12.1.1.1        Serial0/0
可以查看R2的两个邻居,它们的RID为3.3.3.3和1.1.1.1。
1 Pri: 邻居路由器接口的优先级,为0代表不参加DR和BDR的选举
2 State :当前邻居路由器接口的状态
3 Dead Time :清除邻居关系前等待的最长时间
4 Address :邻居接口的IP地址
5 Interface :自己和邻居路由器相连接口
6 - :表示点至点的链路上OSPF不进行DR选举
要点
OSPF 邻居不能建立的常见原因
1、      Hello 和Dead间隔不同。
默认是Dead间隔是Hello的4倍,可在接口下通过“ip ospf hell-interval”和“ip ospf dead-interval”调整。
2、      区域号码不一至。
3、      特殊区域(stub和nssa)区域类型不匹配。
4、      认证类型和密码不一致。
5、      路由器ID相同。
6、      Hello 包被ACL deny了。
7、      MTU 不匹配。
8、      接口下的网络类型不匹配。
 R2#show ip ospf database
 
            OSPF Router with ID (2.2.2.2) (Process ID 1)
 
                Router Link States (Area 0)
 
Link ID         ADV Router      Age         Seq#       Checksum  Link count
1.1.1.1         1.1.1.1         1278        0x80000009      0x00510A     3
2.2.2.2         2.2.2.2         1007        0x8000000E      0x00E707     5
3.3.3.3         3.3.3.3         1152        0x8000000E      0x00CB5F     5
4.4.4.4         4.4.4.4         1134        0x80000008       0x0028DB    3
OSPF 拓扑数据库的信息,标题解释如下
1 Link ID: 是指Link State ID ,代表整个路由器,而不是某个链路。
2 ADV Route :是指通告链路状态信息的路由器ID。
3 Age :老化时间。
4 Seq# :序列号。
5 Checksum :校验和。
6 Link count :通告路由器在本区域内的链路数目。