「PPTP サーバー」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
 
(同期)
2行目: 2行目:
 
[[en:PPTP server]]
 
[[en:PPTP server]]
 
[[ru:PPTP server]]
 
[[ru:PPTP server]]
[[zh-CN:PPTP Server]]
+
[[zh-cn:PPTP server]]
  +
{{Related articles start}}
  +
{{Related|PPTP クライアント}}
  +
{{Related articles end}}
 
[[Wikipedia:PPTP|Point-to-Point Tunneling Protocol]] (PPTP) は仮想プライベートネットワークを実装するための手段です。PPTP は PPP パケットをカプセル化する TCP や GRE トンネルを使ってコントロールチャンネルを使用します。
 
[[Wikipedia:PPTP|Point-to-Point Tunneling Protocol]] (PPTP) は仮想プライベートネットワークを実装するための手段です。PPTP は PPP パケットをカプセル化する TCP や GRE トンネルを使ってコントロールチャンネルを使用します。
   
 
このエントリでは Arch で PPTP サーバーを作成する方法を示します。
 
このエントリでは Arch で PPTP サーバーを作成する方法を示します。
   
{{Warning|The PPTP protocol is inherently insecure. See http://poptop.sourceforge.net/dox/protocol-security.phtml for details.}}
+
{{Warning|PPTP プロトコルは性質上、セキュアではありません。詳しくは http://poptop.sourceforge.net/dox/protocol-security.phtml を参照。}}
   
 
== インストール ==
 
== インストール ==
15行目: 18行目:
 
== 設定 ==
 
== 設定 ==
   
{{Tip|Configuration examples can be found in the {{ic|/usr/share/doc/pptpd}} directory.}}
+
{{Tip|設定例が {{ic|/usr/share/doc/pptpd}} ディレクトリに存在します。}}
   
  +
典型的な設定は以下のようになります:
A typical configuration may look like:
 
   
 
{{hc|/etc/pptpd.conf|
 
{{hc|/etc/pptpd.conf|
33行目: 36行目:
 
}}
 
}}
   
Now create the pppd options file, in our example this is {{ic|/etc/ppp/options.pptpd}}:
+
それから pppd options ファイルを作成してください。この例では {{ic|/etc/ppp/options.pptpd}} になります:
   
 
{{hc|/etc/ppp/options.pptpd|
 
{{hc|/etc/ppp/options.pptpd|
68行目: 71行目:
 
}}
 
}}
   
  +
{{Note|ファイルのパース時に問題が発生しないように、上記のファイルの最後の行は空行にしてください。}}
{{Note|Ensure that empty line at the end of the file exists to prevent possible parsing issues.}}
 
   
  +
そしてユーザーを認証するための認証情報を記述したファイルを作成します:
Now create credentials file for authenticating users:
 
   
 
{{hc|/etc/ppp/chap-secrets|
 
{{hc|/etc/ppp/chap-secrets|
77行目: 80行目:
 
}}
 
}}
   
  +
上記の場合、ユーザー名が ''user2'' でパスワードが ''123'' で認証されます。
Now you can be authenticated with ''user2'' as username and ''123'' for password.
 
   
 
sysctl 設定ファイル {{ic|/etc/sysctl.d/30-ipforward.conf}} を作成してカーネルのパケット転送を有効化し、サブネットにアクセスできるクライアントに接続できるようにします ([[インターネット共有#パケット転送の有効化]]も参照):
 
sysctl 設定ファイル {{ic|/etc/sysctl.d/30-ipforward.conf}} を作成してカーネルのパケット転送を有効化し、サブネットにアクセスできるクライアントに接続できるようにします ([[インターネット共有#パケット転送の有効化]]も参照):
85行目: 88行目:
 
}}
 
}}
   
  +
最後に sysctl に設定の変更を反映させてください:
Now apply changes to let the sysctl configuration take effect:
 
   
 
# sysctl --system
 
# sysctl --system
91行目: 94行目:
 
=== iptables ファイアウォールの設定 ===
 
=== iptables ファイアウォールの設定 ===
   
  +
iptables の設定を変更して PPTP クライアントからアクセスできるようにします:
Configure your iptables settings to enable access for PPTP Clients
 
   
 
{{bc|
 
{{bc|
113行目: 116行目:
 
iptables -A POSTROUTING -t nat -o ppp+ -j MASQUERADE
 
iptables -A POSTROUTING -t nat -o ppp+ -j MASQUERADE
 
}}
 
}}
  +
{{Note|"eth0" はサーバーに接続するときに使用する実際のイーサネットインターフェイスに置き換えてください。}}
Now save the new iptables rules with:
 
  +
新しい iptables のルールを保存するには:
   
 
# iptables-save > /etc/iptables/iptables.rules
 
# iptables-save > /etc/iptables/iptables.rules
121行目: 125行目:
 
=== UFW ファイアウォールの設定 ===
 
=== UFW ファイアウォールの設定 ===
   
  +
ufw の設定を変更して PPTP クライアントがアクセスできるようにします。
Configure your ufw settings to enable access for PPTP Clients.
 
   
  +
{{ic|/etc/default/ufw}} のデフォルトの転送ポリシーを変更してください:
You must change default forward policy in {{ic|/etc/default/ufw}}
 
   
 
{{hc|/etc/default/ufw|2=
 
{{hc|/etc/default/ufw|2=
129行目: 133行目:
 
}}
 
}}
   
Now change {{ic|/etc/ufw/before.rules}}, add following code after header and before *filter line
+
そして {{ic|/etc/ufw/before.rules}} を編集して、ヘッダの後、*filter 行の前に以下のコードを追加します:
   
 
{{hc|/etc/ufw/before.rules|
 
{{hc|/etc/ufw/before.rules|
143行目: 147行目:
 
}}
 
}}
   
Open pptp port 1723
+
pptp のポート 1723 を開きます:
   
 
{{bc|
 
{{bc|
149行目: 153行目:
 
}}
 
}}
   
  +
ufw を再起動して変更を適用してください:
Restart ufw for good measure
 
   
 
{{bc|
 
{{bc|
164行目: 168行目:
 
他のサービスと同じように、エラーを調査するときは [[Systemd#トラブルシューティング]] を見てください。
 
他のサービスと同じように、エラーを調査するときは [[Systemd#トラブルシューティング]] を見てください。
   
=== Error 619 on the client side ===
+
=== クライアント側で Error 619 が発生する ===
   
  +
{{ic|/etc/pptpd.conf}} 内の {{ic|logwtmp}} オプションを探してコメントアウトしてください。このオプションが有効になっている場合、クライアントの接続と切断を記録するのに ''wtmp'' が使われます。
Search for the {{ic|logwtmp}} option in {{ic|/etc/pptpd.conf}} and comment it out. When this is enabled, ''wtmp'' will be used to record client connections and disconnections.
 
   
 
#logwtmp
 
#logwtmp
172行目: 176行目:
 
=== pptpd[xxxxx]: Long config file line ignored ===
 
=== pptpd[xxxxx]: Long config file line ignored ===
   
Add a blank line at the end of {{ic|/etc/pptpd.conf}}. [http://sourceforge.net/p/poptop/bugs/35/]
+
{{ic|/etc/pptpd.conf}} の最後の行に空行を追加してください [http://sourceforge.net/p/poptop/bugs/35/]
   
 
=== ppp0: ppp: compressor dropped pkt ===
 
=== ppp0: ppp: compressor dropped pkt ===
   
If you have this error while a client is connected to the server, add the following script to {{ic|/etc/ppp/ip-up.d/mppefixmtu.sh}}:
+
クライアントからサーバーに接続する際にこのエラーが表示される場合、以下のスクリプトを {{ic|/etc/ppp/ip-up.d/mppefixmtu.sh}} に追加してください:
   
 
#!/bin/sh
 
#!/bin/sh
183行目: 187行目:
 
ip link set $1 mtu $FIXED_MTU
 
ip link set $1 mtu $FIXED_MTU
   
  +
スクリプトに実行可能属性を付与:
Make the script executable:
 
   
 
# chmod 755 /etc/ppp/ip-up.d/mppefixmtu.sh
 
# chmod 755 /etc/ppp/ip-up.d/mppefixmtu.sh

2016年5月5日 (木) 21:55時点における版

関連記事

Point-to-Point Tunneling Protocol (PPTP) は仮想プライベートネットワークを実装するための手段です。PPTP は PPP パケットをカプセル化する TCP や GRE トンネルを使ってコントロールチャンネルを使用します。

このエントリでは Arch で PPTP サーバーを作成する方法を示します。

警告: PPTP プロトコルは性質上、セキュアではありません。詳しくは http://poptop.sourceforge.net/dox/protocol-security.phtml を参照。

インストール

公式リポジトリpptpdインストールしてください。

設定

ヒント: 設定例が /usr/share/doc/pptpd ディレクトリに存在します。

典型的な設定は以下のようになります:

/etc/pptpd.conf
# See man pptpd.conf to get more information about this file

# pppd options file. By default, /etc/ppp/options is used
option /etc/ppp/options.pptpd

# Server IP in local network
localip 192.168.1.2

# IP address ranges used to assign IPs to new connecting clients
# Here we define two ranges for our 192.168.1.* subnet: 234-238 and 245
remoteip 192.168.1.234-238,192.168.1.245

それから pppd の options ファイルを作成してください。この例では /etc/ppp/options.pptpd になります:

/etc/ppp/options.pptpd
# Read man pppd to see the full list of available options

# The name of the local system for authentication purposes
name pptpd

# Refuse PAP, CHAP or MS-CHAP connections but accept connections with
# MS-CHAPv2 or MPPE with 128-bit encryption
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128

# Add entry to the ARP system table
proxyarp

# For the serial device to ensure exclusive access to the device
lock

# Disable BSD-Compress and Van Jacobson TCP/IP header compression
nobsdcomp
novj
novjccomp

# Disable file logging
nolog

# DNS servers for Microsoft Windows clients. Using Google's public servers here
ms-dns 8.8.8.8
ms-dns 8.8.4.4
ノート: ファイルのパース時に問題が発生しないように、上記のファイルの最後の行は空行にしてください。

そしてユーザーを認証するための認証情報を記述したファイルを作成します:

/etc/ppp/chap-secrets
# <username> <server name> <password> <ip addresses>
user2    pptpd    123    *

上記の場合、ユーザー名が user2 でパスワードが 123 で認証されます。

sysctl 設定ファイル /etc/sysctl.d/30-ipforward.conf を作成してカーネルのパケット転送を有効化し、サブネットにアクセスできるクライアントに接続できるようにします (インターネット共有#パケット転送の有効化も参照):

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

最後に sysctl に設定の変更を反映させてください:

# sysctl --system

iptables ファイアウォールの設定

iptables の設定を変更して PPTP クライアントからアクセスできるようにします:

# Accept all packets via ppp* interfaces (for example, ppp0)
iptables -A INPUT -i ppp+ -j ACCEPT
iptables -A OUTPUT -o ppp+ -j ACCEPT

# Accept incoming connections to port 1723 (PPTP)
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT

# Accept GRE packets
iptables -A INPUT -p 47 -j ACCEPT
iptables -A OUTPUT -p 47 -j ACCEPT

# Enable IP forwarding
iptables -F FORWARD
iptables -A FORWARD -j ACCEPT

# Enable NAT for eth0 и ppp* interfaces
iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE
iptables -A POSTROUTING -t nat -o ppp+ -j MASQUERADE
ノート: "eth0" はサーバーに接続するときに使用する実際のイーサネットインターフェイスに置き換えてください。

新しい iptables のルールを保存するには:

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

詳細は Iptables を読んでください。

UFW ファイアウォールの設定

ufw の設定を変更して PPTP クライアントがアクセスできるようにします。

/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

# commit to apply changes
COMMIT

pptp のポート 1723 を開きます:

ufw allow 1723

ufw を再起動して変更を適用してください:

ufw disable
ufw enable

サーバーの起動

pptpd.service を使って PPTP サーバーを起動・有効化してください。

トラブルシューティング

他のサービスと同じように、エラーを調査するときは Systemd#トラブルシューティング を見てください。

クライアント側で Error 619 が発生する

/etc/pptpd.conf 内の logwtmp オプションを探してコメントアウトしてください。このオプションが有効になっている場合、クライアントの接続と切断を記録するのに wtmp が使われます。

#logwtmp

pptpd[xxxxx]: Long config file line ignored

/etc/pptpd.conf の最後の行に空行を追加してください [1]

ppp0: ppp: compressor dropped pkt

クライアントからサーバーに接続する際にこのエラーが表示される場合、以下のスクリプトを /etc/ppp/ip-up.d/mppefixmtu.sh に追加してください:

#!/bin/sh
CURRENT_MTU="`ip link show $1 | grep -Po '(?<=mtu )([0-9]+)'`"
FIXED_MTU="`expr $CURRENT_MTU + 4`"
ip link set $1 mtu $FIXED_MTU

スクリプトに実行可能属性を付与:

# chmod 755 /etc/ppp/ip-up.d/mppefixmtu.sh

参照: [2]