本文为测试=。=
一、检查是否持环境搭配,若你使用XEN架构的VPS,下面的步骤不用执行。
1、检测PPP是否开启:
cat /dev/ppp
2、开启成功的标志:
cat: /dev/ppp: No such file or directory 或者 cat: /dev/ppp: No such device or address
二、检测完成后,可以继续进行下面的安装操作
1、安装ppp:
yum install -y ppp
2、安装PPTP:
yum install epel-release yum install pptpd
3、安装iptables(如果本身系统自带,那么可以不用安装):
systemctl stop firewalld systemctl mask firewalld yum install iptables iptables-services systemctl enable iptables service iptables start service iptables save
三、配置环境
1、编辑pptpd.conf
vi /etc/pptpd.conf
2、搜索localip,去掉下面字段前面的#,然后保存退出
localip 192.168.0.1 remoteip 192.168.0.234-238,192.168.0.245 #这些是默认的,一般不用修改,分配给客户端的ip在234到238之间,也可以往大了写,具体看客户端数量。
3、配置options.pptpd
vi /etc/ppp/options.pptpd
4、搜索ms-dns,去掉搜索到的两行ms-dns前面的#,并修改为下面的字段
ms-dns 8.8.8.8 #这是谷歌的dns ms-dns 8.8.4.4
5、配置连接VPN客户端要用到的帐号密码
vi /etc/ppp/chap-secrets
6、添加一行,按照格式写入你的用户名和密码(用 tab 键分割各参数)
vpnuser pptpd 密码
7、修改内核参数
vi /etc/sysctl.conf
8、在conf末尾添加下面的代码,使内核支持转发
net.ipv4.ip_forward=1
9、这个时候把iptables关闭的话是可以连接VPN了,之所以要把iptables关闭是因为没有开放VPN的端口,
客户如果直接连接的话是不允许的,这里还需要设置iptables的转发规则,让你的客户端连接上之后能访问外网。iptables -A INPUT -p tcp --dport 1723 -j ACCEPT iptables -A INPUT -p 47 -j ACCEPT iptables -A OUTPUT -p 47 -j ACCEPT iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE #注:eth0 为外网网卡 iptables -A INPUT -i ppp+ -j ACCEPT iptables -A OUTPUT -o ppp+ -j ACCEPT iptables -F FORWARD iptables -A FORWARD -j ACCEPT iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE iptables -A POSTROUTING -t nat -o ppp+ -j MASQUERADE #注:eth0 为外网网卡 service iptables save
10、最后,应该重启一下pptpd服务和iptables服务。
stemctl restart iptables systemctl restart pptpd systemctl enable pptpd.service
PS:本文亲测,系统是centos 7.0 64位,注意配置路由转发规则,上文中配置的网卡 eth0一定要对应实际服务器的外网网卡,配置的时候由于直接写成 eth0 而不是实际的网卡导致VPN可以连接,但是不能上网。
本文:三月有晴天 提供支持,并完善配置环境。
偷懒直接脚本装了SS/SSR,懒人有懒人的办法😄