|
本帖最后由 yumin9822 于 2015-9-8 10:17 编辑
自己一直用的,大部分网上抄来的,自己修修补补加了一些内容,贡献给大家。
亮点如下(大神不要笑话):
1. 加入TUN PPP自动判断脚本(理论上OPENVZ没办法在VPS中自动开启TUN和PPP)
2. mppe有些系统不支持的,自动判断在pptpd中开启还是关闭。(不是非常准确,请教大神指教)
关键字被替换了,来个pastebin链接 http://pastebin.ca/3155677
- #!/bin/bash
- if ( [ "$(cat /dev/net/tun 2>&1)" == "cat: /dev/net/tun: File descriptor in bad state" ] && [ "$(cat /dev/ppp 2>&1)" == "cat: /dev/ppp: No such device or address" ] ); then
- echo "TUN and PPP are ok"
- else
- echo "Please enable your TUN and PPP"
- exit 1
- fi
- read -t 30 -p "(Ready to install PPTP 扶墙, Default: y):" answer
- if [ -z $answer ]; then
- answer="y"
- fi
- if [ "$answer" = "y" ]; then
- echo "begin to install 扶墙 services";
- yum remove -y pptpd ppp
- rm -rf /etc/pptpd.conf
- rm -rf /etc/ppp
-
- yum update -y
- yum install curl openssl -y
- vpsip=`curl -s -4 checkip.dns.he.net | sed -n 's/.*: \([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p'`
- yum install -y ppp pptpd
- mknod /dev/ppp c 108 0
- echo 1 > /proc/sys/net/ipv4/ip_forward
- sed -i 's/^exit 0/#exit 0/g' /etc/rc.d/rc.local
- sed -i 's/#net.ipv4.ip_forward = 1/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
- sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
- echo "mknod /dev/ppp c 108 0" >> /etc/rc.d/rc.local
- echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.d/rc.local
-
- echo "localip 172.16.36.1" >> /etc/pptpd.conf
- echo "remoteip 172.16.36.2-254" >> /etc/pptpd.conf
- echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd
- echo "ms-dns 8.8.4.4" >> /etc/ppp/options.pptpd
-
- pass=`openssl rand 6 -base64`
- if [ "$1" != "" ]
- then pass=$1
- fi
- echo "扶墙 pptpd ${pass} *" >> /etc/ppp/chap-secrets
- iptables -A FORWARD -p tcp --syn -s 172.16.36.0/24 -j TCPMSS --set-mss 1356
- iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source "$vpsip"
- service iptables save
- chkconfig pptpd on
- chkconfig iptables on
- service iptables restart
- modprobe ppp-compress-18 || sed -i 's/^require-mppe-128/#require-mppe-128/' /etc/ppp/options.pptpd
- service pptpd start
- echo "扶墙 service is installed, your 扶墙 username is 扶墙, 扶墙 password is ${pass}"
- modprobe ppp-compress-18 || echo "Please disable mppe on 扶墙 client!!"
- else
- echo "PPTP 扶墙 cancelled, Nothing to do"
- fi
复制代码
需要自定义用户名密码脚本如下:
- #!/bin/bash
- echo "input user name:"
- read username
- echo "input password:"
- read userpassword
- echo "${username} pptpd ${userpassword} *" >> /etc/ppp/chap-secrets
- service pptpd start
复制代码 |
|