您的位置:首页 > 其它

nat的双线接入负载均衡与虚拟服务器(发布服务器)

2010-08-02 16:14 483 查看
nat的双线接入负载均衡与虚拟服务器(发布服务器)
公司为了快速可靠的访问外网,分别在网通和电信购买了公网地址。要求:正常情况下网络实现等路径负载均衡,若网通/电信的连接出现问题,则公司内部通过正常的线路访问外网,不会造成网络不同!
********************************************************
模拟网络环境:依据拓扑结构环境,在r1,r3上配置默认路由,让r1和r3可以相互通信(这就等于实际公司用两条线拨号上网);现在我们就可以完成关于双接入的负载均衡.
配置思路:
这里我们通过acl、route-map和nat配合实现!
当路由的接口接到数据包时会做一下处理(如图示):



网络拓扑结构:



配置方法:
1) 配置端口ip地址(依据拓扑结构)
2) 配置默认路由
ip route 0.0.0.0 0.0.0.0 10.0.0.1
ip route 0.0.0.0 0.0.0.0 20.0.0.1
3) 配置acl访问控制列表

Router(config)#access-list 100 permit ip host 192.168.1.2 any
Router(config)#access-list 101 permit ip host 192.168.1.3 any //配置ACl规则
注:用acl规则过滤不同的主机,使不同主机经过不同的外网接口访问外网,以实现负载均衡.
4) 配置路由策略(route-map)

Router(config)#route-map goutao permit 10 //定义路由策略并指定其优先级
Router(config-route-map)#match ip address 100 //匹配定义的acl
Router(config-route-map)#match interface Ethernet0/1 //匹配端口(是否为up状态)
Router(config-route-map)#set ip next-hop 20.0.0.1 //如果匹配以上条件指定下一跳地址为 20.0.0.1
Router(config)#route-map goutao permit 20
Router(config-route-map)#match ip address 101
Router(config-route-map)#match interface Ethernet0/2
Router(config-route-map)#set ip next-hop 10.0.0.1
Router(config)#route-map isp2 permit 10
Router(config-route-map)#match ip address 100
Router(config-route-map)#match interface Ethernet0/2
Router(config)#route-map isp3 permit 10
Router(config-route-map)#match ip address 101
Router(config-route-map)#match interface Ethernet0/2
Router(config)#route-map isp1 permit 10
Router(config-route-map)#match ip address 100
Router(config-route-map)#match interface Ethernet0/1
Router(config)#route-map isp4 permit 10
Router(config-route-map)#match ip address 101
Router(config-route-map)#match interface Ethernet0/1
注:配置route-map并定义规则.

5) 关联route-map配置nat规则
Router(config)#ip nat inside source route-map isp1 interface Ethernet0/1 overload // 定义nat规则
Router(config)#ip nat inside source route-map isp2 interface Ethernet0/2 overload
Router(config)#ip nat inside source route-map isp3 interface Ethernet0/2 overload
Router(config)#ip nat inside source route-map isp4 interface Ethernet0/1 overload
注:对照路由策略route-map{isp1/isp2/isp3/isp4},决定数据使用哪个端口的公网地址作为源地址
Router(config)#ip nat inside source static tcp 192.168.1.2 80 20.0.0.2 80 //当外网访问网关服务器的80端口时,则会被转到内部局域网中的web服务器上
Router(config)#ip nat inside source static tcp 192.168.1.3 20 20.0.0.2 20
Router(config)#ip nat inside source static tcp 192.168.1.3 21 20.0.0.2 21 //当外网访问网关服务器的ftp时,则会被转到内部局域网中的ftp服务器上

6) 在内外接口上开启nat功能,内口开启路由策略(route-map)
内--->ip nat inside
内--->p policy route-map goutao
外--->ip nat outside
本文出自 “让我们一起成长!” 博客,请务必保留此出处http://goutao.blog.51cto.com/1917611/365668
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: