LoginSignup
2

More than 5 years have passed since last update.

PPTPサーバをつくる

Posted at

中国にいる間に、PCやスマホを新たに設定する必要に迫られた。
Google Chrome とか Google Play とかダウンロードするのに、VPN経由で行うことになる。
どこのVPNサービスを使うのがいいか? 技術者ならば、自分でVPNサーバを立てよう。

パッケージをダウンロードするためだけの用途なので、PPTPサーバをさくっと作るのでいいかな。

環境

Amazon AWS 米国東部(バージニア北部、US-EAST-1)リージョン
t2.smallインスタンス。昔ながらの Ubuntu-14.04
もともと、別の用事に使っていたもの。

Ubuntu 18.04 からつないでみる

AWSのセキュリティグループの設定は以下のようにしておく。
元々、ポート80,110,22,21,25,587を使っていたサーバなので、それに1723とGREを追加。
image

そのうえで、
https://qiita.com/Amothic/items/b253bbea78e669a14bac
の設定を行う。

うまくつながらない。
/var/log/syslog の表示。

https://qiita.com/tukiyo3/items/a3088de30d2faa8c1e93
を参考に、GREモジュールを読み込みましたが改善しません。


Aug 30 10:08:16 www pptpd[20754]: CTRL: Client 113.88.44.84 control connection started
Aug 30 10:08:17 www pptpd[20754]: CTRL: Starting call (launching pppd, opening GRE)
Aug 30 10:08:17 www pppd[20755]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Aug 30 10:08:17 www pppd[20755]: The remote system is required to authenticate itself
Aug 30 10:08:17 www pppd[20755]: but I couldn't find any suitable secret (password) for it to use to do so.
Aug 30 10:08:17 www pptpd[20754]: GRE: read(fd=6,buffer=7f81216934a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
Aug 30 10:08:17 www pptpd[20754]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
Aug 30 10:08:17 www pptpd[20754]: CTRL: Reaping child PPP[20755]
Aug 30 10:08:17 www pptpd[20754]: CTRL: Client 113.88.44.84 control connection finished

原因、/etc/ppp/chapの
フォーマットを勘違いしてデタラメ書いていた。修正したら・・・


Aug 30 10:48:49 www pptpd[21271]: CTRL: Client 113.88.44.84 control connection started
Aug 30 10:48:50 www pptpd[21271]: CTRL: Starting call (launching pppd, opening GRE)
Aug 30 10:48:50 www pppd[21272]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Aug 30 10:48:50 www pppd[21272]: pppd 2.4.5 started by ubuntu, uid 0
Aug 30 10:48:50 www pppd[21272]: Using interface ppp0
Aug 30 10:48:50 www pppd[21272]: Connect: ppp0 <--> /dev/pts/6
Aug 30 10:48:51 www pppd[21272]: peer from calling number 113.88.44.84 authorized
Aug 30 10:48:51 www pppd[21272]: MPPE required but peer negotiation failed
Aug 30 10:48:52 www pppd[21272]: Connection terminated.
Aug 30 10:48:52 www pppd[21272]: Connect time 0.1 minutes.
Aug 30 10:48:52 www pppd[21272]: Sent 10 bytes, received 15 bytes.
Aug 30 10:48:52 www pppd[21272]: Exit.
Aug 30 10:48:52 www pptpd[21271]: GRE: read(fd=6,buffer=7ff9a495c4a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
Aug 30 10:48:52 www pptpd[21271]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
Aug 30 10:48:52 www pptpd[21271]: CTRL: Reaping child PPP[21272]
Aug 30 10:48:52 www pptpd[21271]: CTRL: Client 113.88.44.84 control connection finished

うーん?
ここを参考に
http://ussr.kiev.ua/ru/VPN-PPTP
MSCHAPにしてみる。

/etc/ppp/pptpd-options
を以下のように直した。


# BSD licensed ppp-2.4.2 upstream with MPPE only, kernel module ppp_mppe.o
# {{{
refuse-pap
refuse-chap
refuse-mschap
# Require the peer to authenticate itself using MS-CHAPv2 [Microsoft
# Challenge Handshake Authentication Protocol, Version 2] authentication.
require-mschap-v2
# Require MPPE 128-bit encryption
# (note that MPPE requires the use of MSCHAP-V2 during authentication)
require-mppe-128


refuse-pap
refuse-chap
require-mschap
# Require the peer to authenticate itself using MS-CHAPv2 [Microsoft
# Challenge Handshake Authentication Protocol, Version 2] authentication.
#require-mschap-v2
# Require MPPE 128-bit encryption
# (note that MPPE requires the use of MSCHAP-V2 during authentication)
#require-mppe-128

以下のようにつながりました。


Aug 30 11:14:17 www pptpd[21547]: CTRL: Client 113.88.44.84 control connection started
Aug 30 11:14:18 www pptpd[21547]: CTRL: Starting call (launching pppd, opening GRE)
Aug 30 11:14:18 www pppd[21548]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Aug 30 11:14:18 www pppd[21548]: pppd 2.4.5 started by ubuntu, uid 0
Aug 30 11:14:18 www pppd[21548]: Using interface ppp0
Aug 30 11:14:18 www pppd[21548]: Connect: ppp0 <--> /dev/pts/6
Aug 30 11:14:19 www pppd[21548]: peer from calling number 113.88.44.84 authorized
Aug 30 11:14:19 www pppd[21548]: MPPE required but peer negotiation failed
Aug 30 11:14:19 www pppd[21548]: Connection terminated.
Aug 30 11:14:19 www pppd[21548]: Connect time 0.1 minutes.
Aug 30 11:14:19 www pppd[21548]: Sent 10 bytes, received 15 bytes.
Aug 30 11:14:19 www pppd[21548]: Exit.
Aug 30 11:14:19 www pptpd[21547]: GRE: read(fd=6,buffer=7fe7d59064a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
Aug 30 11:14:19 www pptpd[21547]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
Aug 30 11:14:19 www pptpd[21547]: CTRL: Reaping child PPP[21548]
Aug 30 11:14:19 www pptpd[21547]: CTRL: Client 113.88.44.84 control connection finished

Androidから繋いでみる

機種:HUAWAY P20 Lite Androidバージョン8.0.0
さて、Androidからつなごうとすると、


Aug 30 11:35:12 www pptpd[21695]: CTRL: Client 112.97.36.78 control connection started
Aug 30 11:35:12 www pptpd[21695]: CTRL: EOF or bad error reading ctrl packet length.
Aug 30 11:35:12 www pptpd[21695]: CTRL: couldn't read packet header (exit)
Aug 30 11:35:12 www pptpd[21695]: CTRL: CTRL read failed
Aug 30 11:35:12 www pptpd[21695]: CTRL: Reaping child PPP[0]
Aug 30 11:35:12 www pptpd[21695]: CTRL: Client 112.97.36.78 control connection finished

となりつながりません。

MTUの問題かな?
/etc/ppp/pptpd-optionsの
mtu 1492をコメントアウトしましたが


Aug 30 11:48:18 www pptpd[21892]: CTRL: Client 112.97.36.78 control connection started
Aug 30 11:48:18 www pptpd[21892]: CTRL: Starting call (launching pppd, opening GRE)
Aug 30 11:48:18 www pppd[21893]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Aug 30 11:48:18 www pppd[21893]: pppd 2.4.5 started by ubuntu, uid 0
Aug 30 11:48:18 www pppd[21893]: Using interface ppp1
Aug 30 11:48:18 www pppd[21893]: Connect: ppp1 <--> /dev/pts/7
Aug 30 11:48:22 www pppd[21893]: peer from calling number 112.97.36.78 authorized
Aug 30 11:48:22 www pppd[21893]: LCP terminated by peer (MPPE required but peer negotiation failed)
Aug 30 11:48:22 www pptpd[21892]: CTRL: EOF or bad error reading ctrl packet length.
Aug 30 11:48:22 www pptpd[21892]: CTRL: couldn't read packet header (exit)
Aug 30 11:48:22 www pptpd[21892]: CTRL: CTRL read failed
Aug 30 11:48:22 www pppd[21893]: Hangup (SIGHUP)
Aug 30 11:48:22 www pppd[21893]: Modem hangup
Aug 30 11:48:22 www pppd[21893]: Connection terminated.
Aug 30 11:48:22 www pppd[21893]: Connect time 0.1 minutes.
Aug 30 11:48:22 www pppd[21893]: Sent 32 bytes, received 10 bytes.
Aug 30 11:48:22 www pptpd[21892]: CTRL: Reaping child PPP[21893]
Aug 30 11:48:22 www pppd[21893]: Exit.
Aug 30 11:48:22 www pptpd[21892]: CTRL: Client 112.97.36.78 control connection finished

あれれ?

なお、mschapv2を有効にしたらこんなになった(Android P20 Lite側で MPPE 有効にしても無効にしても変化はなし)


Aug 30 12:12:53 www pptpd[22138]: CTRL: Client 112.97.36.89 control connection started
Aug 30 12:12:53 www pptpd[22138]: CTRL: EOF or bad error reading ctrl packet length.
Aug 30 12:12:53 www pptpd[22138]: CTRL: couldn't read packet header (exit)
Aug 30 12:12:53 www pptpd[22138]: CTRL: CTRL read failed
Aug 30 12:12:53 www pptpd[22138]: CTRL: Reaping child PPP[0]
Aug 30 12:12:53 www pptpd[22138]: CTRL: Client 112.97.36.89 control connection finished

今回は、Androidについてはさくっとできなかったのであきらめて日本に帰ってから設定しました。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2