监测和调试 OSPF协议( 四 )


(3)show ip ospf interface命令给出了S0和S1接口的Cost值 , 它们也为相同的64 。
(4)细心的读者可能产生了一个疑问 , 即:为什么在路由表中显示的Cost(74)与接口的Cost(64)之间不同?
为说明问题 , 切换到R1路由器上 , 查看OSPF接口信息 , 表明其E0接口的Cost为10 。
从R2路由器到172.16.1.0/24网段需要经过R1、R2之间的串行链路和R2的以太网接口 , 所以最终的Cost值为两个链路的Cost值相加 , 为74 。对于到172.16.30/24网段的路由而言 , 其结果相同 。
(5)在第2段中 , 通过更改相应接口的带宽参数来影响Cost值 。
在R2路由器上 , 使用bandwidth命令 , 设置S0接口的带宽为64kbit/s , S1接口的带宽为125kbit/s 。
查看OSPF路由表 , 结果显示相应的Cost己经更改为1572(S0接口)和810(S1接口) 。
分别查看接口信息和OSPF接口信息 , 表明带宽和Cost值已经产生应有的变化 , Cost值分别是1562(S0接口)和800(S1接口) 。
(6)有一种更为直接的更改Cost值的方法 , 那就是第3段中演示的在接口配置模式下使 用ip ospfcost命令定义Cost的方法 。
实验中我们把S0接口的Cost设定为200 。相应的命令显示设置是成功的 。
ip ospf cost命令不管相应接口的带宽为多少 , 人工设定一个Cost值 , 并立即生效 , 参与路由的计算 。
第4部分:最终的各路由器配置清单
为便于读者学习 , 在实验的最后列出3台路由器的完整配置清单 。清单中R1和R3路由器也加入了带宽的设置 。请注重E0接口下设置了no keepalive语旬 , 这是因为在实验环境下此接口没有连接网线;在实际的网络环境下 , 不应设置此语句 。
所有路由器的最终配置见配置清单11-2 。
配置清单11-2所有路由器的最终配置
第1段:R1路由器的配置清单
Current configuration : 642 bytes
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service passWord-encryption
!
hostname R1
ip subnet-zero
!
interface Ethemet0
 ip address 172.16.1.1255.255.255.0
 no keepalive
!
interface Serial0
 no ip address
 shutdown
!
interface Serial 1
 bandwidth 125
 ip address 192.168.1.1255.255.255.252
 clockrate 125000
!
router ospf 100
 network 172.16.1.1 0.0.0.0 area 0
 network 192.168.1.1 0.0.0.0 area 0
!
ip classless
ip http server
!
line con 0
line aux 0
line vty 0 4
 login
!
end
第2段:R2路由器的配置清单
Current configuration : 618 bytes
!
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
hostname R2
!
ip subnet-zero
!
interface Ethemet0
 no ip address
 shutdown
!
interface Serial0
 bandwidth 64
 ip address 192.168.1.5 255.255.255.252
!
interface Serial 1
 bandwidth 125
 ip address 192.168.1.2 255.255.255.252
!
router ospf 100
 network 192.168.1.2 0.0.0.0 area 0
 network 192.168.1.5 0.0.0.0 area 0
!
ip classless
ip http server
!
line con 0
line aux 0
line vty 0 4
 login
!
end
第3段:R3路由器的配置清单
Current configuration : 678 bytes
version 12.1
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R3
!
ip subnet-zero
!
interface Ethemet0
 ip address 172.16.3.1255.255.255.0
no keepalive
!
interface Serial0
 bandwidth 64

推荐阅读