[SoftEther VPN] VPN 接続するユーザーアカウントを追加 / 変更する方法

アカウントを追加しようと思った経緯

実家のある岡山に帰省中、東京の自宅で稼働させている SoftEther VPN サーバ (以降 VPN サーバ) へ VPN 接続できなくなっていることに気がついた。

原因は、VPN サーバ側で VPN 接続するユーザーアカウント (以下ユーザー) のパスワードを変更していたことだった。

僕が VPN 接続するのに使っている端末は決まっていて、

  • Chromebook 
  • Peppermint OS

の 2 台です。

Chromebook は普段東京で外出時に持ち歩くことが多く、その時外出先から VPN サーバに接続しています。

Peppermint は岡山にあるパソコンで帰省時にここから VPN サーバに接続しています。

これまで Chromebook であれ Peppermint であれ vpnaccount という名前のユーザーを共用していましたが、これを使い分けることを思いつきました。

  1. chromebook では chromebook というユーザー名で VPN 接続するようにする
  2. Peppermint では peppermint というユーザー名で VPN 接続するようにする

で、今僕は岡山にいるのでとりあえず今日のところは上記 2 をやることにした。

やらないといけないこと

  • VPN サーバ側で新しいユーザーを作る
  • VPN クライアント側で新しいユーザーを使って VPN 接続しにいくように設定する

の 2 つです。

VPN サーバに新しいユーザーを作る方法

今回 CLI のコマンド操作のみで行いました。

まず、VPN サーバに接続します

$ cd /usr/local/vpnserver
$ sudo ./vpncmd
[sudo] password for oreore: 
vpncmd コマンド - SoftEther VPN コマンドライン管理ユーティリティ
SoftEther VPN コマンドライン管理ユーティリティ (vpncmd コマンド)
Version 4.22 Build 9634   (Japanese)
Compiled 2016/11/27 15:23:56 by yagi at pc30
Copyright (c) SoftEther VPN Project. All Rights Reserved.

vpncmd プログラムを使って以下のことができます。

1. VPN Server または VPN Bridge の管理
2. VPN Client の管理
3. VPN Tools コマンドの使用 (証明書作成や通信速度測定)

1 - 3 を選択: 1

接続先の VPN Server または VPN Bridge が動作しているコンピュータの IP アドレスまたはホスト名を指定してください。
'ホスト名:ポート番号' の形式で指定すると、ポート番号も指定できます。
(ポート番号を指定しない場合は 443 が使用されます。)
何も入力せずに Enter を押すと、localhost (このコンピュータ) のポート 443 に接続します。
接続先のホスト名または IP アドレス: 

サーバーに仮想 HUB 管理モードで接続する場合は、仮想 HUB 名を入力してください。
サーバー管理モードで接続する場合は、何も入力せずに Enter を押してください。
接続先の仮想 HUB 名を入力: 
パスワード: ********

VPN Server "localhost" (ポート 443) に接続しました。

VPN Server 全体の管理権限があります。

VPN Server>

HubList コマンドで作成済みの仮想 HUB を確認することができます。

VPN Server>hublist
HubList コマンド - 仮想 HUB の一覧の取得
項目 |値
----------------+-------------------
仮想 HUB 名 |DEFAULT
状態 |オンライン
種類 |スタンドアロン
ユーザー |0
グループ |0
セッション |0
MAC テーブル |0
IP テーブル |0
ログイン回数 |0
最終ログイン日時|2017-04-29 21:23:24
最終通信日時 |2017-04-29 21:23:24
転送バイト数 |0
転送パケット数 |0
----------------+-------------------
仮想 HUB 名 |Hgsnkn_VPN_HUB1
状態 |オンライン
種類 |スタンドアロン
ユーザー |2
グループ |0
セッション |2
MAC テーブル |7
IP テーブル |12
ログイン回数 |207
最終ログイン日時|2017-09-22 22:09:23
最終通信日時 |2017-09-22 22:27:16
転送バイト数 |17,285,827,967
転送パケット数 |91,426,062
コマンドは正常に終了しました。

VPN Server>

今回は上記 Hgsnkn_VPN_HUB1 という仮想 HUB に接続するユーザーを追加するという内容です。

次に対象となる仮想 HUB に接続します

Hub コマンドで仮想 HUB に接続することができます。

VPN Server>Hub Hgsnkn_VPN_HUB1
Hub コマンド - 管理する仮想 HUB の選択
仮想 HUB "Hgsnkn_VPN_HUB1" を選択しました。
コマンドは正常に終了しました。

VPN Server/Hgsnkn_VPN_HUB1>

Hgsnkn_VPN_HUB1 に接続できました。

ユーザーを作成します

UserCreate コマンドで新しいユーザーを作成します。UserList コマンドで作成済みユーザーを表示することができます。

VPN Server/Hgsnkn_VPN_HUB1>UserCreate
UserCreate コマンド - ユーザーの作成
ユーザー名: peppermint

参加するグループ名: 

ユーザーの本名: 

ユーザーの説明: 

コマンドは正常に終了しました。

VPN Server/Hgsnkn_VPN_HUB1>UserList
UserList コマンド - ユーザー一覧の取得
項目            |値
----------------+-------------------------------
ユーザー名      |peppermint
本名            |
所属グループ    |-
説明            |
認証方法        |パスワード認証
ログイン回数    |0
最終ログイン日時|(なし)
有効期限        |無期限
転送バイト数    |0
転送パケット数  |0
----------------+-------------------------------
ユーザー名      |vpnaccount
本名            |
所属グループ    |-
説明            |
認証方法        |パスワード認証
ログイン回数    |207
最終ログイン日時|2017年 9月22日(金) 22時 9分23秒
有効期限        |無期限
転送バイト数    |6,048,010,867
転送パケット数  |13,409,046
コマンドは正常に終了しました。

VPN Server/Hgsnkn_VPN_HUB1>

peppermint ユーザーの作成ができました。

次に UserPasswordSet コマンドで peppermint ユーザーのパスワードを設定します。

VPN Server/Hgsnkn_VPN_HUB1>UserPasswordSet
UserPasswordSet コマンド - ユーザーの認証方法をパスワード認証に設定しパスワードを設定
ユーザー名: peppermint

パスワードを入力してください。キャンセルするには Ctrl+D キーを押してください。

パスワード: *********
確認入力  : *********


コマンドは正常に終了しました。

VPN Server/Hgsnkn_VPN_HUB1>

これで VPN サーバ側に peppermint ユーザーが作られました。

注意点としては、UserPasswordSet コマンドに関しては大文字と小文字を正確に入力しないと機能しないようになってるみたいです。全部小文字で userpasswordset と叩くと、

———-

VPN Server/Hgsnkn_VPN_HUB1>userpassswordset
“userpassswordset”: コマンドが見つかりません。
HELP コマンドで使用できるコマンド一覧を表示できます。
VPN Server/Hgsnkn_VPN_HUB1>

———-

となっちゃいました。

話を戻すと、あとは VPN クライアント側の設定ですが、やることとしては同じユーザー peppermint で VPN サーバへ接続しにいくようにするだけです。

VPN クライアント側で新しいユーザーを使って VPN 接続しにいくように設定する

同じくコマンド操作のみで行いました。

VPN クライアントに接続する

まず vpnclient プロセスを起動させ、その後 vpncmd を実行して VPN クライアントに接続します。

$ sudo ./vpnclient start
The SoftEther VPN Client service has been started.
$ sudo ./vpncmd
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.22 Build 9634   (English)
Compiled 2016/11/27 15:23:56 by yagi at pc30
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: 2

Specify the host name or IP address of the computer that the destination VPN Client is operating on. 
If nothing is input and Enter is pressed, connection will be made to localhost (this computer).
Hostname of IP Address of Destination: localhost

Connected to VPN Client "localhost".

VPN Client>

VPN クライアントにつながりました。

AccountGet コマンドで、現在の VPN サーバへの接続設定を確認します。接続設定というのは下記 connect_to_hgsnkn (この名前は僕がわかりやすいようにつけたものです) のことです。

この VPN サーバへの接続設定 =  connect_to_hgsnkn に変更を加えることが VPN クライアント側での作業になります。

VPN Client>accountget
AccountGet command - Get Setting of VPN Connection Setting 
Name of VPN Connection Setting: connect_to_hgsnkn

Item                                                 |Value
-----------------------------------------------------+--------------------------------
VPN Connection Setting Name                          |connect_to_hgsnkn
Destination VPN Server Host Name                     |oreore.softether.net
Destination VPN Server Port Number                   |443
Destination VPN Server Virtual Hub Name              |Hgsnkn_VPN_HUB1
Proxy Server Type                                    |Direct TCP/IP Connection
Verify Server Certificate                            |Disable
Device Name Used for Connection                      |to_hgsnkn
Authentication Type                                  |Standard Password Authentication
User Name                                            |vpnaccount
Number of TCP Connections to Use in VPN Communication|1
Interval between Establishing Each TCP Connection    |1
Connection Life of Each TCP Connection               |Infinite
Use Half Duplex Mode                                 |Disable
Encryption by SSL                                    |Enable
Data Compression                                     |Disable
Connect by Bridge / Router Mode                      |Disable
Connect by Monitoring Mode                           |Disable
No Adjustment for Routing Table                      |Disable
Do not Use QoS Control Function                      |Disable
The command completed successfully.

VPN Client>

今回の設定の肝は、上記 User Name のところが vpnaccount ユーザーになっているのを peppermint ユーザーに変更することです。

VPN サーバへの接続設定を変更する

AccountUsernameSet コマンドで peppermint ユーザで VPN 接続しに行くように connect_to_hgsnkn に変更を加えます。

VPN Client>accountusernameset
AccountUsernameSet command - Set User Name of User to Use Connection of VPN Connection Setting
Name of VPN Connection Setting: connect_to_hgsnkn

Connecting User Name: peppermint

The auth type for this VPN Connection Setting is currently set as password authentication. After changing the user name, you must use the AccountPasswordSet command to reset the password.
The command completed successfully.

VPN Client>

AccountPasswordSet コマンドで peppermint ユーザーのパスワードを connect_to_hgsnkn に設定します。

VPN Client>accountpasswordset
AccountPasswordSet command - Set User Authentication Type of VPN Connection Setting to Password Authentication
Name of VPN Connection Setting: connect_to_hgsnkn

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

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


Specify standard or radius: standard

The command completed successfully.

VPN Client>exit
$

VPN クライアント側の設定変更はここまでです。

VPN クライアントのプロセスを再起動する

$ sudo ./vpnclient stop
Stopping the SoftEther VPN Client service ...
SoftEther VPN Client service has been stopped.
$ sudo ./vpnclient start
The SoftEther VPN Client service has been started.
$

これで新しいユーザー peppermint で VPN サーバと接続されればオーケーです。

VPN サーバとつながったことの確認

/usr/local/vpnclient/client_log/client_YYYYMMDD.log には以下のような出力が出ます。

( 省略 )

2017-09-22 22:39:11.766 The SoftEther VPN Client Engine has been shut down.
2017-09-22 22:39:11.766 ------------------------------------------------------
2017-09-22 22:39:13.967 ------------------------------------------------------
2017-09-22 22:39:13.967 SoftEther VPN Client Version 4.22 Build 9634   (English)
2017-09-22 22:39:13.967 Compiled 2016/11/27 15:23:56 by yagi at pc30
2017-09-22 22:39:13.967 The SoftEther VPN Client Engine has been started.
2017-09-22 22:39:13.967 Loading configuration file...
2017-09-22 22:39:13.977 Monitoring the directory "/usr/local/vpnclient". If the amount of available free disk space becomes less than 100.00 MBytes, the backup files for log files and configurations that are saved on the sub-directories of this directory will be automatically deleted in the order of oldest first. The amount of free disk space that determines when to start deletion can be modified by changing the "AutoDeleteCheckDiskFreeSpaceMin" item in the configuration file.
2017-09-22 22:39:13.977 The configuration file has been loaded.
2017-09-22 22:39:13.977 Connection processing for VPN Connection Setting "connect_to_hgsnkn" has started.
2017-09-22 22:39:13.977 VPN Connection Setting "connect_to_hgsnkn": Connection operation starting (this is now 1 times).
2017-09-22 22:39:15.959 VPN Connection Setting "connect_to_hgsnkn": Now connected. Session name: "SID-PEPPERMINT-79"

インターフェイスやルーティングテーブルを確認するとそれっぽくなっています。

$ ifconfig vpn_to_hgsnkn
vpn_to_hgsnkn Link encap:Ethernet  HWaddr 00:ac:8e:96:2d:6f  
          inet addr:10.1.0.7  Bcast:10.1.0.255  Mask:255.255.255.0
          inet6 addr: fe80::2ac:8eff:fe96:2d6f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3930 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3393 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:485146 (485.1 KB)  TX bytes:359298 (359.2 KB)

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 wlan0
10.1.0.0        0.0.0.0         255.255.255.0   U         0 0          0 vpn_to_hgsnkn
172.16.1.0      10.1.0.1        255.255.255.0   UG        0 0          0 vpn_to_hgsnkn
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0
$ 

10.1.0.0/24 というセグメントが東京で稼働中の VPN サーバ側にあるセグメントです。

このセグメントの IP (上記 10.1.0.7) が岡山にある Peppermint パソコンに設定されていることが確認できます。

できたでー!

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください