Description
digital ocean, centos7
Guide
检查是否支持PPTP
1 2 3
| modprobe ppp-compress-18 && echo ok #返回OK zgrep MPPE /proc/config.gz #返回CONFIG_PPP_MPPE=y 或 =m cat /dev/net/tun #返回cat: /dev/net/tun: File descriptor in bad state
|

安装PPP

安装&配置PPTPD
1 2 3 4 5
| wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -ivh epel-release-latest-7.noarch.rpm yum repolist yum -y update yum install -y pptpd
|


编辑/etc/pptpd.conf设置VPN内网IP段
1 2
| localip 192.168.0.1 remoteip 192.168.0.214,192.168.0.245
|
编辑/etc/ppp/options.pptpd
1 2 3 4 5 6 7
| // 更改DNS项: ms-dns 8.8.8.8 ms-dns 8.8.4.4
// 修改日志记录: nologfd logfile /var/log/pptpd.log
|
编辑/etc/ppp/chap-secrets设置VPN账号密码
1 2
| 用户名 pptpd 密码 * //每个字段之间用tab键隔开 *表示用任意IP连接VPN都可以 root pptpd 123 *
|
编辑/etc/sysctl.conf修改内核参数支持内核转发
1 2
| net.ipv4.ip_forward=1 输入命令生效:sysctl -p
|

修改防火墙设置:
1 2 3 4 5 6 7 8 9
| 创建规则文件:touch /usr/lib/firewalld/services/pptpd.xml
修改规则文件 <?xml version="1.0" encoding="utf-8"?> <service> <short>pptpd</short> <description>PPTP</description> <port protocol="tcp" port="1723"/> </service>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| 启动或重启防火墙: systemctl start firewalld.service或firewall-cmd --reload
添加服务: firewall-cmd --permanent --zone=public --add-service=pptpd
允许防火墙伪装IP: firewall-cmd --add-masquerade
开启47及1723端口: firewall-cmd --permanent --zone=public --add-port=47/tcp firewall-cmd --permanent --zone=public --add-port=1723/tcp
允许gre协议: firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT firewall-cmd --permanent --direct --add-rule ipv4 filter OUTPUT 0 -p gre -j ACCEPT
设置规则允许数据包由eth0和ppp+接口中进出 firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i ppp+ -o eth0 -j ACCEPT firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i eth0 -o ppp+ -j ACCEPT
设置转发规则,从源地址发出的所有包都进行伪装,改变地址,由eth0发出: firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o eth0 -j MASQUERADE -s 192.168.0.0/24
重启服务器: firewall-cmd --reload systemctl restart pptpd
|
验证
查看pptpd启动状态

原因:/etc/pptpd.conf
中remoteip 192.168.0.214,192.168.0.245
之间多了一个空格

改为:


然后,我用手机的vpn连上后成功上了google,但是网速很慢。
Q&A
Q: MPPE disabled
A:
Q: Cannot determine ethernet address for proxy ARP
A:
pptpd 的问题, Cannot determine ethernet address for proxy ARP:
VPN 架设中一些问题的解决方法(pptpd)
Linux 通过 pptp 连接 VPN 网络
Centos 6.5 下配置L2tp Vpn
Reference
CentOS7安装PPTP
Centos7 下部署PPTP
CentOS7中PPTP的配置