CentOS 使用 PPTP 搭建 VPN 服务器

230人浏览 / 1人评论

参考

https://blog.csdn.net/jake8168/article/details/129215044

https://blog.csdn.net/weixin_41432198/article/details/129193495

https://blog.csdn.net/m0_61385351/article/details/128615332

https://blog.csdn.net/m0_61385351/article/details/128615332

前提

modprobe ppp-compress-18 && echo success
应该输出”success”,如果不支持尝试安装:
yum install kernel-devel


# 云服务器开放1723端口

安装

yum install epel-release
yum install ppp pptpd net-tools iptables-services -y

vim /etc/pptpd.conf
option /etc/ppp/options.pptpd
logwtmp
localip 10.0.0.6  # 设置pptp虚拟网卡接口IP地址(注意:不是服务器的公网IP,而是服务器的内网ip,使用 ip addr 查看)
remoteip 10.0.0.6-254 # 为拨入VPN的用户动态分配的IP地址池,一般分配当前ip之后的即可

vim /etc/ppp/options.pptpd
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8	#这里是设置windows连接时候的DNS首地址
ms-dns 8.8.4.4	#这里是设置windows连接时候的DNS备用地址
proxyarp
lock
nobsdcomp 
novj
novjccomp
nologfd

# 设置用户名和密码,数据之间用tab隔开
vim /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client    server  secret          IP addresses
   test       pptpd   123456        * 

vim /etc/sysctl.conf
# 将 net.ipv4.ip_forward = 0 修改为 net.ipv4.ip_forward = 1
sysctl -p

systemctl start pptpd
systemctl enable pptpd

firewall-cmd --add-masquerade
firewall-cmd --permanent --add-masquerade
firewall-cmd --query-masquerade
firewall-cmd --permanent --zone=public --add-port=1723/tcp
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -i ens32 -p gre -j ACCEPT
firewall-cmd --permanent --zone=public --add-port=1723/tcp
firewall-cmd --reload
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
# 或者关闭防火墙
systemctl stop firewalld

Windows 连接

全部评论

2024-11-02 23:28
Awesome! Its truly awesome paragraph, I have got mudh clear idea about from this article. https://www.waste-ndc.pro/community/profile/tressa79906983/