CentOS 搭建PPTP
1. 安装ppp
yum install -y ppp
2. 安装pptpd
yum install -y pptpd
3. 配置/etc/pptpd.conf
vi /etc/pptpd.conf
localip 192.168.2.1 remoteip 192.168.2.201-230
localip为VPN服务器的虚拟地址,remoteip为连接VPN的客户端的虚拟地址网段。
4. 配置/etc/ppp/options.pptpd
vi /etc/ppp/options.pptpd
ms-dns 8.8.8.8 ms-dns 4.2.2.2
VPN的DNS地址,最好Ping一下连通性。
5. 配置VPN账号和密码以及对应的网段:
vi /etc/ppp/chap-secrets
tester pptpd 111111 *
6. 配置系统转发
vi /etc/sysctl.conf
net.ipv4.ip_forward=1
使配置生效
sysctl -p
7. 配置防火墙
(1) 开启防火墙
systemctl start firewalld
(2) 设置开启启动
systemctl enable firewalld.service
(3) IP伪装, nat转发
firewall-cmd --add-masquerade --permanent firewall-cmd --permanent --direct --passthrough ipv4 -t nat -I POSTROUTING -o eth0 -j MASQUERADE -s 192.168.2.0/24 firewall-cmd --permanent --direct --passthrough ipv4 -t nat -A POSTROUTING -s 192.168.2.201/24 -j SNAT --to-source 192.168.2.1
(4) 开放1723端口
查看
firewall-cmd --list-all
开启
firewall-cmd --permanent --add-port=1723/tcp
(5) 重启防火墙
firewall-cmd --reload
8. 重启 pptpd 服务
systemctl restart pptpd
9. 设置pptpd服务开机启动
systemctl enable pptpd