LVS regardless of the NAT and Dr Mode, both LVS server and real server in the same network segment, Nat needs to use LVS server as the default gateway for each realserver, Dr Mode with modified MAC address directly from the data link layer forwarding, Requirements must be within the same physical network segment
The experiment of Lvs-nat
Network topology:
The use of 1 router, a public network IP, a managed private network, 3 private network VMS built (1 LVS, 2 realserver), the VM firewall is closed, router binding public IP, configure port forwarding policy, 80 port to LVS IP : 80, Tsing Yun in firewall open downstream TCP 80 port
Environment: CentOS 6.4 x64
Process:
One LB
1 Install Ipvsadm First
2 opening Ip_forward
echo "1" >/proc/sys/net/ipv4/ip_forward
3 Writing LVS Rules
#vim lvsnat.sh
Ipvsadm-c
Ipvsadm-a-T Lvs_ip:80-s RR
Ipvsadm-a-T Lvs_ip:80-r web1_ip:80-m
Ipvsadm-a-T Lvs_ip:80-r web2_ip:80-m
4 Execution rules
SH lvsnat.sh
5 use Ipvsadm-l to see
[Email protected] ~]# ipvsadm-l
IP Virtual Server version 1.2.1 (size=4096)
Prot Localaddress:port Scheduler Flags
Remoteaddress:port Forward Weight activeconn inactconn
TCP Lvs_ip:http RR
-web1_ip:http MASQ 1 0 0
-web2_ip:http MASQ 1 0 0
Two Real servers
Real server only needs to point the gateway to LVS_IP, open the Apache test
Route add default GW lvs_ip
Delete webserver default route: Route del defaults GW 192.168.100.1
Reference article: http://www.importnew.com/11229.html
LVS Principle and Practice (NAT mode)