PPTP server

出自 Arch Linux 中文维基

這篇文章或章節的翻譯不反映原文。

原因:Still references rc.d.(在 Talk:PPTP server# 中討論)

點對點隧道協議(PPTP)是一種實現虛擬專用網(VPN)的方法。PPTP 在TCP之上使用一個控制通道和 GRE 隧道操作加密 PPP 數據包。

本條目說明如何在 Arch 中創建 PPTP 伺服器。

安裝[編輯 | 編輯原始碼]

安裝位於官方軟體倉庫的軟體包pptpd

配置[編輯 | 編輯原始碼]

然後編輯文件/etc/pptpd.conf

/etc/pptpd.conf
option /etc/ppp/pptpd-options
localip 172.16.36.1
remoteip 172.16.36.2-254

接著編輯文件/etc/ppp/pptpd-options

/etc/ppp/pptpd-options
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
ms-dns 8.8.8.8
ms-dns 8.8.4.4

/etc/ppp/chap-secrets中添加用戶名和密碼:

/etc/ppp/chap-secrets
<username>     pptpd     <password>   *

/etc/sysctl.d/99-sysctl.conf中啟用IP轉發:

/etc/sysctl.d/99-sysctl.conf
net.ipv4.ip_forward=1

應用 sysctl.conf 修改:

# sysctl --system

iptables 防火牆配置[編輯 | 編輯原始碼]

配置 iptables 設置,允許 PPTP 客戶端訪問:

iptables -A INPUT -i ppp+ -j ACCEPT
iptables -A OUTPUT -o ppp+ -j ACCEPT

iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -p 47 -j ACCEPT
iptables -A OUTPUT -p 47 -j ACCEPT

iptables -F FORWARD
iptables -A FORWARD -j ACCEPT

iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
iptables -A POSTROUTING -t nat -o ppp+ -j MASQUERADE

使用下面命令保存新的 iptables 規則:

# rc.d save iptables

systemd 用戶需要使用:

# iptables-save > /etc/iptables/iptables.rules

閱讀 Iptables 條目獲得更多信息。

ufw 防火牆配置[編輯 | 編輯原始碼]

/etc/default/ufw中,修改默認的轉發規則

/etc/default/ufw
DEFAULT_FORWARD_POLICY=」ACCEPT」

修改/etc/ufw/before.rules,添加如下配置到 *filter 之前

/etc/ufw/before.rules
# nat Table rules
*nat
:POSTROUTING ACCEPT [0:0]

# Allow traffic from clients to eth0
-A POSTROUTING -s 172.16.36.0/24 -o eth0 -j MASQUERADE

# don.t delete the .COMMIT. line or these nat table rules won.t be processed
COMMIT

代開埠 1723:

ufw allow 1723

重啟ufw

ufw disable
ufw enable

啟動[編輯 | 編輯原始碼]

pptpd 軟體包已經提供了 service 文件.

啟動服務:

# systemctl start pptpd.service

開機自動啟動:

# systemctl enable pptpd.service