荣耀之链论坛

 找回密码
 立即注册
搜索
查看: 3420|回复: 4

centos7 7.3 64位安装pptp

[复制链接]

1326

主题

2373

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
10267
发表于 2017-5-22 13:19 | 显示全部楼层 |阅读模式
https://help.aliyun.com/knowledge_detail/41345.html
可以参考这个链接,但是不要全看,里面也有一部分错误


我自己的步骤如下:

yum install -y ppp pptpd

vi /etc/pptpd.conf
localip 172.16.36.1
remoteip 172.16.36.2-172.16.36.100

vi /etc/ppp/options.pptpd
ms-dns 223.5.5.5
ms-dns 223.6.6.6

vi /etc/ppp/ip-up
在退出之前添加
ifconfig $1 mtu 1500
(如果不添加这个用WIN10拨号以后访问不了https的网站)

vi /etc/ppp/chap-secrets
user1 *       password1        172.16.36.2
user2 *       password2        172.16.36.3
user3 *       password3        172.16.36.4
user4 *       password4        172.16.36.5
这里是添加用户,并且指定用户的IP
如果不想这么麻烦可以直接用命令添加用户
vpnuser add user1 password1
直接添加的用户默认的IP是*,也就是你拨号以后随机给你分配一个,不固定
添加用户立刻生效,不需要重启服务

service pptpd restart
这样服务器就搭建好了

然后WIN10客户端新建了VPN拨号
需要做如下设置:
安全里面选择允许使用这些协议
默认已经勾选了CHAP

回复

使用道具 举报

1326

主题

2373

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
10267
 楼主| 发表于 2017-5-22 13:51 | 显示全部楼层
转发忘记设置了

转发设置如下
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -j MASQUERADE

然后添加自己的规则
iptables -t nat -I PREROUTING 1 -p tcp --dport 33890 -j DNAT --to 172.16.36.2:33890

最后保存规则
/usr/libexec/iptables/iptables.init save
阿里云的centos保存命令是是iptables-save > /etc/iptables.rules


回复 支持 反对

使用道具 举报

1326

主题

2373

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
10267
 楼主| 发表于 2017-6-16 04:12 | 显示全部楼层
filter表需要开启这个协议和这些端口
GRE协议  53 67 68 137 443 1723

iptables -t filter -I INPUT 1 -p tcp --sport 138 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 138 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 47 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 47 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 53 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 53 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 67 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 67 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 68 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 68 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 137 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 137 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 1723 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 1723 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --sport 443 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --sport 443 -j ACCEPT


iptables -t filter -I INPUT 1 -p tcp --dport 138 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 138 -j ACCEPT

iptables -t filter -I INPUT 1 -p tcp --dport 47 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 47 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --dport 53 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 53 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --dport 67 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 67 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --dport 68 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 68 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --dport 137 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 137 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --dport 1723 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 1723 -j ACCEPT
iptables -t filter -I INPUT 1 -p tcp --dport 443 -j ACCEPT
iptables -t filter -I INPUT 1 -p udp --dport 443 -j ACCEPT
iptables -t filter -I INPUT 1 -p gre -j ACCEPT


这下面两条如果需要也要
iptables -t filter -I FORWARD 1 -j ACCEPT
iptables -t filter -I OUTPUT 1 -j ACCEPT
回复 支持 反对

使用道具 举报

1326

主题

2373

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
10267
 楼主| 发表于 2018-8-17 03:50 | 显示全部楼层
如果用的是firewalld 则语句如下:
PPTP服务需要添加的语句
firewall-cmd --add-port=1723/tcp --permanent
firewall-cmd --add-masquerade --permanent
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -i eth0 -p gre -j ACCEPT
firewall-cmd --reload
回复 支持 反对

使用道具 举报

1326

主题

2373

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
10267
 楼主| 发表于 2018-8-17 03:53 | 显示全部楼层
https://blog.csdn.net/wtm21/article/details/77849773
#!/bin/bash
yum -y update
yum -y install epel-release
yum -y install firewalld net-tools ppp pptpd
# 开启内核转发
echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
sysctl -p
#添加pptp的登录账号密码,账号是admin 密码admin888
echo 'admin * admin888 *' >> /etc/ppp/chap-secrets
#开启虚拟IP分配
cat >>/etc/pptpd.conf <<END
localip 192.168.2.1
remoteip 192.168.2.10-100
END
#添加 pptp 的DNS解析服务器 格式:ms-dns 8.8.8.8 ,ip改为你自己的可以了
cat >>/etc/ppp/options.pptpd <<END
# ms-dns 202.12.27.33
ms-dns 8.8.8.8
ms-dns 8.8.4.4
END
# Firewall 通过防火墙规则
ens=$(ls /etc/sysconfig/network-scripts/ | grep 'ifcfg-e.*[0-9]' | cut -d- -f2)
systemctl restart firewalld.service
systemctl enable firewalld.service
firewall-cmd --set-default-zone=public
firewall-cmd --add-interface=m=$ens
firewall-cmd --add-port=1723/tcp --permanent
firewall-cmd --add-masquerade --permanent
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -i $ens -p gre -j ACCEPT
firewall-cmd --reload
#
cat > /etc/ppp/ip-up.local << END
/sbin/ifconfig $1 mtu 1400
END
chmod +x /etc/ppp/ip-up.local
systemctl restart pptpd.service
systemctl enable pptpd.service


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

荣耀之链

GMT+8, 2025-6-18 05:11 , Processed in 0.015145 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表