Using NAT for Server Load Distribution
Problem
You have several application servers and you want to use NAT so that users can connect to them by a single IP address, distributing the load across all of the servers.
Solution
The rotary keyword allows you to do simple NAT-based load balancing of servers:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface
Router(config-if)#
FastEthernet0/0
ip address
Router(config-if)#
192.168.1.1 255.255.255.0
ip nat inside
Router(config-if)#exit
Router(config)#interface
Router(config-if)#
FastEthernet0/1
ip address
Router(config-if)#
192.168.2.1 255.255.255.0
ip nat outside
Router(config-if)#exit
Router(config)#ip nat pool
WEBSERVERS 192.168.1.101 192.168.1.105
netmask
255.255.255.0
type rotary
Router(config)#access-list
20
permit host
Router(config)#
192.168.1.100
ip nat inside destination list
20
pool
Router(config)#
WEBSERVERS
end
Router#
Discussion
This example is more applicable to an Intranet than to the public Internet. It shows a simple way of doing load balancing among a group of application servers that all perform the same function. We would like to stress that this load balancing is extremely limited, and if you want a fully featured load-balancing device, you would be much better off with one of Cisco’s Content Services Switches, such as the CSS 11500 series. However, we understand that these devices are expensive, so if your requirements are fairly basic, this recipe provides a simpler ...
Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.