【实验拓扑】
【实验说明】
通常情况下我们内部有多台服务器,例如Web服务器,这些服务器的地址不同,但承载的应用时相同的,如何让外部访问时实现负载均衡呢?
我们以telnet测试,R1与R6都能够被telnet。实验要让R5访问R1与R6的telnet服务时,通过NAT实现负载均衡
【实验配置】
R4:
interface Ethernet 0/0
ip nat inside
!
interface Serial 0/1
ip nat outside
!
interface Serial 0/0.1
ip nat outside
!
ip nat pool SERVERS prefix-length 24 type rotary
address 10.0.0.1 10.0.0.1
address 10.0.0.6 10.0.0.6
先定义一个pool,为内部的服务器地址范围
!
ip access-list extended INBOUND_TELNET
permit tcp any host 150.1.4.4 eq 23
定义允许的服务,和外部访问内部时被转换的地址
!
ip nat inside destination list INBOUND_TELNET pool SERVERS
设置目的地址NAT,实现负载均衡
【实验验证】
R4#show ip nat statistics
Total active translations: 3 (2 static, 1 dynamic; 1 extended)
Outside interfaces:
Serial0/0.1, Serial0/1
Inside interfaces:
FastEthernet0/0
Hits: 480 Misses: 12
CEF Translated packets: 492, CEF Punted packets: 0
Expired translations: 11
Dynamic mappings:
-- Inside Destination
[Id: 1] access-list INBOUND_TELNET pool SERVERS refcount 1
pool SERVERS: netmask 255.255.255.0
start 10.0.0.1 end 10.0.0.1
start 10.0.0.6 end 10.0.0.6
type rotary, total addresses 2, allocated 1 (50%), misses 0
Queued Packets: 0
R4#show ip nat statistics
Total active translations: 3 (2 static, 1 dynamic; 1 extended)
Outside interfaces:
Serial0/0.1, Serial0/1
Inside interfaces:
FastEthernet0/0
Hits: 480 Misses: 12
CEF Translated packets: 492, CEF Punted packets: 0
Expired translations: 11
Dynamic mappings:
-- Inside Destination
[Id: 1] access-list INBOUND_TELNET pool SERVERS refcount 1
pool SERVERS: netmask 255.255.255.0
start 10.0.0.1 end 10.0.0.1
start 10.0.0.6 end 10.0.0.6
type rotary, total addresses 2, allocated 1 (50%), misses 0
Queued Packets: 0
R5#telnet 150.1.4.4
Trying 150.1.4.4 ... Open
R1>exit 第一次连接到R1上
[Connection to 150.1.4.4 closed by foreign host]
R5#telnet 150.1.4.4
Trying 150.1.4.4 ... Open
R6>exit 第二次连接到R6上
[Connection to 150.1.4.4 closed by foreign host]
R5#
【实验基本配置】
R1:
inter fa 0/0
ip address 10.0.0.1 255.255.255.0
no shut
!
ip route 0.0.0.0 0.0.0.0 10.0.0.4
R4:
inter ethernet 0/0
ip address 10.0.0.4 255.255.255.0
no shut
!
inter Loopback0
ip add 150.1.4.4 255.255.255.0
ip ospf network point-to-point
!
interface Serial 0/0
encaps frame-relay
no shutdown
!
interface Serial 0/0.1 point-to-point
ip address 155.1.0.4 255.255.255.0
frame-relay interface-dlci 405
!
interface Serial 0/1
no shutdown
ip address 155.1.45.4 255.255.255.0
!
router ospf 1
router-id 150.1.4.4
network 155.1.0.4 0.0.0.0 area 0
network 155.1.45.4 0.0.0.0 area 0
network 150.1.4.4 0.0.0.0 area 0
!
router bgp 1
bgp router-id 150.1.4.4
neighbor 150.1.5.5 remote-as 2
neighbor 150.1.5.5 update-source Loopback0
neighbor 150.1.5.5 ebgp-multihop
R5:
interface Loopback0
ip address 150.1.5.5 255.255.255.0
ip ospf network point-to-point
!
interface Serial 0/0
encapsulation frame-relay
no shut
!
interface Serial 0/0.1 point-to-point
ip address 155.1.0.5 255.255.255.0
frame-relay interface-dlci 504
!
interface Serial 0/1
no shutdown
clockrate 64000
ip address 155.1.45.5 255.255.255.0
!
router ospf 1
router-id 150.1.5.5
network 155.1.0.5 0.0.0.0 area 0
network 155.1.45.5 0.0.0.0 area 0
network 150.1.5.5 0.0.0.0 area 0
!
router bgp 2
bgp router-id 150.1.5.5
neighbor 150.1.4.4 remote-as 1
neighbor 150.1.4.4 update-source Loopback0
neighbor 150.1.4.4 ebgp-multihop
neighbor 150.1.4.4 default-originate
R6:
inter gig 0/0
ip address 10.0.0.6 255.255.255.0
no shut
!
ip route 0.0.0.0 0.0.0.0 10.0.0.4
转载于:https://blog.51cto.com/haolun/993047