SoftEather VPNを試した

野暮用で自宅のPCからの通信をクラウド(Azure)に構築したVPNサーバを経由させてインターネットに繋ぎたかった。これだけの用途なら本当に簡単にできたので、今後も何かあれば使っていきたい。

VMの作成

AzureでLinuxVMを作る。B1lsで月額550円ぐらい。ディストリビューションUbuntu 18.04にした。

ポートの穴あけ

AWSのセキュリティグループ的なものがAzureのNetwork Security Groupというものであるので、これで穴あけを行う。

VPN Server側はTCP:443を開けておけばよいらしい。気休めに接続元IPも絞っておく

VPN Serverのインストール

ドキュメントに書いてある通りに従う。

7.3 Linux へのインストールと初期設定 - SoftEther VPN プロジェクト

ただ、gccとmakeは必要なのであらかじめ入れておく。

apt update
apt install -y gcc make

起動スクリプトはinit.dを使う古い方法で、このままでは自動起動ができない。Systemd用に設定ファイルを書き起こす必要があるけど今回は一時的に必要なだけなので自動起動まではしない。

VPN Serverの設定

vpncmdを使って設定を行う

ryozi@softeather-vpn-example:/usr/local/vpnserver$ sudo ./vpncmd
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.34 Build 9745   (English)
Compiled 2020/04/05 23:39:56 by buildsan at crosswin
Copyright (c) SoftEther VPN Project. All Rights Reserved.

By using vpncmd program, the following can be achieved.

1. Management of VPN Server or VPN Bridge
2. Management of VPN Client
3. Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool)

Select 1, 2 or 3: 1

HUBを選択する。初期状態で"DEFAULT"がいるのでこれを指定する。

VPN Server>Hub DEFAULT
Hub command - Select Virtual Hub to Manage
The Virtual Hub "DEFAULT" has been selected.
The command completed successfully.

ユーザを作成。VPN Client接続で使う。

VPN Server/DEFAULT>UserCreate
UserCreate command - Create User
User Name: ryozi

Assigned Group Name:

User Full Name: ryozi

User Description: ryozi

The command completed successfully.

作成したユーザのパスワードを設定。VPN Client接続で使う。

VPN Server/DEFAULT>UserPasswordSet
UserPasswordSet command - Set Password Authentication for User Auth Type and Set Password
User Name: ryozi

Please enter the password. To cancel press the Ctrl+D key.

Password: ************
Confirm input: ************


The command completed successfully.

この時点でつながるようにはなったが、IPが割り当たらず困った。よくよく考えれば、DHCPサーバなんてないので当然だった。

何かないかとドキュメントを眺めたら Secure NATという機能の中に「DHCP サーバーとしての利用」があったのでこれが使えそうと思った。(やりたいことはNATなのでこれが正しい気もする)

3.7 仮想 NAT および仮想 DHCP サーバー - SoftEther VPN プロジェクト

SecureNatを有効化。

VPN Server/DEFAULT>SecureNatEnable
SecureNatEnable command - Enable the Virtual NAT and DHCP Server Function (SecureNat Function)
The command completed successfully.

VPN Server側は以上。

VPN Clientのインストール・設定

VPN ClientはWindows

VPN設定はこんな感じ。接続先のホスト名はVMのパブリックIPでもよい。特に何もしていない。

f:id:ryousanngata:20201108224324p:plain

サーバ証明書は自己署名な証明書なので、「サーバ証明書を必ず検証する」にチェックするようにすると確認が発生するようになる。

後はつながった後に、ブラウザを開いてIPを確認する。AzureのVMに振られたIPであることを確認する。