Load Balancing in RedHat tunnel mode

Source: Internet
Author: User
First, the working principle of load balancing in tunneling mode: when the client accesses the director machine, the director machine sends the client request to the real server, and then the real server directly responds to the request response result to the client. The Real Server can be an inaccessible network segment-that is, each server can boast a network. This method not only reduces the pressure on the ctor machine, but also achieves high efficiency and can be used in space. But it does not seem to work for the moment in China (because few companies have used it ...). Generally applicable to large and medium-sized

First, the working principle of load balancing in tunneling mode: when the client accesses the director machine, the director machine sends the client request to the real server, and then the real server directly responds to the request response result to the client. The Real Server can be an inaccessible network segment-that is, each server can boast a network. This method not only reduces the pressure on the ctor machine, but also achieves high efficiency and can be used in space. But it does not seem to work for the moment in China (because few companies have used it ...). It is generally applicable to large and medium-sized enterprises.

Lab environment: two host servers: 192.168.0.11 and 192.168.0.12
Medium transfer: 192.168.0.13 and 192.168.0.19
Client: 192.168.0.10
(The host name must be consistent with the IP address. Iptables: clear -- iptables-F. Selinux disabled)

Tutorial steps:
A. Server:
1. 192.168.0.11
# Yum install-y httpd
# Service httpd start
# Echo "192.168.0.11">/var/www/html/index.html
# Route add default gw 192.168.0.13
# Vim/etc/init. d/shutarp
-------------------------------
#! /Bin/sh
VIP = 192.168.0.19

./Etc/rc. d/init. d/functions

Case "$1" in
Start)
Echo "Tunl port starting"
Ifconfig tunl0 $ VIP netmask 255.255.255.255 broadcast $ VIP up
/Sbin/route add-host $ VIP dev tunl0
Echo "1">/proc/sys/net/ipv4/conf/tunl0/arp_ignore
Echo "2">/proc/sys/net/ipv4/conf/tunl0/arp_announce
Echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore
Echo "2">/proc/sys/net/ipv4/conf/all/arp_announce
Sysctl-p

;;
Stop)
Echo "Tunl port closing"
Ifconfig tunl0 down
Echo 1>/proc/sys/net/ipv4/ip_forward
Echo 0>/proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
Echo "Usage: $0 {start | stop }"
Exit 1
Esac
-------------------------------
# Service shutarp start
2. 192.168.0.12
# Yum install-y httpd
# Service httpd start
# Echo "192.168.0.12">/var/www/html/index.html
# Route add default gw 192.168.0.13
# Vim/etc/init. d/shutarp
-------------------------------
#! /Bin/sh
VIP = 192.168.0.19

./Etc/rc. d/init. d/functions

Case "$1" in
Start)
Echo "Tunl port starting"
Ifconfig tunl0 $ VIP netmask 255.255.255.255 broadcast $ VIP up
/Sbin/route add-host $ VIP dev tunl0
Echo "1">/proc/sys/net/ipv4/conf/tunl0/arp_ignore
Echo "2">/proc/sys/net/ipv4/conf/tunl0/arp_announce
Echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore
Echo "2">/proc/sys/net/ipv4/conf/all/arp_announce
Sysctl-p

;;
Stop)
Echo "Tunl port closing"
Ifconfig tunl0 down
Echo 1>/proc/sys/net/ipv4/ip_forward
Echo 0>/proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
Echo "Usage: $0 {start | stop }"
Exit 1
Esac
-------------------------------
# Service shutarp start
B. Intermediate transfer:
1. Install the ipvs service:
# Yum clean all
# Yum install-y ipvsadm
2. Enable ip Forwarding, disable other services, and set forwarding
# Vim/etc/init. d/lvsDR
---------------------------------
#! /Bin/sh
VIP = 192.168.0.19
RIP1 = 192.168.0.11
RIP2 = 192.168.0.12
GW = 192.168.0.1

./Etc/rc. d/init. d/functions

Case "$1" in
Start)
Echo "start LVS of DirectorServer"
/Sbin/ifconfig tunl0 $ VIP broadcast $ VIP netmask bandwidth limit 255 up
/Sbin/route add-host $ VIP dev tunl0
/Sbin/ipvsadm-C
/Sbin/ipvsadm-A-t $ VIP: 80-s rr
/Sbin/ipvsadm-a-t $ VIP: 80-r $ RIP1: 80-I
/Sbin/ipvsadm-a-t $ VIP: 80-r $ RIP2: 80-I
/Sbin/ipvsadm

;;
Stop)
Echo "close LVS Directorserver"
Ifconfig tunl0 down
/Sbin/ipvsadm-C
;;
*)
Echo "Usage: $0 {start | stop }"
Exit 1
Esac

---------------------------------
# Service lvsDR start (Execution script)

# Vim/bin/shutarp
-------------------------------
#! /Bin/bash
VIP = 192.168.0.19
/Sbin/ifconfig lo: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up
/Sbin/route add-host $ VIP dev lo: 0
Echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignore
Echo "2">/proc/sys/net/ipv4/conf/lo/arp_announce
Echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore
Echo "2">/proc/sys/net/ipv4/conf/all/arp_announce
Sysctl-p
-------------------------------
# Shutarp

C. Client:
Open http: // 192.168.0.19/in the browser. Refresh the page again. If the page is displayed, the experiment is successful !)

Related Article

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.