实验目的:
利用静态路由实现的负载均衡,理解负载均衡中数据传输的过程.
实验拓扑图:
路由器上的配置:
R1 上的配置:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
粘贴上路由器的基本命令
Router(config)#enable password cisco
Router(config)#no ip domain-lookup
Router(config)#line con 0
Router(config-line)# exec-timeout 0 0
Router(config-line)# logging synchronous
Router(config-line)#
Router(config-line)#line aux 0
Router(config-line)# exec-timeout 0 0
Router(config-line)# logging synchronous
Router(config-line)#line vty 0 4
Router(config-line)#
Router(config-line)#
Router(config-line)# exec-timeout 0 0
Router(config-line)# password cisco
Router(config-line)#
Router(config-line)# login
Router(config-line)#
Router(config-line)#
Router(config-line)#alias exec a sh ip int bri
Router(config)#alias exec b sh ip route
Router(config)#alias exec c sh ip route rip
Router(config)#alias exec d sh run
Router(config)#hostname R1
设置环回测试接口,环回测试的主要意义在于这种接口由于是逻辑存在,所以这种接口永远也不会被shutdown.一般用来作测试和定义路由ID中使用.
R1(config)#interface loopback 0,
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#interface e0/0
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface s1/0
R1(config-if)#ip address 172.16.2.1 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown
R1(config-if)#exit
R2的配置:
Router(config)#hostname R2
R2(config)#interface s1/0
R2(config-if)#ip address 172.16.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface s1/1
R2(config-if)#ip address 172.16.3.1 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
R2(config-if)#exit
R3的配置:
Router(config)#hostname R3
R3(config)#interface e0/0
R3(config-if)#ip address 172.16.1.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#interface s1/1
R3(config-if)#ip address 172.16.3.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface loopback 0
R3(config-if)#ip address 4.4.4.4 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
好了,配置好了上面的这些之后就可以进行验证了.
首先在路由器上设置去往R3的包的路径:
R1上的,直接通过静态路由来实现
R1(config)#ip route 4.4.4.0 255.255.255.0 172.16.1.2
再利用默认路由设置R3到R1的回包路径
R2(config)#ip route 0.0.0.0 0.0.0.0 172.16.2.1
R3(config)#ip route 0.0.0.0 0.0.0.0 172.16.3.1
在这里验证负载均衡.
用扩展的ping命令
R1#ping
Protocol [ip]:
Target IP address: 4.4.4.4
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 1.1.1.1
Type of service [0]: .
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]: r
Number of hops [ 9 ]:
Loose, Strict, Record, Timestamp, Verbose[RV]: r
% No room for that option
Loose, Strict, Record, Timestamp, Verbose[RV]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
Packet has IP options: Total option bytes= 39, padded length=40
Record route: <*>
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
Reply to request 0 (112 ms). Received packet has options
Total option bytes= 40, padded length=40
Record route:
(172.16.1.1)
(4.4.4.4)
(172.16.3.2)
(172.16.2.2)
(1.1.1.1) <*>
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
End of list
Reply to request 1 (184 ms). Received packet has options
Total option bytes= 40, padded length=40
Record route:
(172.16.1.1)
(4.4.4.4)
(172.16.3.2)
(172.16.2.2)
(1.1.1.1) <*>
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
End of list
Reply to request 2 (136 ms). Received packet has options
Total option bytes= 40, padded length=40
Record route:
(172.16.1.1)
(4.4.4.4)
(172.16.3.2)
(172.16.2.2)
(1.1.1.1) <*>
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
End of list
Reply to request 3 (136 ms). Received packet has options
Total option bytes= 40, padded length=40
Record route:
(172.16.1.1)
(4.4.4.4)
(172.16.3.2)
(172.16.2.2)
(1.1.1.1) <*>
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
End of list
Reply to request 4 (136 ms). Received packet has options
Total option bytes= 40, padded length=40
Record route:
(172.16.1.1)
(4.4.4.4)
(172.16.3.2)
(172.16.2.2)
(1.1.1.1) <*>
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
(0.0.0.0)
End of list
Success rate is 100 percent (5/5), round-trip min/avg/max = 112/140/184 ms
R1#
通过观察可以看到通过扩展ping命令发现ICMP包去回的路径是不同的这样就实现的了负载均衡.
本文转自 独钩寒江雪 51CTO博客,原文链接:http://blog.51cto.com/bennie/100612,如需转载请自行联系原作者