Nat mode configuration of Lvs load balancer

Source: Internet
Author: User

The Lvs NAT mode is the full name of virtual server via network address translation (Vs/nat), which rewrites the destination address of the request message via the Net-addressing translation, and assigns the request to the backend's real server according to the scheduled scheduling algorithm. When the response message of the real server passes through the scheduler, the source address of the message is rewritten and returned to the client to complete the load scheduling process.

Lvs NAT working schematic diagram is as follows

Characteristics:
1, all back-end servers and LVS servers (schedulers) are in the same network segment
2, the backend server IP is a private address and is used only for communication between cluster nodes
3,lvs server processes both request and reply packets
4, the Gateway of the backend server points to the IP of the LVS server
5, port mapping can be implemented
6, back-end server can be any operating system
7,lvs server is likely to become a system performance bottleneck (both requests and returns go through the LVS server)

To configure the test environment:

VMware8.0, three CentOS5.6 virtual machines

Server Configuration

C_server 8.8.8.1

D_SERVER0 8.8.8.8 (Public network IP)

D_server1 192.168.10.1 (LAN IP)

R_server1 192.168.10.2(LAN IP)

R_server2 192.168.10.3(LAN IP)

Ensure that C_server and D_SERVER0 can communicate with each other, d_server1,r_server1 and r_server2 can communicate with each other, and R_server1 and R_server2 gateways point to D_ Server1 (Command: Route add default GW 192.168.10.1), it is also important to note that the server is shutting down the firewall (iptables-l-n;service iptables stop).

Software Installation:

You need to install IPVSADM on the D_server machine,

Yum-y Install ipvsadm*



To create a configuration script:

vi/root/lvs.sh

#!/bin/bashecho 1 >/proc/sys/net/ipv4/ip_forward  #打开路由转发功能ipvsadm-cipvsadm-at 8.8.8.8:80-s rripvsadm-at 8.8.8.8:80-r 192.168.10.2:80-mipvsadm-at 8.8.8.8:80-r 192.168.10.3:80-mipvsadm-l-N



chmod a+x/root/lvs.sh

sh/root/lvs.sh

To this LVS NAT mode load balancer configuration is complete!

Test:

Close the Web server on D_server and create two HTML files in the Web directory on R_server1 and R_server2, respectively

echo ' 192.168.10.2 ' >/home/webserver1/index.html

echo ' 192.168.10.3 ' >/home/webserver2/index.html


Enter http://8.8.8.8/index.html on C_server's browser and you'll see the effect!





Nat mode configuration of Lvs load balancer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.