lvs-note

私有ip

10.0.0.0/8 A

172.16.0.0/16―172.31.0.0/16 B

192.168.0.0/16 C


Linuxlvs

wKiom1NKM1_Sp7GVAAHBFy1S-R8852.jpg

Lvs配置

Yum �Cy install ipvsadm*

Echo “1” > /proc/sys/net/ipv4/ip_forward

Ipvsadm �CC

Ipvsadm �CA �Ct 8.8.8.10:80 �Cs rr

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 192.168.1.2:80�Cm

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 192.168.1.3:80-m

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 192.168.1.4:80-m

Ipvsadm �CL �Cn

Web配置

Route add default gw 192.168.1.1

Route �Cn

(route del default)

所有的数据包都要经过Lvs,因此该是局限性


wKioL1NKM0uRU8DZAAIAWJzhiyc098.jpg

所有服务器都要有隧道网卡配置公网ip eth0 �C>ip tunl0->vip

Lvs配置

Ifconfig tunl0 8.8.8.10 netask255.255.255.255 up

Route add �Chost 8.8.8.10 dev tunl0

Ipvsadm �CC

Ipvsadm �CA �Ct 8.8.8.10:80 �Cs rr

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 8.8.8.2:80 �Ci

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 8.8.8.3:80 -i

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 8.8.8.4:80 -i

Web配置

Ifconfig tunl0 8.8.8.10 netmask255.255.255.255 up

Route add �Chost 8.8.8.10 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


wKiom1NKM4jBQKsvAAIC7mmpLXU195.jpg

Lvs配置

Ifconfig eth0:0 :8.8.8.10 netmask255.255.255.255 up

Route add �Chost 8.8.8.10 dev eth0:0

Ipvsadm �CC

Ipvsadm �CA �Ct 8.8.8.10:80 �Cs rr

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 8.8.8.2:80 -g

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 8.8.8.3:80 -g

Ipvsadm �Ca �Ct 8.8.8.10:80 �Cr 8.8.8.4:80 �Cg

Web配置

Ifconfig lo:0 8.8.8.10 nemask255.255.255.255 up

Route add �Chost 8.8.8.10 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


负载算法轮叫rr 加权轮叫wrr 最少连接lc 加权最少连接wlc

tcpdump -i eth0 �Cnn



你可能感兴趣的:(LVS)