OpenVPNサーバー構築 (pritunl)

## 参考

* [VPN Server Pritunlの設定](https://tech.blog.home.group.jp/archives/585)
* [VPN ServerにはPritunlが便利 - Qiita](https://qiita.com/syui/items/97f1fcc339ac14b48faf)
* [公式ドキュメント](https://docs.pritunl.com/docs)
* https://hub.docker.com/r/jippi/pritunl/tags

## 起動

```sh:run.sh
docker run \
 -d \
 --name pritunl \
 --cap-add NET_ADMIN \
 --restart=always \
 -p 12321:443/tcp \
 -p 1194:1194/tcp \
 -v $(pwd)/pritunl/:/var/lib/pritunl \
 -v $(pwd)/mongodb/:/var/lib/mongodb \
 jippi/pritunl
```

* BBルーターには`1194/tcp`だけ開ければよい。

## 設定

* https://localhost:12321
    * user : pritunl
    * pass : pritunl
    
![1.PNG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/957cb005-2dc9-3182-2fab-97b8d8c3ecf9.png)

![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/0899159b-397a-dd8a-4a65-5c4669f05b7b.png)

* Users

![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/72de3f2a-36bc-a4cf-4382-9ca6a3645b6b.png)

* Add Organization

![3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/65f9e712-3ee7-420e-b6a8-5d09869ee3be.png)

* 組織の作成

![4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/03f014c9-667f-5fa8-474f-5c5898cf2f1c.png)

* ユーザーの作成 (認証に用いる)

![5.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/d1229e42-810f-3d71-023d-9cdf92e60ea2.png)

![user.PNG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/582849e5-3cc8-3466-1ff3-0f3c63f89587.png)

![server.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/6d7c7550-525c-a66b-2fcd-9ef5f08dd6b5.png)

* Add Server

![add.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/589a1997-2645-688c-6810-27268e9ba975.png)

![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/cc3b978c-fbd9-6285-a423-8c0b530d4f1d.png)

![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/cb7025b9-40a8-a185-71e5-95b48a7c6e95.png)

![3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/2ac41898-7d16-04ab-0d72-7b861653d3b6.png)

* Start Server

![4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/592fdd99-2e59-ae07-d370-feb3e48b35db.png)

* 接続設定のダウンロード

![users.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/ee86c5ae-6df7-9707-b64a-3d961b60ca5e.png)

![dl.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/a7779b22-d72f-a4e4-a853-13028025f2e2.png)

![dl2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/7fe9d280-4c6f-ce90-6a52-288aa5d46b80.png)

* OneDrive などでiOSに転送する。

## iOSにて作業

![1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/cdf41d6e-8664-2448-1465-55f6c9635049.png)
![2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/36ed3519-bab8-9ad7-84c0-e9cc1b308e7e.png)
![3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/87f12573-dc22-47de-e7b7-2f571387cbe5.png)
![4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/9246ef73-99f3-70f2-176e-8d0a9c165c7e.png)
![5.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/f761d501-6020-866a-957b-5075fc1df251.png)
![6.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/a152fc28-7fd9-fdb9-9ff3-ca34dda1ca02.png)
![7.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/25728/4565a5b1-240c-03f6-f9bf-580f761c12d5.png)

完了

## 速度計測

* Ping の TTLが `180ms`の場合、2Mbpsほどしか出なかった。（とても遅い）
* Ping の TTLが `16ms`の場合、50Mbps出た。（充分早い）