通过修改cost值改变路由选择

通过修改cost值改变路由选择

命令show ip ospf int (可以查看开启了ospf 的接口的详细信息)
下面是R1的两个端口的相关信息

F0/0:

FastEthernet0/0 is up, line protocol is up
Internet address is 123.1.1.1/24, Area 0
Process ID 1, Router ID 11.11.11.11, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 11.11.11.11, Interface address 123.1.1.1
Backup Designated Router (ID) 3.3.3.3, Interface address 123.1.1.3
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:02
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 0 msec
Neighbor Count is 2, Adjacent neighbor count is 2
Adjacent with neighbor 2.2.2.2
Adjacent with neighbor 3.3.3.3 (Backup Designated Router)
Suppress hello for 0 neighbor(s)

s0/2/0:

Serial0/2/0 is up, line protocol is up
Internet address is 12.1.1.1/24, Area 0
Process ID 1, Router ID 11.11.11.11, Network Type POINT-TO-POINT, Cost: 64
Transmit Delay is 1 sec, State POINT-TO-POINT, Priority 0
No designated router on this network
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:02
Index 2/2, 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 0 msec
Neighbor Count is 1 , Adjacent neighbor count is 1
Adjacent with neighbor 2.2.2.2
Suppress hello for 0 neighbor(s)

从中可以得知各个接口的cost值

show ip route:
通过修改cost值改变路由选择
(思科不好的一点就是它有很多信息显示得没有某为简练,到位,这里的开销值没有给出)

但从图中不难看出R1到R4选择的线路为R1-R2(123.1.1.2)-R4。

cost值可以自己算。以上诉路线为例
开销值为路由学习方向(数据发出方向)的端口的cost值之和
从前图已经知道了R1 F0/0的cost值为1,并且还知道了线路为R1-R2(123.1.1.2)-R4 ,那还需知道R上的F0/1端口的cost值
通过修改cost值改变路由选择
可以看见F0/1的cost值为1
也就是说整条路线的cost值为2

根据题目要求,需更改路线为R1-R2(12.1.1.2)-R4
因为R1-R2(123.1.1.2)-R4已经没办法再小了,所以只能将R1-R2(12.1.1.2)-R4开销值改大

改R1的F0/0
通过修改cost值改变路由选择

通过修改cost值改变路由选择
从上图可以看见,路线修改成功