bash脚本Centos6.3下安装VPN(pptpd)服务器

页面导航:首页 > 操作系统 > LINUX > bash脚本Centos6.3下安装VPN(pptpd)服务器

bash脚本Centos6.3下安装VPN(pptpd)服务器

来源: 作者: 时间:2016-08-18 10:30 【

bash脚本Centos6.3下安装VPN(pptpd)服务器#!/bin/bashfunction installVPN(){yum remove -y pptpd pppiptables --flush POSTROUTING --table natiptables --flush FORWARDrm -rf /etc/pptpd.confrm...
bash脚本Centos6.3下安装VPN(pptpd)服务器
 
#!/bin/bash
function installVPN(){
yum remove -y pptpd ppp
iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp*
yum install -y ppp iptables
echo 1 > /proc/sys/net/ipv4/ip_forward
cd /tmp
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.x86_64.rpm
rpm -ivh pptpd-1.3.4-2.el6.x86_64.rpm
cat >/etc/ppp/options.pptpd<<END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
END
cat >/etc/pptpd.conf<<END
option /etc/ppp/options.pptpd
logwtmp
localip 10.10.10.1
remoteip 10.10.10.205-254
END
iptables -t nat -A POSTROUTING -s 10.10.10/8 -o eth0 -j SNAT --to-source `ifconfig  | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==2 { print $1}'`
iptables -A FORWARD -s `ifconfig  | grep 'inet addr:'| grep -v '127.0.0' | cut -d: -f2 | awk 'NR==2 { print $1}'`/32 -o eth0 -j ACCEPT
service pptpd start
chkconfig --level pptpd 2345 on
chkconfig pptpd on
service iptables save
chkconfig iptables on
service iptables start
}
function addVPNuser(){
echo "input user name:"
read username
echo "input password:"
read userpassword
echo "${username} pptpd ${userpassword} *" >> /etc/ppp/chap-secrets
service pptpd restart-kill
service pptpd start
service iptables restart
}
echo "which do you want to ? input the number."
echo "1. install VPN service"
echo "2. add VPN user"
read num
case "$num" in
[1] ) (installVPN);;
[2] ) (addVPNuser);;
*) echo "nothing,exit";;
esac
bash echo "Your VPN server configuration is complete,The default user password vpnuser as test123 Please run the script again to add custom user"
进过多次测试,可以很正常运行vpn服务。如图所示:
 
 
未连接VPN服务器ip配置和ping百度测试
 
 
连接VPN服务器后的ip配置和ping百度测试
Tags:

文章评论

最 近 更 新
热 点 排 行
Js与CSS工具
代码转换工具

<