最近客户新加了条电信的线路(之前是使用联通的),需要做双线路负载均衡,访问联通网站时走联通线路,默认时走电信线路。在这里随便复习一下在cisco路由器上实现该功能,如下图:
Eg:
拓扑描述:R3是公司路由器F0/1接内网,NAT内部地址上外网;R1,R4模拟电信外部网络;R2,R5模拟联通外部网络。
R3接口基本配置:
interface FastEthernet0/1
ip address 192.168.1.1 255.255.255.0
description R1 LAN
ip nat inside
interface FastEthernet1/1
ip address 21.21.21.1 255.255.255.0
description R1---->ISP1
ip nat outside
interface FastEthernet1/0
ip address 12.12.12.1 255.255.255.0
description R1---->ISP1
ip nat outside
======================================
R1接口配置:
interface FastEthernet1/0
ip address 12.12.12.2 255.255.255.0
interface FastEthernet1/1
ip address 14.14.14.1 255.255.255.0
=======================================
R2接口配置:
interface FastEthernet1/0
ip address 21.21.21.2 255.255.255.0
interface FastEthernet1/1
ip address 25.25.25.1 255.255.255.0
========================================
1.配置NAT列表:
access-list 100 permit ip 192.168.1.0 0.0.0.255 any
2. 配置动态地址池:
ip nat pool isp1 12.12.12.1 12.12.12.1 netmask 255.255.255.0
ip nat pool isp2 21.21.21.1 21.21.21.1 netmask 255.255.255.0
3. 配置路由策略 :
route-map isp2 permit 1
match ip address 100
match interface FastEthernet1/0
route-map isp1 permit 1
match ip address 100
match interface FastEthernet1/1
4.配置IP SLA:
ip sla 1
icmp-echo 12.12.12.2 source-ip 12.12.12.1
frequency 20
ip sla schedule 1 life forever start-time now
ip sla 2
icmp-echo 21.21.21.2 source-ip 21.21.21.1
frequency 20
ip sla schedule 2 life forever start-time now
track 10 ip sla 1 reachability
track 20 ip sla 2 reachability
5. 映射NAT列表:
ip nat inside source route-map isp1 pool isp1 overload
ip nat inside source route-map isp2 pool isp2 overload
6. 配置路由:
ip route 0.0.0.0 0.0.0.0 12.12.12.2 track 10
ip route 0.0.0.0 0.0.0.0 21.21.21.2 track 20--------配合sla实现双线路冗余,默认配置下cisco路由器是基于目标地址负载均衡
ip route 25.25.25.0 255.255.255.0 21.21.21.2--------实现访问联通网络时从联通线路出外网
将全国的联通地址段全部添加到静态路由表中
验证:
R3#show ip route
Gateway of last resort is 21.21.21.2 to network 0.0.0.0
21.0.0.0/24 is subnetted, 1 subnets
C 21.21.21.0 is directly connected, FastEthernet1/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, FastEthernet1/1
C 192.168.1.0/24 is directly connected, Loopback1
S* 0.0.0.0/0 [1/0] via 21.21.21.2 -----------------显示两条默认路由
[1/0] via 12.12.12.2
R3#traceroute 25.25.25.2 source 192.168.1.1
Type escape sequence to abort.
Tracing the route to 25.25.25.2
1 21.21.21.2 40 msec 76 msec 60 msec ------从联通线路出外网
2 25.25.25.2 80 msec * 76 msec
附录:联通公网IP地址列表
110.16.0.0/14
110.52.0.0/15
110.6.0.0/15
110.72.0.0/15
112.109.128.0/17
112.111.0.0/16
112.122.0.0/15
112.132.0.0/16
112.192.0.0/14
112.224.0.0/11
112.64.0.0/15
112.80.0.0/13
112.88.0.0/13
112.96.0.0/15
113.0.0.0/13
113.194.0.0/15
113.200.0.0/15
113.204.0.0/14
113.224.0.0/12
113.56.0.0/15
113.58.0.0/16
113.59.0.0/17
113.8.0.0/15
114.240.0.0/12
115.46.0.0/16
115.48.0.0/12
115.85.192.0/18
116.112.0.0/14
116.116.0.0/15
116.2.0.0/15
116.95.0.0/16
117.8.0.0/13
118.212.0.0/16
118.72.0.0/13
118.80.0.0/15
119.108.0.0/15
119.112.0.0/13
119.162.0.0/15
119.164.0.0/14
119.176.0.0/12
119.248.0.0/14
119.36.0.0/16
119.39.0.0/16
119.4.0.0/14
119.48.0.0/13
119.62.0.0/16
120.0.0.0/12
120.80.0.0/13
121.16.0.0/13
121.24.0.0/14
121.28.0.0/15
121.30.0.0/16
121.31.0.0/16
122.136.0.0/13
122.156.0.0/14
122.192.0.0/14
122.96.0.0/15
123.112.0.0/12
123.128.0.0/13
123.138.0.0/15
123.144.0.0/14
123.148.0.0/16
123.152.0.0/13
123.188.0.0/14
123.232.0.0/14
123.4.0.0/14
123.8.0.0/13
124.128.0.0/13
124.160.0.0/16
124.161.0.0/16
124.162.0.0/16
124.163.0.0/16
124.164.0.0/14
124.64.0.0/15
124.66.0.0/17
124.67.0.0/16
124.88.0.0/16
124.89.0.0/17
124.89.128.0/17
124.90.0.0/15
124.92.0.0/14
125.211.0.0/16
125.32.0.0/16
125.33.0.0/16
125.34.0.0/16
125.35.0.0/17
125.35.128.0/17
125.36.0.0/14
125.40.0.0/13
175.42.0.0/15
202.102.128.0/21
202.102.136.0/21
202.102.144.0/20
202.102.224.0/21
202.102.232.0/21
202.102.240.0/20
202.106.0.0/16
202.107.0.0/17
202.108.0.0/16
202.110.0.0/18
202.110.192.0/18
202.110.64.0/18
202.111.128.0/19
202.130.224.0/19
202.38.143.0/24
202.96.0.0/18
202.96.64.0/21
202.96.72.0/21
202.96.80.0/20
202.97.128.0/18
202.97.192.0/19
202.97.224.0/21
202.97.232.0/21
202.97.240.0/20
202.98.0.0/21
202.98.8.0/21
202.99.0.0/18
202.99.104.0/21
202.99.112.0/20
202.99.128.0/19
202.99.160.0/21
202.99.168.0/21
202.99.176.0/20
202.99.192.0/21
202.99.200.0/21
202.99.208.0/20
202.99.224.0/21
202.99.232.0/21
202.99.240.0/20
202.99.64.0/19
202.99.96.0/21
203.93.192.0/18
203.93.64.0/18
203.93.8.0/24
210.13.0.0/18
210.13.128.0/17
210.13.64.0/18
210.14.160.0/19
210.14.192.0/19
210.15.128.0/18
210.15.32.0/19
210.15.96.0/19
210.21.0.0/17
210.51.0.0/16
210.52.128.0/17
210.53.0.0/17
210.53.128.0/17
210.74.128.0/19
210.74.96.0/19
210.78.0.0/19
210.78.160.0/19
210.78.192.0/18
210.82.0.0/15
211.144.0.0/15
211.90.0.0/15
211.92.0.0/15
211.94.0.0/15
211.96.0.0/15
218.10.0.0/16
218.104.0.0/17
218.104.128.0/19
218.104.160.0/19
218.104.192.0/21
218.104.200.0/21
218.104.208.0/20
218.104.224.0/19
218.105.0.0/16
218.106.0.0/15
218.11.0.0/16
218.12.0.0/16
218.21.128.0/17
218.24.0.0/15
218.26.0.0/16
218.27.0.0/16
218.28.0.0/15
218.56.0.0/14
218.60.0.0/15
218.67.128.0/17
218.68.0.0/15
218.7.0.0/16
218.8.0.0/15
219.154.0.0/15
219.156.0.0/15
219.158.0.0/17
219.158.128.0/17
219.159.0.0/18
220.192.0.0/15
220.194.0.0/15
220.196.0.0/14
220.200.0.0/13
220.248.0.0/14
220.252.0.0/16
221.0.0.0/15
221.10.0.0/16
221.11.0.0/17
221.11.128.0/18
221.11.192.0/19
221.11.224.0/19
221.12.0.0/17
221.12.128.0/18
221.13.0.0/18
221.13.128.0/17
221.13.64.0/19
221.13.96.0/19
221.14.0.0/15
221.192.0.0/15
221.194.0.0/16
221.195.0.0/16
221.196.0.0/15
221.198.0.0/16
221.199.0.0/19
221.199.128.0/18
221.199.192.0/20
221.199.224.0/19
221.199.32.0/20
221.199.48.0/20
221.199.64.0/18
221.2.0.0/16
221.200.0.0/14
221.204.0.0/15
221.206.0.0/16
221.207.0.0/18
221.207.128.0/17
221.207.64.0/18
221.208.0.0/14
221.212.0.0/16
221.213.0.0/16
221.214.0.0/15
221.216.0.0/13
221.3.0.0/17
221.3.128.0/17
221.4.0.0/16
221.5.0.0/17
221.5.128.0/17
221.6.0.0/16
221.7.0.0/19
221.7.128.0/17
221.7.32.0/19
221.7.64.0/19
221.7.96.0/19
221.8.0.0/15
222.128.0.0/14
222.132.0.0/14
222.136.0.0/13
222.160.0.0/15
222.162.0.0/16
222.163.0.0/19
222.163.128.0/17
222.163.32.0/19
222.163.64.0/18
58.144.0.0/16
58.16.0.0/16
58.17.0.0/17
58.17.128.0/17
58.18.0.0/16
58.19.0.0/16
58.20.0.0/16
58.21.0.0/16
58.22.0.0/15
58.240.0.0/15
58.242.0.0/15
58.244.0.0/15
58.246.0.0/15
58.248.0.0/13
60.0.0.0/13
60.10.0.0/16
60.11.0.0/16
60.12.0.0/16
60.13.0.0/18
60.13.128.0/17
60.13.64.0/18
60.14.0.0/15
60.16.0.0/13
60.208.0.0/13
60.216.0.0/15
60.218.0.0/15
60.220.0.0/14
60.24.0.0/14
60.28.0.0/15
60.30.0.0/16
60.31.0.0/16
60.8.0.0/15
61.133.0.0/17
61.134.128.0/18
61.134.192.0/18
61.134.96.0/19
61.135.0.0/16
61.136.0.0/18
61.136.64.0/18
61.137.128.0/17
61.138.0.0/18
61.138.128.0/18
61.138.64.0/18
61.139.128.0/18
61.148.0.0/15
61.156.0.0/16
61.158.0.0/17
61.158.128.0/17
61.159.0.0/18
61.161.0.0/18
61.161.128.0/17
61.162.0.0/16
61.163.0.0/16
61.167.0.0/16
61.168.0.0/16
61.176.0.0/16
61.179.0.0/16
61.180.128.0/17
61.181.0.0/16
61.182.0.0/16
61.189.0.0/17
61.240.0.0/14
61.48.0.0/14
61.52.0.0/15
61.54.0.0/16
61.55.0.0/16