LoginSignup
7
7

More than 3 years have passed since last update.

macOSで pptp 接続

Last updated at Posted at 2019-07-06

概要

macOSでPPTP接続がサポートされていないのでコマンドベースで繋げる方法のメモです。
ちょっとだけ繋げたい、たまにしか使わない、わざわざアプリ入れたくないという方におすすめです。

アプリ入れる場合は、ShimoというVPNクライアント(有料)などがあります。

試したOS

macOS Mojave (10.14.5)

追記 2019/11/20

MacをCatalinaにアップグレードすると、そもそもPPTP.ppp 自体がマシンから削除されてしまうので、この方法では接続できません。

手順

pppd コマンドを使って接続します。

設定ファイルを作成する

/etc/ppp/peers/ の下に VPNサーバー名というファイルを作成します。

例えばVPNサーバーが test.vpnserver.com というアドレスの場合以下のようにファイルを作成します。

$ sudo touch /etc/ppp/peers/test.vpnserver.com

設定内容を記述する

作成したファイルに次の内容を貼り付けます。
test.vpnserver.com の部分は自分で作成したファイル名に変更して実行します。

$ sudo vi /etc/ppp/peers/test.vpnserver.com

次の内容をコピーして貼り付けます。

plugin PPTP.ppp
noauth
remoteaddress "<test.vpnserver.com>"
user "<USERNAME>"
password "<PASSWORD>"
redialcount 1
redialtimer 5
idle 1800
# mru 1368
# mtu 1368
receive-all
novj 0:0
ipcp-accept-local
ipcp-accept-remote
refuse-eap
refuse-pap
refuse-chap-md5
hide-password
mppe-stateless
mppe-128
# require-mppe-128
looplocal
nodetach
ms-dns 8.8.8.8
usepeerdns
# ipparam gwvpn
defaultroute
debug

以下の部分を変更します。

"<test.vpnserver.com>":VPNのサーバー名
"<USERNAME>":VPN接続のユーザー名
"<PASSWORD>":VPN接続のパスワード

保存して終了します。

VPN接続時に暗号化しない場合は mppe-128 などをコメントアウトしてください

接続する

pppd call を使って先ほど作成したファイルを指定して接続します。

$ sudo pppd call test.vpnserver.com

これで以下のようなデータが表示されれば、接続されています。
また、接続するとプロセスが起動したままとなります。

Sat Jul  6 14:51:30 2019 : publish_entry SCDSet() failed: Success!
Sat Jul  6 14:51:30 2019 : publish_entry SCDSet() failed: Success!
Sat Jul  6 14:51:30 2019 : PPTP connecting to server 'xxx.xxx.xxx.xxx' (xxx.xxx.xxx.xxx)...
Sat Jul  6 14:51:30 2019 : PPTP connection established.
Sat Jul  6 14:51:30 2019 : PPTP set port-mapping for en0, interface: 10, protocol: 0, privatePort: 0
Sat Jul  6 14:51:30 2019 : using link 0
Sat Jul  6 14:51:30 2019 : Using interface ppp0
Sat Jul  6 14:51:30 2019 : Connect: ppp0 <--> socket[34:17]
...
Sat Jul  6 14:51:31 2019 : Received acsp/dhcp dictionaries
Sat Jul  6 14:51:31 2019 : Committed PPP store
Sat Jul  6 14:51:31 2019 : pptp_wait_input: Address added. previous interface setting (name: en0, address: 192.168.3.3), current interface setting (name: ppp0, family: PPP, address: xxx.xxx.xxx.xxx, subnet: 255.255.0.0, destination: xxx.xxx.xxx.xxx).
Sat Jul  6 14:51:31 2019 : PPTP port-mapping update for en0 ignored: VPN is the Primary interface. Public Address: xxxxxx, Protocol: None, Private Port: 0, Public Port: 0
Sat Jul  6 14:51:31 2019 : PPTP clearing port-mapping for en0
Sat Jul  6 14:51:34 2019 : rcvd [IPV6CP TermReq id=0x1]
...

このプロセスは Ctrl + C とかで終了できないので、めんどくさいですがプロセスIDとかを調べてKillします。

接続終了

ps コマンドで接続を調べます。

$ ps aux | grep pppd

pppdを実行している一覧からプロセスIDを確認します。
*以下の場合は 34283

root    34283   0.0  0.0  4464780   6204   ??  Ss    2:51PM   0:00.02 pppd call test.vpnserver.com

killコマンドで確認したIDを指定して実行します。

$ kill 34283

実行すると、プロセスが起動していた方のターミナルは次のように接続終了データが表示されます。

Sat Jul  6 14:59:57 2019 : Terminating on signal 15.
Sat Jul  6 14:59:57 2019 : ipcp: down
Sat Jul  6 14:59:57 2019 : sent [LCP TermReq id=0x8 "User request"]
Sat Jul  6 14:59:57 2019 : Connection terminated.
Sat Jul  6 14:59:57 2019 : Connect time 8.5 minutes.
Sat Jul  6 14:59:57 2019 : Sent 1405665 bytes, received 6277979 bytes.
Sat Jul  6 14:59:57 2019 : PPTP disconnecting...
Sat Jul  6 14:59:57 2019 : PPTP clearing port-mapping for en0
Sat Jul  6 14:59:57 2019 : PPTP disconnected

これで終了しました。

7
7
0

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
7
7