Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1513605
  • 博文数量: 416
  • 博客积分: 10061
  • 博客等级: 上将
  • 技术积分: 3287
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-05 11:12
个人简介

技术在于专研

文章分类

全部博文(416)

文章存档

2021年(3)

2015年(34)

2013年(2)

2012年(1)

2011年(2)

2010年(5)

2007年(344)

2006年(25)

分类:

2007-02-09 14:35:01

通过NAT实现镜像服务器的负载均衡

STEP1:底层配置,定义内口外口.

R1(config)#int s2/1

R1(config-if)#ip ad 12.0.0.2 255.255.255.0

R1(config-if)#no sh

R1(config-if)#int f0

R1(config-if)#int f0/0

R1(config-if)#ip ad 10.0.0.1 255.255.255.0

R1(config-if)#no ip proxy-arp

R1(config-if)#no sh

R1(config-if)#do ping 10.0.0.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.0.0.2, timeout is 2 seconds:

..!!!

Success rate is 60 percent (3/5), round-trip min/avg/max = 120/130/144 ms

R1(config-if)#do ping 10.0.0.3

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.0.0.3, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 64/96/112 ms

R1(config-if)#exit

R1(config)#int s2/1

R1(config-if)#ip nat outside

R1(config-if)#int f0/0

R1(config-if)#ip nat inside

 

 

 

R2(config-line)#int s2/1

R2(config-if)#ip ad 12.0.0.1 255.255.255.0

R2(config-if)#no sh

R2(config-if)#int s2/2

R2(config-if)#ip ad 23.0.0.1 255.255.255.0

R2(config-if)#no sh

R2(config-if)#do ping 12.0.0.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 12.0.0.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/183/324 ms

R2(config-if)#do ping 23.0.0.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 23.0.0.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 64/148/232 ms

 

 

R3(config-line)#int s2/1

R3(config-if)#ip ad 23.0.0.2 255.255.255.0

R3(config-if)#no sh

 

 

STEP2:通过ACL定义本地的公网地址,作为来自外部访问的目标地址

R1(config)#access-list 1 permit 12.0.0.5  //定义进行转换后的目的地址,外部直接访问的地址

STEP3:定义内网的服务器地址池

R1(config)#ip nat pool serer 10.0.0.2 10.0.0.3 prefix-length 24 type rotary  //定义外网访问的内网地址池的范围,并起一个池的名字,type rotay定义了自动负载均衡

STEP4:作基于目的地的转换.

R1(config)#ip nat inside destination list 1 pool serer  //为内部目的地址应用到NAT,以使外部能顺利访问本地服务

 

R1上看一下是否已经做成镜像

R1#sho ip access

Standard IP access list 1

    permit 12.0.0.5

 

 

R3TELNET测试一下看是否已经配置成功

R3#telnet 12.0.0.5

Trying 12.0.0.5 ... Open

 

 

User Access Verification

 

Password:

Serer2>

 

R1#debug ip nat

IP NAT debugging is on

R1#

00:46:33: NAT: s=23.0.0.2, d=12.0.0.5->10.0.0.3 [40625]

00:46:34: NAT: s=10.0.0.3->12.0.0.5, d=23.0.0.2 [3852]

00:46:34: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.3 [40626]

00:46:34: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.3 [40627]

00:46:34: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.3 [40628]

00:46:34: NAT*: s=10.0.0.3->12.0.0.5, d=23.0.0.2 [3853]

00:46:34: NAT*: s=10.0.0.3->12.0.0.5, d=23.0.0.2 [3854]

00:46:34: NAT*: s=10.0.0.3->12.0.0.5, d=23.0.0.2 [3855

 

R3#telnet 12.0.0.5

Trying 12.0.0.5 ... Open

 

 

User Access Verification

 

Password:

Serer1>

 

R1#

00:47:15: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.2 [13898]

00:47:15: NAT*: s=10.0.0.2->12.0.0.5, d=23.0.0.2 [50115]

00:47:15: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.2 [13899]

00:47:15: NAT*: s=10.0.0.2->12.0.0.5, d=23.0.0.2 [50116]

00:47:16: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.2 [13900]

00:47:16: NAT*: s=23.0.0.2, d=12.0.0.5->10.0.0.2 [13901]

00:47:16: NAT*: s=10.0.0.2->12.0.0.5, d=23.0.0.2 [50117]

00:47:16: NAT*: s=10.0.0.2->12.0.0.5, d=23.0.0.2 [50118]

从测试的结果看通过NAT已经成功实现镜像服务器的负载均衡.

 

 

R1的配置

R1#sh ru

Building configuration...

 

Current configuration : 1347 bytes

!

version 12.1

service timestamps debug uptime

service timestamps log uptime

no service password-encryption

!

hostname R1

!

ip subnet-zero

ip cef

!

no ip domain-lookup

!

ip audit notify log

ip audit po max-events 100

ip ssh time-out 120

ip ssh authentication-retries 3

!

interface FastEthernet0/0

 ip address 10.0.0.1 255.255.255.0

 no ip proxy-arp            //关闭代理ARP

 ip nat inside               //定义内网口

 duplex half

!

interface Serial2/0

 no ip address

 shutdown

 serial restart-delay 0

!

interface Serial2/1

 ip address 12.0.0.2 255.255.255.0

 ip nat outside              //定义的外网口

 serial restart-delay 0

!

interface Serial2/2

 no ip address

 shutdown

 serial restart-delay 0

!

interface Serial2/3

 no ip address

 shutdown

 serial restart-delay 0

!

interface Serial3/0

 no ip address

 shutdown

 serial restart-delay 0

!

interface Serial3/1

 no ip address

 shutdown

 serial restart-delay 0

!

interface Serial3/2

 no ip address

 shutdown

 serial restart-delay 0

!

interface Serial3/3

 no ip address

 shutdown

 serial restart-delay 0

!

ip nat pool serer 10.0.0.2 10.0.0.3 prefix-length 24 type rotary  //定义将进行自动负载均衡的内网地址

ip nat inside destination list 1 pool serer  //把内部地址应用到NAT,以使外网能正常访问

ip classless

ip route 0.0.0.0 0.0.0.0 Serial2/1         //默认路由条目

no ip http server

no ip http secure-server

!

access-list 1 permit 12.0.0.5            //外网将要访问的本地外网地址

!

line con 0

 exec-timeout 0 0

 password cisco

 logging synchronous

 stopbits 1

line aux 0

 stopbits 1

line vty 5 15

!

      

end

 

阅读(987) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~