# $# 表示提供到shell脚本或者函数的参数总数;
# 1表示只有一个参数。
#/bin/bash
#file: tun_RS.sh
if [ $# -ne 1 ];
then
echo “usage: $0 virtualIP”
echo “such as : $0 172.19.58.200″
exit 0
fi
VIP=$1
# RS 无需转发
echo “0” >/proc/sys/net/ipv4/ip_forward
# modify eth0 mtu to 1440 for TCP server
/sbin/ifconfig eth0 mtu 1440
# 配置tunl0
/sbin/ifconfig tunl0 up
/sbin/ifconfig tunl0 ${VIP} broadcast ${VIP} netmask 0xffffffff up
/sbin/route add -host ${VIP} dev tunl0
# 解决arp的问题
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
# 解决rp_filter的问题
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