LVS客户端自动配置

LVS客户端自动配置

#/bin/bash
VIP=(202.106.195.111 202.106.195.222)
[ -e /etc/sysctl.conf ]&&rm -f /etc/sysctl.conf
[ -e /etc/sysconfig/network-scripts/ifcfg-lo:0 ]&&rm -f /etc/sysconfig/network-scripts/ifcfg-lo:0
[ -e /etc/sysconfig/network-scripts/ifcfg-lo:1 ]&&rm -f /etc/sysconfig/network-scripts/ifcfg-lo:1

echo "net.ipv4.conf.all.arp_ignore = 1">/etc/sysctl.conf
echo "net.ipv4.conf.all.arp_announce = 2">>/etc/sysctl.conf
echo "net.ipv4.conf.default.arp_ignore = 1">>/etc/sysctl.conf
echo "net.ipv4.conf.default.arp_announce = 2">>/etc/sysctl.conf
echo "net.ipv4.conf.lo.arp_ignore = 1">>/etc/sysctl.conf
echo "net.ipv4.conf.lo.arp_announce = 2">>/etc/sysctl.conf
sysctl -p &>/dev/null

cd /etc/sysconfig/network-scripts
for ((i=0;i<`echo ${#VIP[*]}`;i++))
do
  cp ifcfg-lo ifcfg-lo:$i
  echo "DEVICE=lo:$i">ifcfg-lo:$i
  echo "IPADDR=${VIP[$i]}">>ifcfg-lo:$i
  echo "NETMASK=255.255.255.255">>ifcfg-lo:$i
  echo "ONBOOT=yes">>ifcfg-lo:$i
  ifup ifcfg-lo:$i
  /usr/sbin/route add -host ${VIP[$i]} dev lo:$i &>/dev/null
done

你可能感兴趣的:(linux,linux,lvs,shell)