静态路由配置(Static Routing)
1.按照试验拓扑,配置好路由器的各个接口IP;
2.使用ping命令验证路由器之间的连同性,以R1为例:
r1#ping 10.3.3.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.2, timeout is 2 seconds:
!!!!!
再用R1 ping R2的loopback和R3的ip:Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.2, timeout is 2 seconds:
!!!!!
r1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
略......
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
略......
3.下面在3台路由器上使用命令ip route添加相应的静态路由:
r1(config)#ip route 192.168.1.0 255.255.255.0 10.3.3.2 //设置静态路由到
r1(config)#ip route 172.16.3.0 255.255.255.0 10.3.3.2
r1(config)#ip route 172.16.1.0 255.255.255.0 10.3.3.2
r1(config)#ip route 172.16.2.0 255.255.255.224 10.3.3.2
r2(config)#ip route 10.1.1.0 255.255.255.0 10.3.3.1
r2(config)#ip route 10.2.2.0 255.255.255.224 10.3.3.1
r2(config)#ip route 172.16.1.0 255.255.255.0 172.16.3.1
r2(config)#ip route 172.16.2.0 255.255.255.224 172.16.3.1
r3(config)#ip route 192.168.1.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.3.3.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.1.1.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.2.2.0 255.255.255.224 172.16.3.2
r1(config)#ip route 172.16.1.0 255.255.255.0 10.3.3.2
r1(config)#ip route 172.16.2.0 255.255.255.224 10.3.3.2
r2(config)#ip route 10.1.1.0 255.255.255.0 10.3.3.1
r2(config)#ip route 10.2.2.0 255.255.255.224 10.3.3.1
r2(config)#ip route 172.16.1.0 255.255.255.0 172.16.3.1
r2(config)#ip route 172.16.2.0 255.255.255.224 172.16.3.1
r3(config)#ip route 192.168.1.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.3.3.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.1.1.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.2.2.0 255.255.255.224 172.16.3.2
r1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
查看一下R1的路由表:
r1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 10.3.3.2
S 172.16.2.0/27 [1/0] via 10.3.3.2
S 172.16.3.0/24 [1/0] via 10.3.3.2
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C 10.3.3.0/24 is directly connected, Serial1/1
C 10.2.2.0/27 is directly connected, Loopback1
C 10.1.1.0/24 is directly connected, Loopback0
S 192.168.1.0/24 [1/0] via 10.3.3.2
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
S 172.16.1.0/24 [1/0] via 10.3.3.2
S 172.16.2.0/27 [1/0] via 10.3.3.2
S 172.16.3.0/24 [1/0] via 10.3.3.2
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C 10.3.3.0/24 is directly connected, Serial1/1
C 10.2.2.0/27 is directly connected, Loopback1
C 10.1.1.0/24 is directly connected, Loopback0
S 192.168.1.0/24 [1/0] via 10.3.3.2
总结:其实如果路由器属于末梢节点的话,可以只用一条默认路由也可以实现上面的效果,例如R1:(企业上网常采用的默认路由)
r1(config)#ip route 0.0.0.0 0.0.0.0 10.3.3.2
这样也可以ping通其余的ip地址。
OK,试验完!
注:
show run
show ip route 查本台路由器路由表
show ip interface bri 查本台路由器接口状态
Loopback 0 虚拟接口
总结:
建立起经过各个网段的下一跳地址(出口)的路由表
Ewin:梦想可以到达的地方,网络就可以做到-开放、平等、自由、充满激情......