CCNA静态路由_第1张图片

1.带下一跳的静态路由:

-----------------------R1----------------------------
R1(config)#ip route 2.2.2.0 255.255.255.0 12.1.1.2
R1(config)#ip route 23.1.1.0 255.255.255.0 12.1.1.2  
R1(config)#ip route 3.3.3.0 255.255.255.0 12.1.1.2 
 
----------------------R2-----------------------------
R2(config)#ip route 1.1.1.0 255.255.255.0 12.1.1.1 
R2(config)#ip route 3.3.3.0 255.255.255.0 23.1.1.3
 
----------------------R3-----------------------------
R3(config)#ip route 1.1.1.0 255.255.255.0 23.1.1.2
R3(config)#ip route 12.1.1.0 255.255.255.0 23.1.1.2
R3(config)#ip route 2.2.2.0 255.255.255.0 23.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:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/60/64 ms
 
R2#ping 1.1.1.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
 
R2#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:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
 
R3#ping 1.1.1.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/61/68 ms
R3#ping 2.2.2.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 m
========================================================================
2. 汇总的实现:
R2(config)#int looPback 0
R2(config-if)#ip add 2.2.1.2 255.255.255.0 secondary 
 
R1(config)#no  ip route 2.2.2.0 255.255.255.0 12.1.1.2
R1(config)#ip route 2.2.0.0 255.255.252.0 12.1.1.2//手动配置汇总
 
验证:
R1#ping 2.2.1.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
R1#ping 2.2.2.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/34/36 ms
========================================================================
3.浮动静态路由的配置:
 
R1(config)#ip route 2.2.0.0 255.255.252.0 10.1.1.2//还没有修改管理距离值。
R1#show ip route static
     2.0.0.0/22 is subnetted, 1 subnets
S       2.2.0.0 [1/0] via 12.1.1.2
                [1/0] via 10.1.1.2
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [1/0] via 12.1.1.2
     23.0.0.0/24 is subnetted, 1 subnets
S       23.1.1.0 [1/0] via 12.1.1.2
R1(config)#ip route 2.2.0.0 255.255.252.0 10.1.1.2 100//把管理距离值改位100,默认情况下为1.
R1#show ip route static 
     2.0.0.0/22 is subnetted, 1 subnets
S       2.2.0.0 [1/0] via 12.1.1.2
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [1/0] via 12.1.1.2
     23.0.0.0/24 is subnetted, 1 subnets
S       23.1.1.0 [1/0] via 12.1.1.2
*没有显示10.1.1.0网段的信息。
当把串口网段关闭以后,我们再来看看:
R1#show ip route static 
     2.0.0.0/22 is subnetted, 1 subnets
S       2.2.0.0 [100/0] via 10.1.1.2
*这时以太网网段浮了起来,实现浮动静态路由。
========================================================================
4.带送出接口的静态路由:
R1(config)#ip route 2.2.0.0 255.255.252.0 e0
R1(config)#ip route 23.1.1.0 255.255.255.0 e0
R1(config)#ip route 3.3.3.0 255.255.255.0 e0 
 
R2(config)#ip route 1.1.1.0 255.255.255.0 e0
R2(config)#ip route 3.3.3.0 255.255.255.0 s1
 
R3(config)#ip route 1.1.1.0 255.255.255.0 s0
R3(config)#ip route 10.1.1.0 255.255.255.0 s0
R3(config)#ip route 2.2.0.0 255.255.252.0 s0 
 
1)验证:
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:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 32/33/36 ms
 
R1#ping 2.2.2.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 4/5/8 ms
 
2)以太网的带送出接口需要代理arp的协助,不然无法实现:
R1#debug arp
ARP 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:
 
*Mar  1 01:08:48.175: IP ARP: creating incomplete entry for IP address: 3.3.3.3 interface Ethernet0
*Mar  1 01:08:48.179: IP ARP: sent req src 10.1.1.1 0000.0c91.7df5,
                 dst 3.3.3.3 0000.0000.0000 Ethernet0
*Mar  1 01:08:48.191: IP ARP: rcvd rep src 3.3.3.3 00e0.1e68.1b5b, dst 10.1.1.1 Ethernet0.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 32/40/48 ms
 
R1#show arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  3.3.3.3                 1   00e0.1e68.1b5b  ARPA   Ethernet0
Internet  10.1.1.1                -   0000.0c91.7df5  ARPA   Ethernet0
 
 
R2#show int e0
Ethernet0 is up, line protocol is up 
  Hardware is Lance, address is 00e0.1e68.1b5b (bia 00e0.1e68.1b5b)
*R2代理转发3.3.3.3的数据。
当关闭代理arp的功能以后,将无法转发数据:
R2(config)#int e0
R2(config-if)#no ip proxy-arp //关闭代理arp的功能。
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:
 
*Mar  1 01:12:54.479: IP ARP: creating incomplete entry for IP address: 3.3.3.3 interface Ethernet0
*Mar  1 01:12:54.483: IP ARP: sent req src 10.1.1.1 0000.0c91.7df5,
                 dst 3.3.3.3 0000.0000.0000 Ethernet0.
*Mar  1 01:12:56.479: IP ARP: sent req src 10.1.1.1 0000.0c91.7df5,
                 dst 3.3.3.3 0000.0000.0000 Ethernet0.
*Mar  1 01:12:58.479: IP ARP: sent req src 10.1.1.1 0000.0c91.7df5,
                 dst 3.3.3.3 0000.0000.0000 Ethernet0.
*Mar  1 01:13:00.479: IP ARP: sent req src 10.1.1.1 0000.0c91.7df5,
                 dst 3.3.3.3 0000.0000.0000 Ethernet0.
*Mar  1 01:13:02.479: IP ARP: sent req src 10.1.1.1 0000.0c91.7df5,
                 dst 3.3.3.3 0000.0000.0000 Ethernet0.
Success rate is 0 percent (0/5)
*无法学习到mac地址,和无法转发数据。
3)下面我们来看看串口的带送出接口的静态路由:
R1(config)#ip route 2.2.0.0 255.255.252.0 s0
R1(config)#ip route 3.3.3.0 255.255.255.0 s0
R1(config)#ip route 23.1.1.0 255.255.255.0 s0
R2(config)#ip route 1.1.1.0 255.255.255.0 s0
R3(config)#ip route 12.1.1.0 255.255.255.0 s0
我们把R2的代理arp功能关闭,并且把e0口shutdown以后再来验证一下:
R2(config)#int s0
R2(config-if)#no ip PROxy-arp
 
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:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/60/60 ms
*串口是不需要代理arp的协助的,因为串口是点对点的链路,而且串口是没有mac地址的。
========================================================================5.实现负载均衡:
R1#show ip route static 
     2.0.0.0/22 is subnetted, 1 subnets
S       2.2.0.0 is directly connected, Serial0
                is directly connected, Ethernet0
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 is directly connected, Serial0
                is directly connected, Ethernet0
     23.0.0.0/24 is subnetted, 1 subnets
S       23.1.1.0 is directly connected, Serial0
                 is directly connected, Ethernet0
 
每个网段都有两条路径,要走哪条路径,关键是看路由器的转发的功能。
 
R1#traceroute 3.3.3.3  //跟踪路由转发的路径。
Type escape sequence to abort.
Tracing the route to 3.3.3.3
 
  1  * 
    12.1.1.2 16 msec * 
  2 23.1.1.3 40 msec *  28 msec
===========================================================================================================
6.默认路由的配置:
R1(config)#ip  route 0.0.0.0 0.0.0.0 s0 //无路可走的时候才会使用到的路由。
R1#debug ip packet 
IP packet debugging is on
R1#ping 3.3.3.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.8, timeout is 2 seconds:
 
*Mar  1 01:43:22.979: IP: tableid=0, s=12.1.1.1 (local), d=3.3.3.8 (Serial0), routed via RIB
*Mar  1 01:43:22.983: IP: s=12.1.1.1 (local), d=3.3.3.8 (Serial0), len 100, sending.
*Mar  1 01:43:24.979: IP: tableid=0, s=12.1.1.1 (local), d=3.3.3.8 (Serial0), routed via RIB
*Mar  1 01:43:24.983: IP: s=12.1.1.1 (local), d=3.3.3.8 (Serial0), len 100, sending.
*Mar  1 01:43:26.979: IP: tableid=0, s=12.1.1.1 (local), d=3.3.3.8 (Serial0), routed via RIB
*Mar  1 01:43:26.983: IP: s=12.1.1.1 (local), d=3.3.3.8 (Serial0), len 100, sending.
*Mar  1 01:43:28.979: IP: tableid=0, s=12.1.1.1 (local), d=3.3.3.8 (Serial0), routed via RIB
*Mar  1 01:43:28.983: IP: s=12.1.1.1 (local), d=3.3.3.8 (Serial0), len 100, sending.
*Mar  1 01:43:30.979: IP: tableid=0, s=12.1.1.1 (local), d=3.3.3.8 (Serial0), routed via RIB
*Mar  1 01:43:30.983: IP: s=12.1.1.1 (local), d=3.3.3.8 (Serial0), len 100, sending.
R1#show ip route static
     2.0.0.0/22 is subnetted, 1 subnets
S       2.2.0.0 is directly connected, Serial0
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 is directly connected, Serial0
     23.0.0.0/24 is subnetted, 1 subnets
S       23.1.1.0 is directly connected, Serial0
S*   0.0.0.0/0 is directly connected, Serial0//缺省路由
===========================================================================================================
7.各种静态路由的优先级别的比较:
5、各种静态路由的优先级别:
   1)正常的静态路由  
   2)带送出接口的
   3)主机路由
   4)缺省路由
   5)汇总路由
R1(config)#ip route 2.2.0.0 255.255.252.0 12.1.1.2 //汇总的路由
R1(config)#ip route 2.2.2.2 255.255.255.255 12.1.1.2 //主机路由
R1(config)#ip route 2.2.0.0 255.255.252.0 s0  //带送出接口的路由
R1(config)#ip  route 0.0.0.0 0.0.0.0 s0 //缺省的路由
R1(config)#ip route 2.2.2.0 255.255.255.0 12.1.1.2//正常的带下一跳的路由
拿R1和R2来做比较优先级:
R1#show ip route static 
S*   0.0.0.0/0 is directly connected, Serial0
R1#traceroute 2.2.2.2
Type escape sequence to abort.
Tracing the route to 2.2.2.2
  1 12.1.1.2 20 msec *  16 msec
R1(config)#ip route 2.2.2.0 255.255.255.0 10.1.1.2 //配置正常的带下一跳的路由
R1#traceroute 2.2.2.2
Type escape sequence to abort.
Tracing the route to 2.2.2.2
 
  1 10.1.1.2 4 msec *  4 msec
*带一下跳的路由优于缺省路由。
R1(config)#ip route 2.2.0.0 255.255.255.0 12.1.1.2//配置汇总路由
R1#traceroute 2.2.2.2
 
Type escape sequence to abort.
Tracing the route to 2.2.2.2
 
  1 10.1.1.2 8 msec *  4 msec
*带下一跳的路由优于汇总路由
R1(config)#ip route 2.2.2.2 255.255.255.255 12.1.1.2 //配置主机路由
R1#traceroute 2.2.2.2
 
Type escape sequence to abort.
Tracing the route to 2.2.2.2
 
  1 12.1.1.2 20 msec *  16 msec
*主机路由优于带下一跳的路由
R1(config)#ip route 2.2.2.0 255.255.255.0 e0//
R1#traceroute 2.2.2.2
 
Type escape sequence to abort.
Tracing the route to 2.2.2.2
 
  1 12.1.1.2 16 msec *  16 msec
*主机路由优于带送出接口的路由。