- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2018-08-27T18:12:37+09:00","","")
#freeze
#author("2018-08-27T20:51:05+09:00","","")
[[CentOS7]]
*SoftEther VPN Client でVPN接続をする [#a282268b]
*SoftEther VPN Client でVPN接続をする [#ze417073]
''SoftEther VPN'' を使用して''CentOS 7'' を''VPN''クライアントとして''VPN''サーバーに接続することを目的としたインストール手順、および、設定。
*ダウンロード [#b323f0b2]
*ダウンロード [#tae511a3]
[[SoftEther ダウンロード センター>http://www.softether-download.com/ja.aspx?product=softether]]からダウンロードします。
-ダウンロードするソフトウェア:SoftEther VPN (Freeware)
-コンポーネント:SoftEther VPN Client
-プラットフォーム:Linux
-CPU:Intel x64 / AMD 64 (64bit)
-ダウンロードするソフトウェア:''SoftEther VPN (Freeware)''
-コンポーネント:''SoftEther VPN Client''
-プラットフォーム:''Linux''
-CPU:''Intel x64 / AMD 64 (64bit)''
*パッケージの解凍 [#te8fd928]
tarで解凍します。
*パッケージの解凍 [#w8407902]
''tar''で解凍します。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# tar zxvf softether-vpnclient-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz|
*実行可能ファイルの生成 [#leef1590]
''make''を実行して、使用権許諾契約書を読むために1を選択します。
*実行可能ファイルの生成 [#hd607244]
''make''を実行して、使用権許諾契約書を読むために「1」を選択します。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# cd vpnserver/|
|[root@localhost ~]# make|
|-------------------------------------------------------------------- &br; &br; SoftEther VPN Client (Ver 4.22, Build 9634, Intel x64 / AMD64) for Linux Install Utility &br; Copyright (c) SoftEther Project at University of Tsukuba, Japan. All Rights Reserved. &br; &br; -------------------------------------------------------------------- &br; &br; &br; Do you want to read the License Agreement for this software ? &br; &br; 1. Yes &br; 2. No &br; &br; Please choose one of above number: &br; &br; &color(lightpink){1}; &color(lime){「1」を入力してEnterキー};|
|&color(lime){使用権許諾契約書を読んで承諾したら、それぞれ1をクリックします。};|
|Did you read and understand the License Agreement ? &br; (If you couldn't read above text, Please read 'ReadMeFirst_License.txt' &br; file with any text editor.) &br; &br; 1. Yes &br; 2. No &br; &br; Please choose one of above number: &br; &color(lightpink){1}; &color(lime){「1」を入力してEnterキー}; &br; &br; &br; Did you agree the License Agreement ? &br; &br; 1. Agree &br; 2. Do Not Agree &br; &br; Please choose one of above number: &br; &color(lightpink){1}; &color(lime){「1」を入力してEnterキー}; &br; &br; make[1]: Entering directory `/home/ec2-user/Installer/vpnclient' &br; Preparing SoftEther VPN Client... &br; ranlib lib/libcharset.a &br; ranlib lib/libcrypto.a &br; ranlib lib/libedit.a &br; ranlib lib/libiconv.a &br; ranlib lib/libintelaes.a &br; ranlib lib/libncurses.a &br; ranlib lib/libssl.a &br; ranlib lib/libz.a &br; ranlib code/vpnclient.a &br; 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 &br; ranlib code/vpncmd.a &br; 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 &br; &br; -------------------------------------------------------------------- &br; The preparation of SoftEther VPN Client is completed ! &br; &br; &br; *** How to switch the display language of the SoftEther VPN Client Service *** &br; SoftEther VPN Client supports the following languages: &br; - Japanese &br; - English &br; - Simplified Chinese &br; &br; You can choose your prefered language of SoftEther VPN Client at any time. &br; To switch the current language, open and edit the 'lang.config' file. &br; &br; &br; *** How to start the SoftEther VPN Client Service *** &br; &br; Please execute './vpnclient start' to run the SoftEther VPN Client Background Service. &br; And please execute './vpncmd' to run the SoftEther VPN Command-Line Utility to configure SoftEther VPN Client. &br; &br; 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. &br; &br; &br; *** For Windows users *** &br; You can download the SoftEther VPN Server Manager for Windows &br; from the http://www.softether-download.com/ web site. &br; This manager application helps you to completely and easily manage the VPN server services running in remote hosts. &br; &br; &br; *** For Mac OS X users *** &br; In April 2016 we released the SoftEther VPN Server Manager for Mac OS X. &br; You can download it from the http://www.softether-download.com/ web site. &br; 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. &br; &br; -------------------------------------------------------------------- &br; &br; make[1]: Leaving directory `/home/ec2-user/Installer/vpnclient'|
*VPN Client の配置 [#cf484751]
*SoftEther VPN Client の設置 [#o67a17d7]
''make''したファイルをそのまま移動させます。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# cd ..|
|[root@localhost ~]# mv vpnclient /usr/local|
|&color(lime){権限を変更しておきます。};|
|[root@localhost ~]# chown -R root:root /usr/local/vpnclient/|
|[root@localhost ~]# cd /usr/local/vpnclient/|
|[root@localhost ~]# chmod 600 *|
|[root@localhost ~]# chmod 700 vpncmd|
|[root@localhost ~]# chmod 700 vpnclient|
*vpncmd の check コマンドによる動作チェック [#cc635759]
*vpncmd の check コマンドによる動作チェック [#n4654390]
''vpncmd''を実行して、''VPN Tools''で動作チェックを行います。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# ./vpncmd|
|vpncmd command - SoftEther VPN Command Line Management Utility &br; SoftEther VPN Command Line Management Utility (vpncmd command) &br; Version 4.22 Build 9634 (English) &br; Compiled 2016/11/27 15:23:56 by yagi at pc30 &br; Copyright (c) SoftEther VPN Project. All Rights Reserved. &br; &br; By using vpncmd program, the following can be achieved. &br; &br; 1. Management of VPN Server or VPN Bridge &br; 2. Management of VPN Client &br; 3. Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool) &br; &br; Select 1, 2 or 3: &color(lightpink){3}; &color(lime){「3」を入力してEnterキー}; &br; &br; VPN Tools has been launched. By inputting HELP, you can view a list of the commands that can be used.|
|VPN Tools>&color(lightpink){check}; &color(lime){←「check」コマンド入力};|
|Check command - Check whether SoftEther VPN Operation is Possible &br; --------------------------------------------------- &br; SoftEther VPN Operation Environment Check Tool &br; &br; Copyright (c) SoftEther VPN Project. &br; All Rights Reserved. &br; &br; 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... &br; &br; Checking 'Kernel System'... &br; Pass &br; Checking 'Memory Operation System'... &br; Pass &br; Checking 'ANSI / Unicode string processing system'... &br; Pass &br; Checking 'File system'... &br; Pass &br; Checking 'Thread processing system'... &br; Pass &br; Checking 'Network system'... &br; Pass &br; &br; All checks passed. It is most likely that SoftEther VPN Server / Bridge can operate normally on this system. &br; &br; The command completed successfully.|
|VPN Tools>&color(lightpink){exit}; &color(lime){←抜ける};|
*スタートアップスクリプトへの登録 [#ea5b495a]
サービスとして起動させる為に、以下のようにスタートアップスクリプトを登録します。
*SoftEther Client の仮想NICにIPアドレスを設定するシェルを新規作成 [#yb46456d]
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# vi /usr/local/vpnclient/setting_ip.sh|
| #!/bin/bash &br; &br; # case Static IP &br; TAP_IF="vpn_vpn" &br; &br; # 30sec Loop &br; for i in {1..30} &br; do &br; sleep 1 &br; ip tap | grep --quiet ${TAP_IF} &br; STATUS=$? &br; if [ "${STATUS}" == "0" ] &br; then &br; ifcfg ${TAP_IF} add 10.8.0.10/24 &br; break; &br; fi &br; done &br; exit 0|
|[root@localhost ~]# chmod 700 /usr/local/vpnclient/setting_ip.sh|
*SoftEther Client の起動スクリプト新規作成 [#ud17fe51]
サービスの起動時に、仮想''NIC'' (''vpn_vpn'') に固定IPアドレスを付与する
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# vi /etc/init.d/vpnclient|
|#!/bin/sh &br; # &br; # chkconfig: 2345 99 01 &br; # description: SoftEther VPN Client &br; &br; DAEMON=/usr/local/vpnclient/vpnclient &br; LOCK=/var/lock/subsys/vpnclient &br; &br; test -x $DAEMON || exit 0 &br; &br; case "$1" in &br; start) &br; $DAEMON start &br; touch $LOCK &br; ;; &br; stop) &br; $DAEMON stop &br; rm $LOCK &br; ;; &br; restart) &br; $DAEMON stop &br; sleep 3 &br; $DAEMON start &br; ;; &br; *) &br; echo "Usage: $0 {start|stop|restart}" &br; exit 1 &br; esac &br; &br; exit 0|
|&color(lime){権限設定をしておきます。};|
|[root@localhost ~]# chmod 755 /etc/init.d/vpnclient|
|&color(lime){自動起動設定をしておきます。};|
|[root@localhost ~]# chkconfig --add vpnclient|
|[root@localhost ~]# chkconfig --list vpnclient|
|vpnserver 0:off 1:off 2:on 3:on 4:on 5:on 6:off|
|[root@localhost ~]# vi /usr/lib/systemd/system/vpnclient.service|
| [Unit] &br; Description=SoftEther VPN Client &br; After=network.target &br; &br; [Service] &br; Type=forking &br; ExecStart=/usr/local/vpnclient/vpnclient start &br; ExecStartPost=/usr/local/vpnclient/setting_ip.sh &br; ExecStop=/usr/local/vpnclient/vpnclient stop &br; &br; [Install] &br; WantedBy=multi-user.target|
*サービスの開始と停止 [#cf726abd]
*サービスの開始と停止 [#nb5b2cd8]
以下のコマンドでサービスを開始できます。ただ、自動起動の確認として、サーバを再起動したほうが良いかと思います。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# /etc/init.d/vpnclient start|
|[root@localhost ~]# systemctl daemon-reload|
|[root@localhost ~]# systemctl enable vpnclient|
*クライアントの設定・管理 [#t6c79560]
*クライアントの設定・管理 [#t4a1924a]
次に、クライアントの設定を''vpncmd''で行っていきます。
''vpncmd''については[[こちら>https://ja.softether.org/4-docs/1-manual/6/6.5]]に記載されています。
なお、以下の設定は「''VPN'' クライアント接続マネージャ」の「別のコンピュータのSoftEther VPN Clientの管理」からでもできます。
その場合は''TCP''ポート''9930''を解放しておく必要があります。
*VPN Client へ接続 [#yd172190]
まだいろいろ設定していないので、サービス(''systemctl'')としてではなく直接 ''vpnclient'' を起動する。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# cd /usr/local/vpnclient/|
|[root@localhost ~]# ./vpncmd|
|vpncmd command - SoftEther VPN Command Line Management Utility &br; SoftEther VPN Command Line Management Utility (vpncmd command) &br; Version 4.22 Build 9634 (English) &br; Compiled 2016/11/27 15:23:56 by yagi at pc30 &br; Copyright (c) SoftEther VPN Project. All Rights Reserved. &br; &br; By using vpncmd program, the following can be achieved. &br; &br; 1. Management of VPN Server or VPN Bridge &br; 2. Management of VPN Client &br; 3. Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool) &br; &br; Select 1, 2 or 3: &color(lightpink){2}; &color(lime){「2」を入力してEnterキー}; &br; &br; Specify the host name or IP address of the computer that the destination VPN Client is operating on. &br; If nothing is input and Enter is pressed, connection will be made to localhost (this computer). &br; Hostname of IP Address of Destination: &color(lime){#リターン}; &br; &br; Connected to VPN Client "localhost".|
|VPN Client>|
|[root@localhost ~]# cd /usr/local/vpnclient|
|[root@localhost vpnclient]# ./vpnclient start|
|[root@localhost vpnclient]# ./vpncmd localhost /CLIENT|
*新規仮想 LAN カードの作成 [#w3791846]
*新規仮想''NIC'' の作成 [#we6c7525]
''NicCreate''コマンドで作成します。ここでは"''VPN''"という名前で作成します。
|BGCOLOR(black):COLOR(white):|c
|VPN Client>NicCreate VPN|
|[root@localhost ~]# cd /usr/local/vpnclient|
|[root@localhost vpnclient]# ./vpncmd localhost /CLIENT|
|VPN Client>NicCreate vpn|
|NicCreate command - Create New Virtual Network Adapter &br; The command completed successfully.|
|VPN Client>NicList|
|NicList command - Get List of Virtual Network Adapters &br; Item |Value &br; ----------------------------+----------------------------------- &br; Virtual Network Adapter Name|VPN &br; Status |Enabled &br; MAC Address |00ACDE96CE73 &br; Version |Version 4.22 Build 9634 (English) &br; The command completed successfully.|
| 仮想 LAN カード名|vpn &br; 状態 |有効 (使用可能) &br; MAC アドレス |00AC71755582 &br; バージョン |Version 4.22 Build 9634 (Japanese)|
|VPN Client>|
*新しい接続設定の作成 [#ked3456a]
*新しい接続設定の作成 [#w6f2b8bc]
''AccountCreate''コマンドで作成します。ここでは"''VPN_Server''"という名前で作成します。
サーバのホスト名や、''HUB''名、ユーザ名は''VPN''サーバ設定で行った設定を参照して下さい。
''NIC''名は''LAN'' カードの作成で作成した''NIC''名です。
|BGCOLOR(black):COLOR(white):|c
|VPN Client>AccountCreate VPN_Server /SERVER:XXX.XXX.XXX.XXX:443 /HUB:VPN /USERNAME:admin /NICNAME:VPN|
|AccountCreate command - Create New VPN Connection Setting &br; The command completed successfully.|
|VPN Client>AccountList|
|AccountList command - Get List of VPN Connection Settings &br; Item |Value &br; ----------------------------+-------------------------------------------- &br; VPN Connection Setting Name |VPN_Server &br; Status |Offline &br; VPN Server Hostname |XXX.XXX.XXX.XXX:443 (Direct TCP/IP Connection) &br; Virtual Hub |VPN &br; Virtual Network Adapter Name|VPN &br; The command completed successfully.|
|AccountList command - Get List of VPN Connection Settings &br; Item | Value &br; ----------------------------+-------------------------------------------- &br; VPN Connection Setting Name | VPN_Server &br; Status | Offline &br; VPN Server Hostname | XXX.XXX.XXX.XXX:443 (Direct TCP/IP Connection) &br; Virtual Hub | VPN &br; Virtual Network Adapter Name | VPN &br; The command completed successfully.|
*接続設定のユーザー認証の種類をパスワード認証に設定 [#bbb44f1d]
*接続設定のユーザー認証の種類をパスワード認証に設定 [#k4206977]
''AccountPasswordSet''コマンドで設定します。パスワードは''VPN''サーバ設定で行った設定を参照して下さい。
|BGCOLOR(black):COLOR(white):|c
|VPN Client>AccountPasswordSet VPN_Server /PASSWORD:Passw0rd /TYPE:standard|
|AccountPasswordSet command - Set User Authentication Type of VPN Connection Setting to Password Authentication &br; The command completed successfully.|
|VPN Client>|
*接続設定をスタートアップ接続に設定 [#q3d23c4b]
*接続設定をスタートアップ接続に設定 [#ieea129e]
''AccountPasswordSet''コマンドで設定します。パスワードは''VPN''サーバ設定で行った設定を参照して下さい。
|BGCOLOR(black):COLOR(white):|c
|VPN Client>AccountStartupSet VPN_Server|
|AccountStartupSet command - Set VPN Connection Setting as Startup Connection &br; The command completed successfully.|
|VPN Client>exit|
*NICの設定 [#s585c25a]
次に、下記のように設定し''NIC''に''DHCP''で''IP''が振られるように設定します。
*サーバー接続 [#ea6e7f49]
設定できたので接続してみます。もし、「接続完了」にならなければ、ユーザ名、パスワード、HUB名、サーバアドレス、ポート等々を確認してみてください。
サーバー側のログ( /usr/local/vpnserver/server_log/vpn_yyyymmdd.log )も確認した方が良いかも。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-vpn_vpn|
|[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-vpn_vpn|
|VPN Client>AccountConnect VPN_Server|
|VPN Client>AccountList|
| 接続設定名 |VPN_Server &br; 状態 |接続完了 &br; 接続先 VPN サーバー|10.8.0.10:44444 (直接 TCP/IP 接続) &br; 仮想 HUB 名 |VPN &br; 仮想 LAN カード名 |vpn_vpn|
変更点としてはDEVICE名をNIC名にするのと、PEERDNSをnoに設定する2点となります。
*仮想NIC 確認 [#z78e6595]
仮想''NIC'' が作成されていることの確認。
|BGCOLOR(black):COLOR(white):|c
|DEVICE=vpn_vpn &br; BOOTPROTO=dhcp &br; ONBOOT=yes &br; TYPE=Ethernet &br; USERCTL=yes &br; PEERDNS=no &br; DHCPV6C=yes &br; DHCPV6C_OPTIONS=-nw &br; PERSISTENT_DHCLIENT=yes &br; RES_OPTIONS="timeout:2 attempts:5" &br; DHCP_ARP_CHECK=no &br; NM_CONTROLLED=no|
|VPN Client>Quit|
|[root@localhost ~]# ip tap|
| vpn_vpn: tap|
*設定したら、NICを立ち上げ直します。 [#wb509d5f]
*サービス停止 [#ff511c7f]
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# ifdown vpn_vpn|
|[root@localhost ~]# ifup vpn_vpn|
|Determining IP information for vpn_vpn... done. &br; &br; Determining IPv6 information for vpn_vpn... done.|
|[root@localhost ~]# ifconfig|
|&color(lime){~(略)~}; &br; vpn_vpn Link encap:Ethernet HWaddr 00:AC:DE:96:CE:73 &br; inet addr:200.1.1.1 Bcast:200.1.1.255 Mask:255.255.255.0 &br; inet6 addr: fe80::2ac:deff:fe96:ce73/64 Scope:Link &br; UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 &br; RX packets:1963 errors:0 dropped:0 overruns:0 frame:0 &br; TX packets:1518 errors:0 dropped:0 overruns:0 carrier:0 &br; collisions:0 txqueuelen:1000 &br; RX bytes:198576 (193.9 KiB) TX bytes:273806 (267.3 KiB)|
|[root@localhost ~]# ./vpnclient stop|
*クライアント同士の通信について [#y88aeb85]
*UDPホールパンチングの無効化 [#i934934a]
設定ファイルを直接編集
※ 必要ないのでパンチしないようにします。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# cp -p vpn_client.config vpn_client.config.org|
|[root@localhost ~]# vi vpn_client.config|
| declare AccountDatabase &br; { &br; declare Account0 &br; { &br; declare ClientOption &br; { &br; string AccountName USER1 &br; bool NoUdpAcceleration true|
*サービス再起動(自動接続 & 自動IP付与) [#ob38088a]
サービスとして起動すると、ちゃんとIPアドレスを仮想''NIC''に設定してくれることを確認。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# systemctl start vpnclient|
|[root@localhost ~]# ip addr show vpn_vpn|
| 5: vpn_vpn: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 &br; link/ether 00:ac:71:75:55:82 brd ff:ff:ff:ff:ff:ff &br; inet 10.8.0.10/24 brd 10.8.0.255 scope global vpn_vpn &br; valid_lft forever preferred_lft forever|
*自動接続ステータス確認(クライアント) [#a5517483]
アカウントがサービス起動時に自動的に接続に行っていることも確認。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# ./vpncmd localhost /CLIENT|
|VPN Client>AccountStatusGet VPN_Server|
| 接続設定名 |VPN_Server &br; セッション接続状態 |接続完了 (セッション確立済み) &br; サーバー名 |xxx.xxx.xxx.xxx &br; ポート番号 |TCP ポート 44444|
|VPN_Server>Quit|
*通信確認(クライアント → サーバー) [#e32f7893]
ちゃんとサーバーと接続されていることも確認。
|BGCOLOR(black):COLOR(white):|c
|[root@localhost ~]# ping -c 3 10.8.0.111|
| PING 10.8.0.111 (10.8.0.111) 56(84) bytes of data. &br; 64 bytes from 10.8.0.111: icmp_seq=1 ttl=64 time=2.42 ms &br; 64 bytes from 10.8.0.111: icmp_seq=2 ttl=64 time=1.02 ms &br; 64 bytes from 10.8.0.111: icmp_seq=3 ttl=64 time=1.01 ms &br; &br; --- 10.8.0.111 ping statistics --- &br; 3 packets transmitted, 3 received, 0% packet loss, time 2003ms &br; rtt min/avg/max/mdev = 1.010/1.489/2.428/0.664 ms|
*クライアント同士の通信について [#b0da27b8]
[[公式ドキュメントで解説されている>https://ja.softether.org/4-docs/1-manual/A/10.3]]ように、上記と同様に''VPN Client''を導入した''PC''を用意すると、あとはクライアント同士で通信が可能です。
IPアドレスの割り当てに問題がある場合は、更に''route''の設定などが必要かもしれません。