LVS FULLNAT 实验环境部署脚本
#!/bin/bash# Lvs_fullnat
# Client CIP: 172.16.20.101/24 eth0:br0
# DirectorVIP: 172.16.20.102/24 eth0:br0
# DIP: 192.168.0.254/24 eth1:br1
# RealServerA RIP: 192.168.0.1/24 eth0:br1
# RealServerB RIP: 192.168.0.2/24 eth0:br1
#
client(){
#配置网络地址
ifconfig eth0 172.16.20.101 netmask 255.255.255.0
return
}
director(){
#配置网络地址
ifconfig eth0 172.16.20.102 netmask 255.255.255.0
ifconfig eth1 192.168.0.254 netmask 255.255.255.0
#开启Debug
./ipvsadm -L -n
echo 12 > /proc/sys/net/ipv4/vs/debug_level
#开启转发
echo 1 > /proc/sys/net/ipv4/ip_forward
#使用淘宝开源内核以及工具。
#配置策略
./ipvsadm -C
./ipvsadm -A -t 172.16.20.102:8080 -s wrr
./ipvsadm -a -t 172.16.20.102:8080 -r 192.168.0.1:80 -b -w 1
./ipvsadm -a -t 172.16.20.102:8080 -r 192.168.0.2:80 -b -w 2
./ipvsadm -P -t 172.16.20.102:8080 -z 192.168.0.254
return
}
realservera(){
modprobe toa
#配置网络地址
ifconfig eth0 192.168.0.1 netmask 255.255.255.0
route del default
route add default gw 192.168.0.254
echo "serverA" > /var/www/html/index.html
/etc/init.d/httpd restart
return
}
realserverb(){
#加载模块
modprobe toa
#配置网络地址
ifconfig eth0 192.168.0.2 netmask 255.255.255.0
route del default
route add default gw 192.168.0.254
echo "serverB" > /var/www/html/index.html
/etc/init.d/httpd restart
return
}
页:
[1]