linux一键搭建VPN脚本[转]

/ 0评 / 2

首先,这脚本写的粗糙。大牛别笑话小菜了。
Ps:这脚本只能运行在Linux下,Unix下是不行的。(就算你手动UNIX下也是很难装成功的)
搭建成功以后,账户是vpn 密码是vpn365

代码如下:
[task]
#!/bin/sh
echo -e "\033[1;035m \n"
echo "######################################################"
echo "# WelCome to Www.90sec.org #"
echo "# Linux install pptpd #"
echo "# By:Met #"
echo "# email:AntiSecMet@Gmail.com #"
echo "######################################################"
if [ $(id -u) != "0" ];then
echo sorry,!root....
exit 1
fi
host=`hostname -i`
name=`hostname`
echo " $name "\n
echo " $host "\n
bit=`uname -a|grep "x86_64"`
if [ "$bit" = "" ];then
echo "32bit"
wget http://poptop.sourceforge.net/yum/stable/rhel5/i386/dkms-2.0.17.5-1.noarch.rpm
wget http://poptop.sourceforge.net/yum/stable/rhel5/i386/pptpd-1.3.4-2.rhel5.i386.rpm
rpm -ivh dkms-2.0.17.5-1.noarch.rpm --force --nodeps
rpm -ivh pptpd-1.3.4-2.rhel5.i386.rpm --force --nodeps
rm -rf pptpd-1.3.4-2.rhel5.i386.rpm
rm -rf dkms-2.0.17.5-1.noarch.rpm
cat >>/etc/pptpd.conf< >/etc/ppp/options.pptpd< >/etc/ppp/chap-secrets< >/etc/pptpd.conf< >/etc/ppp/options.pptpd< >/etc/ppp/chap-secrets< vpn pptpd vpn365 *
EOF
sed -i "s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g" grep "net.ipv4.ip_forward = 0" /etc/sysctl.conf
sysctl -p
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source $host
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
/etc/init.d/iptables save
/etc/init.d/iptables restart
/etc/init.d/pptpd restart
/etc/init.d/pptpd restart
chkconfig pptpd on
chkconfig iptables on
echo "Thank you for using"
echo "#+ $name #+"\n
echo "#+ $host #+"\n
fi

[/task]

发表评论

电子邮件地址不会被公开。 必填项已用*标注