除已知条目外,其余全是它们各自的未知,此时我们可以用两种办法来配置静态路由
一、使用下一跳next-hop:
R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.123.1 R2(config)#ip route 1.1.2.0 255.255.255.0 192.168.123.1 R2(config)#ip route 1.1.3.0 255.255.255.0 192.168.123.1 |
红字标识的即为next-hop
看一下路由表:
R2#sh ip route static 1.0.0.0/24 is subnetted, 3 subnets S 1.1.1.0 [1/0] via 192.168.123.1 S 1.1.2.0 [1/0] via 192.168.123.1 S 1.1.3.0 [1/0] via 192.168.123.1 |
到达三个未知的地方全部都交给了 via 192.168.123.1 ,注意[]里的数字[1/0]
二、使用出接口interface:
R1(config)#ip route 2.2.1.0 255.255.255.0 serial 1/1 R1(config)#ip route 2.2.2.0 255.255.255.0 serial 1/1 R1(config)#ip route 2.2.3.0 255.255.255.0 serial 1/1 |
红字标识的地方即为出接口
看一下路由表:
R1#sh ip route static 2.0.0.0/24 is subnetted, 3 subnets S 2.2.1.0 is directly connected, Serial1/1 S 2.2.2.0 is directly connected, Serial1/1 S 2.2.3.0 is directly connected, Serial1/1 |
这里已经没有[]了。取而代之的是directly connected,说明路由器R1认为这些条目都是自己直连的条目。
路由器在路由选择的过程中会比较哪条路是更好的路
这时候如果用第一种方法给它配上相同的路由条目,看一下会出现什么情况:
R1(config)#ip route 2.2.1.0 255.255.255.0 192.168.12.2 R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.12.2 R1(config)#ip route 2.2.3.0 255.255.255.0 192.168.12.2 R1#sh ip route sta R1#sh ip route static 2.0.0.0/24 is subnetted, 3 subnets S 2.2.1.0 is directly connected, Serial1/1 [1/0] via 192.168.12.2 S 2.2.2.0 is directly connected, Serial1/1 [1/0] via 192.168.12.2 S 2.2.3.0 is directly connected, Serial1/1 [1/0] via 192.168.12.2 |
R1认为现在R1到达R2后面的直连网络可以有两条路走了,其实只有这一条通道,却被R1认为是两条不同的路。可见,这两种方法需要根据情况使用,否则可能会出现路由选择的问题。

