OSPF
之
auto-cost reference-bandwidth
的应用
在
OSPF
的使用过程中,当链路中的带宽(端口的带宽)不一致时,为了防止设备自动计算
cost
值出现失误,我们往往手动的通过更改
auto-cost
的值来实现人为控制路由选路(
ip ospf cost
也可以达到人为选路的目的),现在我们以一个实例来说下
auto-cost
的使用。
如下面拓扑所示:
RSR20
的端口都是百兆口,两个
5750
都是千兆口,在默认情况开启
OSPF
后其路由表显示如下:
S 5750A #sh ip route
Gateway of last resort is no set
C 192.168.128.40/29 is directly connected, GigabitEthernet 0/2
C 192.168.128.44/32 is local host.
C 192.168.129.40/29 is directly connected, GigabitEthernet 0/1
C 192.168.129.44/32 is local host.
O 192.168.130.40/29 [110/2] via 192.168.129.45, 00:00:06, GigabitEthernet 0/1
[110/2] via 192.168.128.45, 00:00:06, GigabitEthernet 0/2
S 5750A #sh ip route
Gateway of last resort is no set
C 192.168.128.40/29 is directly connected, GigabitEthernet 0/2
C 192.168.128.45/32 is local host.
O 192.168.129.40/29 [110/2] via 192.168.130.45, 00:00:49, GigabitEthernet 0/1
[110/2] via 192.168.128.44, 00:00:49, GigabitEthernet 0/2
C 192.168.130.40/29 is directly connected, GigabitEthernet 0/1
C 192.168.130.44/32 is local host.
RSR 20A #sh ip route
Gateway of last resort is no set
O 192.168.128.40/29 [110/2] via 192.168.129.44, 00:01:39, FastEthernet 0/0
[110/2] via 192.168.130.44, 00:01:39, FastEthernet 0/1
C 192.168.129.40/29 is directly connected, FastEthernet 0/0
C 192.168.129.45/32 is local host.
C 192.168.130.40/29 is directly connected, FastEthernet 0/1
C 192.168.130.45/32 is local host.
这个时候就出现一种情况,任何一台设备到其未直连的网段有两条路由可走,而实际上使用
traceroute
测试
192.168.130.45
(
RSR20
的
F0/0
口时),显示下一跳为
192.168.120.44
à
192.168.129.45
(即经过
S5750B
转发到达
RSR20
);然后再使用
traceroute
测试
192.168.129.44
(
RSR20
的
F0/0
口时),显示的下一跳为
192.168.130.45
à
192.168.129.44
(即经过
RSR20
转发后到达
S5750B
)。确实有点蹊跷,超出路由可控的情况了。
仔细查看了下路由表突然发现这么一种情况:每台设备通过
OSPF
获得的未知网段的
cost
值都是
2
,可是链路中又有
100M
的又有
1000M
的怎么会出现这种情况呢?
查看了一下设备手册才知道,
RSR20
和
S5750S
的
OSPF
默认的度量参考值均为
100
,这样的话,在设备自动计算的时候,对于
100M
链路而言有
cost=100/100=1;
而对于
1000M
的链路而言则有
cost=100/1000=0.1
也视为
1
进行计算,故
1000M
链路的优势根本就没有显现出来。此时我们可以手动的修改其度量参考值,在路由配置模式下使用
auto-cost reference-bandwidth 1000
来设置接口带宽缺省度量(参考值一般由设备的最大带宽决定,般与最大带宽相同)。
在
RSR20
、
S 5750A
和
S5750B
的路由模式下都添加上一句
auto-cost reference-bandwidth 1000
,此时我们再次查看一下路由表:
S5750B#sh ip route
Gateway of last resort is no set
C 192.168.128.40/29 is directly connected, GigabitEthernet 0/2
C 192.168.128.44/32 is local host.
C 192.168.129.40/29 is directly connected, GigabitEthernet 0/1
C 192.168.129.44/32 is local host.
O 192.168.130.40/29 [110/11] via 192.168.128.45, 00:02:58, GigabitEthernet 0/2
S 5750A #sh ip route
Gateway of last resort is no set
C 192.168.128.40/29 is directly connected, GigabitEthernet 0/2
C 192.168.128.45/32 is local host.
O 192.168.129.40/29 [110/11] via 192.168.128.44, 00:05:15, GigabitEthernet 0/2
C 192.168.130.40/29 is directly connected, GigabitEthernet 0/1
C 192.168.130.44/32 is local host.
RSR 20A #sh ip route
Gateway of last resort is no set
O 192.168.128.40/29 [110/11] via 192.168.129.44, 00:06:32, FastEthernet 0/0
[110/11] via 192.168.130.44, 00:06:32, FastEthernet 0/1
C 192.168.129.40/29 is directly connected, FastEthernet 0/0
C 192.168.129.45/32 is local host.
C 192.168.130.40/29 is directly connected, FastEthernet 0/1
C 192.168.130.45/32 is local host.
这个时候就出现一种情况,任何一台设备到其未直连的网段只有
1
条最佳路由可走,而实际上在
S5750B
上使用
traceroute
测试
192.168.130.45
(
RSR20
的
F0/1
口时),显示下一跳为
192.168.128.45
à
192.168.130.45
(即经过
S5750B
转发到达
RSR20
);然后再使用
traceroute
测试
192.168.129.45
(
RSR20
的
F0/0
口时),显示的下一跳为
192.168.129.45
à
192.168.130.44
(即经过
RSR20
转发后到达
S 5750A
),网络走的是
S 5750A
和
S5750B
间的
1000M
链路了。