做属于自己公司的网站,wordpress代码主题,100款应用软件免费大全,网页开发入门7.2 浮动静态路由及负载均衡
7.2.1 原理概述
浮动静态路由(Floating Static Route)是一种特殊的静态路由#xff0c;通过配置去往相同的目的网段#xff0c;但优先级不同的静态路由#xff0c;以保证在网络中优先级较高的路由#xff0c;即主路由失效的情况下#xff0c…7.2 浮动静态路由及负载均衡
7.2.1 原理概述
浮动静态路由(Floating Static Route)是一种特殊的静态路由通过配置去往相同的目的网段但优先级不同的静态路由以保证在网络中优先级较高的路由即主路由失效的情况下提供备份路由。正常情况下备份路由不会出现在路由表中。
负载均衡(Load sharing),当数据有多条可选路径前往同一目的网络可以通过配置相同优先级和开销的静态路由实现负载均衡使得数据的传输均衡地分配到多条路径上从而实现数据分流、减轻单条路径负载过重的效果。而当其中某一条路径失效时其他路径仍然能够正常传输数据也起到了冗余作用。
7.2.2 实验内容
R2为公司总部R1与R3是两个分部pc模拟各个部门办公电脑现在需要总部与各个分部分部与分部之间都能通信且分部之间在通讯时候之间的直连链路为主用链路通过总部的链路为备份链路本实验使用浮动静态路由实现在根据实验需求实现负载均衡来优化网络。
7.2.3 实验拓扑 7.2.4 实验编址
设备接口IP地址子网掩码默认网关R1AR2220GE 0/0/0192.168.10.254255.255.255.0N/AR1AR2220Serial 1/0/0172.16.1.1255.255.255.0N/AR1AR2220Serial 1/0/1172.16.2.6255.255.255.0N/AR2AR2220GE 0/0/0192.168.30.254255.255.255.0N/AR2AR2220Serial 1/0/0172.16.1.2255.255.255.0N/AR2AR2220Serial 1/0/1172.16.3.3255.255.255.0N/AR3AR2220GE 0/0/0192.168.20.254255.255.255.0N/AR3AR2220Serial 1/0/0172.16.3.4255.255.255.0N/AR3AR2220Serial 1/0/1172.16.2.5255.255.255.0N/APC1Ethernet 0/0/1192.168.10.1255.255.255.0192.168.10.254PC2Ethernet 0/0/1192.168.20.1255.255.255.0192.168.20.254PC3Ethernet 0/0/1192.168.30.1255.255.255.0192.168.30.254
7.2.5 实验步骤
1、基本配置
根据实验编址表进行pc等的基本配置。电脑IP我就不在这里配置了。
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.10.254 24
[R1-GigabitEthernet0/0/0]interface serial 1/0/0
[R1-Serial1/0/0]ip address 172.16.1.1 24
[R1-Serial1/0/1]interface serial 1/0/1
[R1-Serial1/0/1]ip address 172.16.2.6 24[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.30.254 24
[R2-GigabitEthernet0/0/0]interface serial 1/0/0
[R2-Serial1/0/0]ip address 172.16.1.2 24
[R2-Serial1/0/0]interface serial 1/0/1
[R2-Serial1/0/1]ip address 172.16.3.3 24[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.20.254 24
[R3-GigabitEthernet0/0/0]interface serial 1/0/0
[R3-Serial1/0/0]ip address 172.16.3.4 24
[R3-Serial1/0/0]interface serial 1/0/1
[R3-Serial1/0/1]ip address 172.16.2.5 242、实现两分部间总部与两分部间的通信
在R1上配置目的网段为主机PC2所在网段的静态路由在R3上配置目的网段为PC1所在网段的静态路由在R2上配置目的网段分别为主机PC1和PC2所在网段的路由。
[R1]ip route-static 192.168.20.0 24 serial 1/0/1
[R1]ip route-static 192.168.30.0 24 serial 1/0/0[R2]ip route-static 192.168.10.0 24 serial 1/0/0
[R2]ip route-static 192.168.20.0 24 serial 1/0/1[R3]ip route-static 192.168.10.0 24 serial 1/0/1
[R3]ip route-static 192.168.30.0 24 serial 1/0/0测试pc1和pc2的连通性。
PC1ping 192.168.20.1
Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break
From 192.168.20.1: bytes32 seq1 ttl254 time47 ms
From 192.168.20.1: bytes32 seq2 ttl254 time16 ms
From 192.168.20.1: bytes32 seq3 ttl254 time31 ms
From 192.168.20.1: bytes32 seq4 ttl254 time16 ms
From 192.168.20.1: bytes32 seq5 ttl254 time15 ms
--- 192.168.20.1 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max 15/25/47 ms使用命令tracert命令测试所经过的网关。通过观察发现数据包是经过R1和R3到达主机pc2的。
PCtracert 192.168.20.1
traceroute to 192.168.20.1, 8 hops max
(ICMP), press CtrlC to stop1 192.168.10.254 16 ms 16 ms 1 ms2 172.16.2.5 31 ms 15 ms 32 ms3 192.168.20.1 15 ms 32 ms 15 ms通过总公司测试分公司也是都可以互相通信。
PCping 192.168.10.1
Ping 192.168.10.1: 32 data bytes, Press Ctrl_C to break
From 192.168.10.1: bytes32 seq1 ttl126 time16 ms
From 192.168.10.1: bytes32 seq2 ttl126 time31 msPCping 192.168.20.1
Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break
From 192.168.20.1: bytes32 seq1 ttl126 time15 ms
From 192.168.20.1: bytes32 seq2 ttl126 time31 ms3、通过浮动静态路由实现路由备份
通过上面的配置现在的网络搭建已经初步完成现需要实现当两分部间通信时直连链路为主要链路通过总部的链路为备份链路即当主要链路发生故障时可以使用备用链路来保证通信正常。现在模拟链路故障pc1是不能ping通pc2的。
PCping 192.168.20.1
Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
--- 192.168.20.1 ping statistics ---5 packet(s) transmitted0 packet(s) received100.00% packet loss在R1上配置静态路由目的网段为主机pc2所在网段掩码为24位下一跳为R2将路由优先级设置为100默认60.在R3上做相同的配置。使用display ip routing-table protocol static命令查看静态路由信息可以观察到目的地址为pc2所在网段的两条优先级为100和60的静态路由都已经存在。
[R1]ip route-static 192.168.20.0 24 serial 1/0/0 preference 100
[R3]ip route-static 192.168.10.0 24 serial 1/0/0 preference 100[R1]display ip routing-table protocol static
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : StaticDestinations : 2 Routes : 3 Configured Routes : 3
Static routing table status : ActiveDestinations : 2 Routes : 2
Destination/Mask Proto Pre Cost Flags NextHop Interface192.168.20.0/24 Static 60 0 D 172.16.2.6 Serial1/0/1192.168.30.0/24 Static 60 0 D 172.16.1.1 Serial1/0/0
Static routing table status : InactiveDestinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface192.168.20.0/24 Static 100 0 172.16.1.1 Serial1/0/0现在模拟链路故障测试pc1和pc2的连通性发现可以正常通信在使用tracert命令查看此时pc1与pc2通信时所经过的网关。
PCping 192.168.20.1
Ping 192.168.20.1: 32 data bytes, Press Ctrl_C to break
From 192.168.20.1: bytes32 seq1 ttl125 time32 ms
From 192.168.20.1: bytes32 seq2 ttl125 time15 ms
From 192.168.20.1: bytes32 seq3 ttl125 time32 ms
From 192.168.20.1: bytes32 seq4 ttl125 time31 ms
From 192.168.20.1: bytes32 seq5 ttl125 time15 msPCtracert 192.168.20.1
traceroute to 192.168.20.1, 8 hops max
(ICMP), press CtrlC to stop1 192.168.10.254 1 ms 16 ms 16 ms2 172.16.1.2 15 ms 32 ms 15 ms3 172.16.3.4 16 ms 31 ms 16 ms4 192.168.20.1 31 ms 31 ms 16 ms可以观察到经过R2到R3再次验证了此时两部门通信已经使用了备份链路。
4、通过负载均衡实现网络优化
公司网络管理员发现分部之间业务往来越来越多网络流量剧增主用链路压力非常大而总部与两分部间的网络流量相对较少即备用链路上的带宽多处在闲置状态。此时可以通过配置实现负载均衡即同时利用主备两条链路来支撑两分部间的通信。
恢复R1的1/0/1接口并配置目的网段为主机pc2所在网段掩码24位下一跳为R2优先级不变。在R3上做同样的配置。用display ip routing-table 命令查看R1上面的路由表。
[R1]interface Serial 1/0/1
[R1-Serial1/0/1]undo shutdown
[R1]ip route-static 192.168.20.0 24 serial 1/0/0
[R3]ip route-static 192.168.10.0 24 serial 1/0/0[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: PublicDestinations : 17 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0172.16.1.0/24 Direct 0 0 D 172.16.1.1 Serial1/0/0172.16.1.1/32 Direct 0 0 D 127.0.0.1 Serial1/0/0172.16.1.2/32 Direct 0 0 D 172.16.1.2 Serial1/0/0172.16.1.255/32 Direct 0 0 D 127.0.0.1 Serial1/0/0172.16.2.0/24 Direct 0 0 D 172.16.2.6 Serial1/0/1172.16.2.5/32 Direct 0 0 D 172.16.2.5 Serial1/0/1172.16.2.6/32 Direct 0 0 D 127.0.0.1 Serial1/0/1172.16.2.255/32 Direct 0 0 D 127.0.0.1 Serial1/0/1192.168.10.0/24 Direct 0 0 D 192.168.10.254 GigabitEthernet0/0/0192.168.10.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0192.168.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0192.168.20.0/24 Static 60 0 D 172.16.2.6 Serial1/0/1Static 60 0 D 172.16.1.1 Serial1/0/0192.168.30.0/24 Static 60 0 D 172.16.1.1 Serial1/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0可以看到去到192.168.20.0网段有两条下一跳不同的路由条目即实现了负载均衡。