学会静态路由的配置:
1、实验拓扑:
2、配置步骤:
R1:
ip route 3.3.3.0 255.255.255.0 10.1.2.2 //如果R1上有数据包到达3.3.3.3的话,在路由表中会把下一跳送到10.1.2.2,但是由于地址为10.1.2.2 不是自己直连的,所以在一次通过查表得到下一跳是10.1.1.2,于是把他送到R2。这就是所谓的递归查找。也是路由表查询的一条规则。
ip route 10.1.2.0 255.255.255.0 10.1.1.2
R1#show ip route static
3.0.0.0/24 is subnetted, 1 subnets
S 3.3.3.0 [1/0] via 10.1.2.2
10.0.0.0/24 is subnetted, 2 subnets
S 10.1.2.0 [1/0] via 10.1.1.2
R3:
R3#show ip route static
1.0.0.0/24 is subnetted, 1 subnets
S 1.1.1.0 [1/0] via 10.1.1.1
10.0.0.0/24 is subnetted, 2 subnets
S 10.1.1.0 [1/0] via 10.1.2.1
ip route 1.1.1.0 255.255.255.0 10.1.1.1
ip route 10.1.1.0 255.255.255.0 10.1.2.1
3、实验结果:递归查询不是一种很好的实现方法,因为他比较耗费路由器的资源。
A、实验目的:理解路由表查询的原则之一最长匹配。
B、实验拓扑:
C、配置步骤:
R1:
ip route 3.0.0.0 255.0.0.0 10.1.1.2
ip route 3.3.3.0 255.255.255.0 Null0 //为了验证路由表查询的最长匹配,在这里写了一条最长的掩码。等会在R1上ping 3.3.3.3时,如果匹配ip route 3.0.0.0 255.0.0.0 10.1.1.2的话,在R3上debug时会有相应的调试信息出来,如果没有的话,说明匹配下一条路由。
ip route 10.1.2.0 255.255.255.0 10.1.1.2
R1# show ip route st
3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
S 3.3.3.0/24 is directly connected, Null0
S 3.0.0.0/8 [1/0] via 10.1.1.2
10.0.0.0/24 is subnetted, 2 subnets
S 10.1.2.0 [1/0] via 10.1.1.2
R1#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
.....//不能ping通
Success rate is 0 percent (0/5)
R1#debug ip packet
IP packet debugging is on
R1#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
00:32:43: IP: tableid=0, s=1.1.1.1 (local), d=3.3.3.3 (Null0), routed via RIB//说明匹配了NULL0 的路由。
00:32:43: IP: s=1.1.1.1 (local), d=3.3.3.3 (Null0), len 100, sending.
00:32:45: IP: tableid=0, s=1.1.1.1 (local), d=3.3.3.3 (Null0), routed via RIB
00:32:45: IP: s=1.1.1.1 (local), d=3.3.3.3 (Null0), len 100, sending.
00:32:47: IP: tableid=0, s=1.1.1.1 (local), d=3.3.3.3 (Null0), routed via RIB
00:32:47: IP: s=1.1.1.1 (local), d=3.3.3.3 (Null0), len 100, sending.
00:32:49: IP: tableid=0, s=1.1.1.1 (local), d=3.3.3.3 (Null0), routed via RIB
00:32:49: IP: s=1.1.1.1 (local), d=3.3.3.3 (Null0), len 100, sending.
00:32:51: IP: tableid=0, s=1.1.1.1 (local), d=3.3.3.3 (Null0), routed via RIB
00:32:51: IP: s=1.1.1.1 (local), d=3.3.3.3 (Null0), len 100, sending.
Success rate is 0 percent (0/5)
R3:
R3#debug ip packet
IP packet debugging is on
R3#
D、实验结果:
通过实验得出:在路由表同时存在到达同一目的地的路由时,路由会根据最长匹配的原则对其进行查找。
A、实验目的:
1.通过写静态路由实现负载均衡
2.同时存在两条路由时,要求直走一个路径(浮动静态路由)
实验拓扑:
B、配置步骤:
R1:
ip route 2.2.2.0 255.255.255.0 Serial1/1
ip route 2.2.2.0 255.255.255.0 FastEthernet0/0
ip route 3.3.3.0 255.255.255.0 Serial1/1
ip route 3.3.3.0 255.255.255.0 FastEthernet0/0
ip route 10.1.2.0 255.255.255.0 Serial1/1
R1# show ip route static
2.0.0.0/24 is subnetted, 1 subnets
S 2.2.2.0 is directly connected, Serial1/1
is directly connected, FastEthernet0/0
3.0.0.0/24 is subnetted, 1 subnets
S 3.3.3.0 is directly connected, Serial1/1
is directly connected, FastEthernet0/0
10.0.0.0/24 is subnetted, 2 subnets
S 10.1.2.0 is directly connected, Serial1/1
R2:
ip route 1.1.1.0 255.255.255.0 Serial1/0
ip route 1.1.1.0 255.255.255.0 FastEthernet0/0
ip route 3.3.3.0 255.255.255.0 Serial1/1
ip route 3.3.3.0 255.255.255.0 FastEthernet0/0
R2# show ip route static
1.0.0.0/24 is subnetted, 1 subnets
S 1.1.1.0 is directly connected, Serial1/0
is directly connected, FastEthernet0/0
3.0.0.0/24 is subnetted, 1 subnets
S 3.3.3.0 is directly connected, Serial1/1
is directly connected, FastEthernet0/0
R3:
ip route 1.1.1.0 255.255.255.0 Serial1/0
ip route 1.1.1.0 255.255.255.0 FastEthernet0/0
ip route 2.2.2.0 255.255.255.0 Serial1/0
ip route 2.2.2.0 255.255.255.0 FastEthernet0/0
ip route 10.1.1.0 255.255.255.0 Serial1/0
R3#show ip route static
1.0.0.0/24 is subnetted, 1 subnets
S 1.1.1.0 is directly connected, Serial1/0
is directly connected, FastEthernet0/0
2.0.0.0/24 is subnetted, 1 subnets
S 2.2.2.0 is directly connected, Serial1/0
is directly connected, FastEthernet0/0
10.0.0.0/24 is subnetted, 2 subnets
S 10.1.1.0 is directly connected, Serial1/0
欢迎关注和转发,专栏更多详细完整网络技术讲解,欢迎大家阅读学习!