CentOS 7.X 安裝VPN PPTP

  1. 安裝yum第三方EPEL套件庫
1
2

sudo yum install epel-release -y

清除快取

1
2

sudo yum clean all -y

更新套件庫

1
2

sudo yum update -y
  1. 安裝PPTP
1
2

sudo yum install ppp pptpd -y

01

  1. 備份設定擋
1
2

cp /etc/pptpd.conf /etc/pptpd.conf.bak
  1. 打開/etc/pptpd.conf,拉到最下面新增
1
2
3

localip 10.0.10.1
remoteip 10.0.10.2-254
  1. 備份設定擋
1
2

cp /etc/ppp/options.pptpd /etc/ppp/options.pptpd.bak
  1. 搜尋ms-dns,將前面#去掉如下
1
2
3

ms-dns 8.8.8.8
ms-dns 8.8.4.4
  1. 備份設定擋
1
2

cp /etc/sysctl.conf /etc/sysctl.conf.bak
  1. 將下面的設定貼上去
1
2
3
4
5
6
7
8
9
10
11
12
13
14

net.core.wmem_max = 12582912
net.core.rmem_max = 12582912
net.ipv4.tcp_rmem = 10240 87380 12582912
net.ipv4.tcp_wmem = 10240 87380 12582912
net.core.wmem_max = 12582912
net.core.rmem_max = 12582912
net.ipv4.tcp_rmem = 10240 87380 12582912
net.ipv4.tcp_wmem = 10240 87380 12582912
net.core.wmem_max = 12582912
net.core.rmem_max = 12582912
net.ipv4.tcp_rmem = 10240 87380 12582912
net.ipv4.tcp_wmem = 10240 87380 12582912
net.ipv4.ip_forward = 1
  1. 打開/etc/rc.d/rc.local,新增設定
1
2

iptables -t nat -A POSTROUTING -s 10.0.10.0/24 -o eth0 -j MASQUERADE
  1. 設定防火牆
1
2
3
4
5
6
7

firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -i eth0 -p tcp --dport 1723 -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter INPUT 0 -p gre -j ACCEPT
firewall-cmd --permanent --direct --add-rule ipv4 filter POSTROUTING 0 -t nat -o eth0 -j MASQUERADE
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
firewall-cmd --reload
  1. 設定帳號密碼/etc/ppp/chap-secrets
1
2

username pptpd password *
  1. 啟動pptp
1
2
3

service pptpd start
chkconfig pptpd on

參考:

  1. CentOS 7 快速部署 PPTP VPN 服務
  2. Setup PPTP Server on CentOS