├── README.md ├── LICENSE ├── pptp-vpn-server-ubuntu14.04.sh └── pptp-vpn-server-centos7.sh /README.md: -------------------------------------------------------------------------------- 1 | # pptp-vpn-server 2 | > 基于pptp的vpn服务搭建部署脚本 3 | 4 | ## 下载 5 | * **ubuntu环境**:`$ wget https://raw.githubusercontent.com/tomoncle/pptp-vpn-server/master/pptp-vpn-server-ubuntu14.04.sh` 6 | * **centos环境**:`$ wget https://raw.githubusercontent.com/tomoncle/pptp-vpn-server/master/pptp-vpn-server-centos7.sh` 7 | 8 | 9 | 10 | ## 使用 11 | * 1.授权:`$ chmod +x pptp-vpn-server-*.sh` 12 | * 2.运行:`$ ./pptp-vpn-server-*.sh`, 执行过程需要你显示的指定你连接的用户名,密码. 13 | * 参数:`username`: vpn连接的用户名 14 | * 参数:`password`: vpn连接的密码 15 | 16 | ## client连接 17 | 打开客户端,使用pptp协议连接, 填入你的`服务器地址`,`用户名`和`密码`即可使用. 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Tom .Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pptp-vpn-server-ubuntu14.04.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ######### 4 | # os: ubuntu 5 | # tomoncle 6 | 7 | 8 | install_pptp() { 9 | sudo apt-get update 10 | sudo apt-get -y install pptpd 11 | } 12 | 13 | config_kernel_IP_forwarding() { 14 | sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf 15 | sudo sysctl -p 16 | } 17 | 18 | config_pptp() { 19 | sudo sed -i 's/#localip 192.168.0.1/localip 192.168.0.1/g' /etc/pptpd.conf 20 | sudo sed -i 's/#remoteip 192.168.0.234-238,192.168.0.245/remoteip 192.168.0.234-238,192.168.0.245/g' /etc/pptpd.conf 21 | sudo sed -i 's/#ms-dns 10.0.0.1/ms-dns 8.8.8.8/g' /etc/ppp/pptpd-options 22 | sudo sed -i 's/#ms-dns 10.0.0.2/ms-dns 8.8.4.4/g' /etc/ppp/pptpd-options 23 | sudo echo "$username pptpd \"$password\" *" >> /etc/ppp/chap-secrets 24 | } 25 | 26 | iptables_config() { 27 | sudo apt-get -y install iptables 28 | sudo iptables -F 29 | sudo iptables -X 30 | sudo iptables -t nat -F 31 | sudo iptables -t nat -X 32 | sudo iptables -A INPUT -p gre -j ACCEPT 33 | sudo iptables -A INPUT -p tcp --dport 1723 -j ACCEPT 34 | sudo iptables -A INPUT -p tcp --dport 47 -j ACCEPT 35 | sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE 36 | } 37 | 38 | 39 | # start shell. 40 | install_pptp 41 | 42 | read -p "Please enter the VPN connection username:" username 43 | read -p "Please enter the VPN connection password:" password 44 | 45 | config_kernel_IP_forwarding 46 | iptables_config 47 | config_pptp 48 | sudo service pptpd restart 49 | 50 | echo -e "\npptp vpn service config success!!!" 51 | -------------------------------------------------------------------------------- /pptp-vpn-server-centos7.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ######### 4 | # os: centos7 5 | # tomoncle 6 | 7 | 8 | install_pptp() { 9 | sudo yum install -y ppp 10 | wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 11 | sudo rpm -ivh epel-release-latest-7.noarch.rpm 12 | sudo yum repolist 13 | sudo yum -y update 14 | sudo yum install -y pptpd 15 | } 16 | 17 | config_kernel_IP_forwarding() { 18 | echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf 19 | sudo sysctl -p 20 | } 21 | 22 | config_pptp() { 23 | sudo sed -i 's/#localip 192.168.0.1/localip 192.168.0.1/g' /etc/pptpd.conf 24 | sudo sed -i 's/#remoteip 192.168.0.234-238,192.168.0.245/remoteip 192.168.0.234-238,192.168.0.245/g' /etc/pptpd.conf 25 | sudo sed -i 's/#ms-dns 10.0.0.1/ms-dns 8.8.8.8/g' /etc/ppp/options.pptpd 26 | sudo sed -i 's/#ms-dns 10.0.0.2/ms-dns 8.8.4.4/g' /etc/ppp/options.pptpd 27 | sudo echo "$username pptpd \"$password\" *" >> /etc/ppp/chap-secrets 28 | } 29 | 30 | iptables_config() { 31 | sudo yum -y install iptables 32 | sudo firewall-cmd --permanent --add-masquerade 33 | sudo firewall-cmd --permanent --add-port=47/tcp 34 | sudo firewall-cmd --permanent --add-port=1723/tcp 35 | sudo firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT 36 | sudo firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE 37 | sudo firewall-cmd --reload 38 | sudo systemctl enable pptpd 39 | } 40 | 41 | 42 | # start shell. 43 | install_pptp 44 | 45 | read -p "Please enter the VPN connection username:" username 46 | read -p "Please enter the VPN connection password:" password 47 | 48 | config_kernel_IP_forwarding 49 | iptables_config 50 | config_pptp 51 | sudo systemctl restart pptpd 52 | 53 | echo -e "\npptp vpn service config success!!!" 54 | --------------------------------------------------------------------------------