LoginSignup
34
40

More than 5 years have passed since last update.

SoftEther VPN でPC間接続VPNをする (Client編)

Last updated at Posted at 2017-03-16

はじめに

SoftEther VPN でPC間接続VPNをする (Server編)の続きです。

SoftEther VPNを使用してPC 間接続 VPNを構築することを目的としたインストール手順、および、設定を書いていきます。

環境

・Amazon Linux(VPN Client側)
・Windows 10 Pro(VPN Server Manager(GUI) 実行用)

$ uname -a
Linux ip-XXX-XXX-XXX-XXX 4.4.51-40.58.amzn1.x86_64 #1 SMP Tue Feb 28 21:57:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

ダウンロード

SoftEther ダウンロード センターからダウンロードします。
今回の対象は以下の通りです。

ダウンロードするソフトウェア:SoftEther VPN (Freeware)
コンポーネント:SoftEther VPN Client
プラットフォーム:Linux
CPU:Intel x64 / AMD 64 (64bit)

インストール 下準備

yum update

$ sudo yum update

EPEL有効化

$ sudo yum-config-manager --enable epel

ダウンロードファイル配備

ここでは以下のように配備します。

$ mkdir ~/Installer
$ mv ~/softether-vpnclient-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz ~/Installer/

インストール

インストールはVPNクライアントのLinux用のドキュメントが無いので、VPNサーバのインストールドキュメントを参考に進めます。
7.3 Linux へのインストールと初期設定

必要なソフトウェアおよびライブラリの確認

gccをインストールしておきます。

$ sudo yum install gcc

パッケージの解凍

tarで解凍します。

$ tar xzvf softether-vpnclient-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz
vpnclient/
vpnclient/Makefile
vpnclient/.install.sh
vpnclient/ReadMeFirst_License.txt
vpnclient/Authors.txt
vpnclient/ReadMeFirst_Important_Notices_ja.txt
vpnclient/ReadMeFirst_Important_Notices_en.txt
vpnclient/ReadMeFirst_Important_Notices_cn.txt
vpnclient/code/
vpnclient/code/vpnclient.a
vpnclient/code/vpncmd.a
vpnclient/lib/
vpnclient/lib/libcharset.a
vpnclient/lib/libcrypto.a
vpnclient/lib/libedit.a
vpnclient/lib/libiconv.a
vpnclient/lib/libintelaes.a
vpnclient/lib/libncurses.a
vpnclient/lib/libssl.a
vpnclient/lib/libz.a
vpnclient/lib/License.txt
vpnclient/hamcore.se2

実行可能ファイルの生成

makeを実行して、使用権許諾契約書を読むために1を選択します。

$ cd vpnserver/
$ make
--------------------------------------------------------------------

SoftEther VPN Client (Ver 4.22, Build 9634, Intel x64 / AMD64) for Linux Install Utility
Copyright (c) SoftEther Project at University of Tsukuba, Japan. All Rights Reserved.

--------------------------------------------------------------------


Do you want to read the License Agreement for this software ?

 1. Yes
 2. No

Please choose one of above number:

1

使用権許諾契約書を読んで承諾したら、それぞれ1をクリックします。

Did you read and understand the License Agreement ?
(If you couldn't read above text, Please read 'ReadMeFirst_License.txt'
 file with any text editor.)

 1. Yes
 2. No

Please choose one of above number:
1


Did you agree the License Agreement ?

1. Agree
2. Do Not Agree

Please choose one of above number:
1

make[1]: Entering directory `/home/ec2-user/Installer/vpnclient'
Preparing SoftEther VPN Client...
ranlib lib/libcharset.a
ranlib lib/libcrypto.a
ranlib lib/libedit.a
ranlib lib/libiconv.a
ranlib lib/libintelaes.a
ranlib lib/libncurses.a
ranlib lib/libssl.a
ranlib lib/libz.a
ranlib code/vpnclient.a
gcc code/vpnclient.a -O2 -fsigned-char -pthread -m64 -lm -ldl -lrt -lpthread -L./ lib/libssl.a lib/libcrypto.a lib/libiconv.a lib/libcharset.a lib/libedit.a lib/libncurses.a lib/libz.a lib/libintelaes.a -o vpnclient
ranlib code/vpncmd.a
gcc code/vpncmd.a -O2 -fsigned-char -pthread -m64 -lm -ldl -lrt -lpthread -L./ lib/libssl.a lib/libcrypto.a lib/libiconv.a lib/libcharset.a lib/libedit.a lib/libncurses.a lib/libz.a lib/libintelaes.a -o vpncmd

--------------------------------------------------------------------
The preparation of SoftEther VPN Client is completed !


*** How to switch the display language of the SoftEther VPN Client Service ***
SoftEther VPN Client supports the following languages:
  - Japanese
  - English
  - Simplified Chinese

You can choose your prefered language of SoftEther VPN Client at any time.
To switch the current language, open and edit the 'lang.config' file.


*** How to start the SoftEther VPN Client Service ***

Please execute './vpnclient start' to run the SoftEther VPN Client Background Service.
And please execute './vpncmd' to run the SoftEther VPN Command-Line Utility to configure SoftEther VPN Client.

Of course, you can use the VPN Server Manager GUI Application for Windows / Mac OS X on the other Windows / Mac OS X computers in order to configure the SoftEther VPN Client remotely.


*** For Windows users ***
You can download the SoftEther VPN Server Manager for Windows
from the http://www.softether-download.com/ web site.
This manager application helps you to completely and easily manage the VPN server services running in remote hosts.


*** For Mac OS X users ***
In April 2016 we released the SoftEther VPN Server Manager for Mac OS X.
You can download it from the http://www.softether-download.com/ web site.
VPN Server Manager for Mac OS X works perfectly as same as the traditional Windows versions. It helps you to completely and easily manage the VPN server services running in remote hosts.

--------------------------------------------------------------------

make[1]: Leaving directory `/home/ec2-user/Installer/vpnclient'

VPN Client の配置

makeしたファイルをそのまま移動させます。

$ cd ..
$ sudo mv vpnclient /usr/local
$ ls -l /usr/local/vpnclient/
total 10476
-rwxrwxr-x 1 ec2-user ec2-user    2784 Nov 27 07:03 Authors.txt
drwxrwxr-x 2 ec2-user ec2-user    4096 Mar 16 05:13 code
-rwxrwxr-x 1 ec2-user ec2-user 1296225 Nov 27 07:03 hamcore.se2
drwxrwxr-x 2 ec2-user ec2-user    4096 Mar 16 05:13 lib
-rwxrwxr-x 1 ec2-user ec2-user    2873 Nov 27 07:03 Makefile
-rwxrwxr-x 1 ec2-user ec2-user   30801 Nov 27 07:03 ReadMeFirst_Important_Notices_cn.txt
-rwxrwxr-x 1 ec2-user ec2-user   36296 Nov 27 07:03 ReadMeFirst_Important_Notices_en.txt
-rwxrwxr-x 1 ec2-user ec2-user   50695 Nov 27 07:03 ReadMeFirst_Important_Notices_ja.txt
-rwxrwxr-x 1 ec2-user ec2-user   58932 Nov 27 07:03 ReadMeFirst_License.txt
-rwxrwxr-x 1 ec2-user ec2-user 4608379 Mar 16 05:13 vpnclient
-rwxrwxr-x 1 ec2-user ec2-user 4612305 Mar 16 05:13 vpncmd

権限を変更しておきます。

$ sudo chown -R root:root /usr/local/vpnclient/
$ cd /usr/local/vpnclient/
$ sudo chmod 600 *
$ sudo chmod 700 vpncmd
$ sudo chmod 700 vpnclient
$ ls -l
total 10476
-rw------- 1 root root    2784 Nov 27 07:03 Authors.txt
drw------- 2 root root    4096 Mar 16 05:13 code
-rw------- 1 root root 1296225 Nov 27 07:03 hamcore.se2
drw------- 2 root root    4096 Mar 16 05:13 lib
-rw------- 1 root root    2873 Nov 27 07:03 Makefile
-rw------- 1 root root   30801 Nov 27 07:03 ReadMeFirst_Important_Notices_cn.txt
-rw------- 1 root root   36296 Nov 27 07:03 ReadMeFirst_Important_Notices_en.txt
-rw------- 1 root root   50695 Nov 27 07:03 ReadMeFirst_Important_Notices_ja.txt
-rw------- 1 root root   58932 Nov 27 07:03 ReadMeFirst_License.txt
-rwx------ 1 root root 4608379 Mar 16 05:13 vpnclient
-rwx------ 1 root root 4612305 Mar 16 05:13 vpncmd

vpncmd の check コマンドによる動作チェック

vpncmdを実行して、VPN Toolsで動作チェックを行います。

$ 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: 3

VPN Tools has been launched. By inputting HELP, you can view a list of the commands that can be used.

VPN Tools>check
Check command - Check whether SoftEther VPN Operation is Possible
---------------------------------------------------
SoftEther VPN Operation Environment Check Tool

Copyright (c) SoftEther VPN Project.
All Rights Reserved.

If this operation environment check tool is run on a system and that system passes, it is most likely that SoftEther VPN software can operate on that system. This check may take a while. Please wait...

Checking 'Kernel System'...
              Pass
Checking 'Memory Operation System'...
              Pass
Checking 'ANSI / Unicode string processing system'...
              Pass
Checking 'File system'...
              Pass
Checking 'Thread processing system'...
              Pass
Checking 'Network system'...
              Pass

All checks passed. It is most likely that SoftEther VPN Server / Bridge can operate normally on this system.

The command completed successfully.

VPN Tools>exit

スタートアップスクリプトへの登録

サービスとして起動させる為に、以下のようにスタートアップスクリプトを登録します。

$ sudo vim /etc/init.d/vpnclient
/etc/init.d/vpnclient
#!/bin/sh
#
# chkconfig: 2345 99 01
# description: SoftEther VPN Client

DAEMON=/usr/local/vpnclient/vpnclient
LOCK=/var/lock/subsys/vpnclient

test -x $DAEMON || exit 0

case "$1" in
  start)
    $DAEMON start
    touch $LOCK
    ;;
  stop)
    $DAEMON stop
    rm $LOCK
    ;;
  restart)
    $DAEMON stop
    sleep 3
    $DAEMON start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac

exit 0

権限設定をしておきます。

$ sudo chmod 755 /etc/init.d/vpnclient

自動起動設定をしておきます。

$ sudo chkconfig --add vpnclient
$ sudo chkconfig --list vpnclient
vpnserver       0:off   1:off   2:on    3:on    4:on    5:on    6:off

サービスの開始と停止

以下のコマンドでサービスを開始できます。
ただ、自動起動の確認として、サーバを再起動したほうが良いかと思います。

$ sudo /etc/init.d/vpnclient start

クライアントの設定・管理

次に、クライアントの設定をvpncmdで行っていきます。
vpncmdについてはこちらに記載されています。

なお、以下の設定は「VPN クライアント接続マネージャ」の「別のコンピュータのSoftEther VPN Clientの管理」からでもできます。
その場合はTCPポート9930を解放しておく必要があります。

$ cd /usr/local/vpnclient/
$ 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: #リターン

Connected to VPN Client "localhost".

VPN Client>

新規仮想 LAN カードの作成

NicCreateコマンドで作成します。
ここでは"VPN"という名前で作成します。

VPN Client>NicCreate VPN
NicCreate command - Create New Virtual Network Adapter
The command completed successfully.

VPN Client>NicList
NicList command - Get List of Virtual Network Adapters
Item                        |Value
----------------------------+-----------------------------------
Virtual Network Adapter Name|VPN
Status                      |Enabled
MAC Address                 |00ACDE96CE73
Version                     |Version 4.22 Build 9634   (English)
The command completed successfully.

VPN Client>

新しい接続設定の作成

AccountCreateコマンドで作成します。
ここでは"VPN_Server"という名前で作成します。

サーバのホスト名や、HUB名、ユーザ名はVPNサーバ設定で行った設定を参照して下さい。
NIC名はLAN カードの作成で作成したNIC名です。

VPN Client>AccountCreate VPN_Server /SERVER:XXX.XXX.XXX.XXX:443 /HUB:VPN /USERNAME:admin /NICNAME:VPN
AccountCreate command - Create New VPN Connection Setting
The command completed successfully.

VPN Client>AccountList
AccountList command - Get List of VPN Connection Settings
Item                        |Value
----------------------------+--------------------------------------------
VPN Connection Setting Name |VPN_Server
Status                      |Offline
VPN Server Hostname         |XXX.XXX.XXX.XXX:443 (Direct TCP/IP Connection)
Virtual Hub                 |VPN
Virtual Network Adapter Name|VPN
The command completed successfully.

接続設定のユーザー認証の種類をパスワード認証に設定

AccountPasswordSetコマンドで設定します。
パスワードはVPNサーバ設定で行った設定を参照して下さい。

VPN Client>AccountPasswordSet VPN_Server /PASSWORD:Passw0rd /TYPE:standard
AccountPasswordSet command - Set User Authentication Type of VPN Connection Setting to Password Authentication
The command completed successfully.

VPN Client>

接続設定をスタートアップ接続に設定

AccountPasswordSetコマンドで設定します。
パスワードはVPNサーバ設定で行った設定を参照して下さい。

VPN Client>AccountStartupSet VPN_Server
AccountStartupSet command - Set VPN Connection Setting as Startup Connection
The command completed successfully.

VPN Client>exit

NICの設定

次に、下記のように設定しNICにDHCPでIPが振られるように設定します。

$ sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-vpn
_vpn
$ sudo vim /etc/sysconfig/network-scripts/ifcfg-vpn_vpn

変更点としてはDEVICE名をNIC名にするのと、PEERDNSをnoに設定する2点となります。

/etc/sysconfig/network-scripts/ifcfg-vpn_vpn
DEVICE=vpn_vpn
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
USERCTL=yes
PEERDNS=no
DHCPV6C=yes
DHCPV6C_OPTIONS=-nw
PERSISTENT_DHCLIENT=yes
RES_OPTIONS="timeout:2 attempts:5"
DHCP_ARP_CHECK=no

設定したら、NICを立ち上げ直します。

$ sudo ifdown vpn_vpn
$ sudo ifup vpn_vpn

Determining IP information for vpn_vpn... done.

Determining IPv6 information for vpn_vpn... done.
$ ifconfig
~()~
vpn_vpn   Link encap:Ethernet  HWaddr 00:AC:DE:96:CE:73
          inet addr:200.1.1.1  Bcast:200.1.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2ac:deff:fe96:ce73/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1963 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1518 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:198576 (193.9 KiB)  TX bytes:273806 (267.3 KiB)

クライアント同士の通信について

公式ドキュメントで解説されているように、上記と同様にVPN Clientを導入したPCを用意すると、あとはクライアント同士で通信が可能です。
IPアドレスの割り当てに問題がある場合は、更にrouteの設定などが必要かもしれません。

参考

SoftEther VPN 公式サイト
PC 間接続 VPN
7.3 Linux へのインストールと初期設定
6.5 VPN Client の管理コマンドリファレンス
10.3 コンピュータ間 VPN の構築

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