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