ykwll 发表于 2015-9-5 12:23:36

LVS NAT 实验环境部署脚本

  LVS_NAT 实验环境部署脚本
  



#!/bin/bash
# Lvs_nat
# Client CIP: 172.16.20.101/24eth0:br0
# Director VIP: 172.16.20.102/24eth0:br0
# DIP: 192.168.0.254/24eth1:br1
# RealServerARIP: 192.168.0.1/24eth0:br1
# RealServerBRIP: 192.168.0.2/24eth0: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 -m -w 1
ipvsadm -a -t 172.16.20.102:8080 -r 192.168.0.2:80 -m -w 2
return
}
realservera(){
#配置网络地址
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(){
#配置网络地址
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]
查看完整版本: LVS NAT 实验环境部署脚本