# $# indicates the total number of arguments supplied to the shell script or function;
# 1 indicates only one parameter.
#/bin/bash
#file: tun_rs.sh
If [$#-ne 1];
Then
echo "Usage: $ virtualip"
echo "such as: $172.19.58.200″
Exit 0
Fi
Vip=$1
# RS does not need to be forwarded
echo "0" >/proc/sys/net/ipv4/ip_forward
# Modify Eth0 MTU to 1440 for TCP server
/sbin/ifconfig eth0 MTU 1440
# Configure Tunl0
/sbin/ifconfig tunl0 up
/sbin/ifconfig tunl0 ${VIP} broadcast ${VIP} netmask 0xFFFFFFFF up
/sbin/route add-host ${vip} dev tunl0
# troubleshoot ARP issues
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
# Solve the Rp_filter problem
echo 0 >/proc/sys/net/ipv4/conf/tunl0/rp_filter
echo 0 >/proc/sys/net/ipv4/conf/all/rp_filter
# End of Tun_rs.sh
LVS realserver Configuration VIP