LVS-Real Server

1407 단어 shellLVS
#!/bin/bash

#Parameters
VIP=192.168.22.5

case "$1" in
    start)
        echo "Starting LVS Real Server ..."
		
		#Bind Virtual IP Address
		/sbin/ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP up
		/sbin/route add -host $VIP dev lo:0
		
		#Forbid ARP Request
        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 
		sysctl -p > /dev/null 2>&1
		
		echo "OK"
        ;;
    stop)
        echo "Stopping LVS Real Server ..."
		
		/sbin/ifconfig lo:0 down
        echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
        echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
        echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
        echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
		
		echo "LVS Real Server Stopped ."
        ;;
	restart)
		$0 stop
		$0 start
    *)
        echo "Usage:$0 { start | stop | restart }"
        exit 1
esac
exit 0

좋은 웹페이지 즐겨찾기