SoftEther VPN を使用してCentOS 7 をVPNクライアントとしてVPNサーバーに接続することを目的としたインストール手順、および、設定。
SoftEther ダウンロード センターからダウンロードします。
tarで解凍します。
[root@localhost ~]# tar zxvf softether-vpnclient-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz |
makeを実行して、使用権許諾契約書を読むために「1」を選択します。
[root@localhost ~]# cd vpnserver/ |
[root@localhost ~]# 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」を入力してEnterキー |
使用権許諾契約書を読んで承諾したら、それぞれ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 「1」を入力してEnterキー Did you agree the License Agreement ? 1. Agree 2. Do Not Agree Please choose one of above number: 1 「1」を入力してEnterキー 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' |
makeしたファイルをそのまま移動させます。
[root@localhost ~]# cd .. |
[root@localhost ~]# mv vpnclient /usr/local |
権限を変更しておきます。 |
[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を実行して、VPN Toolsで動作チェックを行います。
[root@localhost ~]# ./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 「3」を入力してEnterキー VPN Tools has been launched. By inputting HELP, you can view a list of the commands that can be used. |
VPN Tools>check ←「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 ←抜ける |
[root@localhost ~]# vi /usr/local/vpnclient/setting_ip.sh |
#!/bin/bash # case Static IP TAP_IF="vpn_vpn" # 30sec Loop for i in {1..30} do sleep 1 ip tap | grep --quiet ${TAP_IF} STATUS=$? if [ "${STATUS}" == "0" ] then ifcfg ${TAP_IF} add 10.8.0.10/24 break; fi done exit 0 |
[root@localhost ~]# chmod 700 /usr/local/vpnclient/setting_ip.sh |
サービスの起動時に、仮想NIC (vpn_vpn) に固定IPアドレスを付与する
[root@localhost ~]# vi /usr/lib/systemd/system/vpnclient.service |
[Unit] Description=SoftEther VPN Client After=network.target [Service] Type=forking ExecStart=/usr/local/vpnclient/vpnclient start ExecStartPost=/usr/local/vpnclient/setting_ip.sh ExecStop=/usr/local/vpnclient/vpnclient stop [Install] WantedBy=multi-user.target |
以下のコマンドでサービスを開始できます。ただ、自動起動の確認として、サーバを再起動したほうが良いかと思います。
[root@localhost ~]# systemctl daemon-reload |
[root@localhost ~]# systemctl enable vpnclient |
次に、クライアントの設定をvpncmdで行っていきます。
vpncmdについてはこちらに記載されています。
なお、以下の設定は「VPN クライアント接続マネージャ」の「別のコンピュータのSoftEther VPN Clientの管理」からでもできます。
その場合はTCPポート9930を解放しておく必要があります。
まだいろいろ設定していないので、サービス(systemctl)としてではなく直接 vpnclient を起動する。
[root@localhost ~]# cd /usr/local/vpnclient |
[root@localhost vpnclient]# ./vpnclient start |
[root@localhost vpnclient]# ./vpncmd localhost /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 The command completed successfully. |
VPN Client>NicList |
仮想 LAN カード名|vpn 状態 |有効 (使用可能) MAC アドレス |00AC71755582 バージョン |Version 4.22 Build 9634 (Japanese) |
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. |
AccountPasswordSetコマンドで設定します。パスワードはVPNサーバ設定で行った設定を参照して下さい。
VPN Client>AccountStartupSet VPN_Server |
AccountStartupSet command - Set VPN Connection Setting as Startup Connection The command completed successfully. |
VPN Client>exit |
設定できたので接続してみます。もし、「接続完了」にならなければ、ユーザ名、パスワード、HUB名、サーバアドレス、ポート等々を確認してみてください。
サーバー側のログ( /usr/local/vpnserver/server_log/vpn_yyyymmdd.log )も確認した方が良いかも。
VPN Client>AccountConnect VPN_Server |
VPN Client>AccountList |
接続設定名 |VPN_Server 状態 |接続完了 接続先 VPN サーバー|10.8.0.10:44444 (直接 TCP/IP 接続) 仮想 HUB 名 |VPN 仮想 LAN カード名 |vpn_vpn |
仮想NIC が作成されていることの確認。
VPN Client>Quit |
[root@localhost ~]# ip tap |
vpn_vpn: tap |
[root@localhost ~]# ./vpnclient stop |
設定ファイルを直接編集
※ 必要ないのでパンチしないようにします。
[root@localhost ~]# cp -p vpn_client.config vpn_client.config.org |
[root@localhost ~]# vi vpn_client.config |
declare AccountDatabase { declare Account0 { declare ClientOption { string AccountName USER1 bool NoUdpAcceleration true |
サービスとして起動すると、ちゃんとIPアドレスを仮想NICに設定してくれることを確認。
[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 link/ether 00:ac:71:75:55:82 brd ff:ff:ff:ff:ff:ff inet 10.8.0.10/24 brd 10.8.0.255 scope global vpn_vpn valid_lft forever preferred_lft forever |
アカウントがサービス起動時に自動的に接続に行っていることも確認。
[root@localhost ~]# ./vpncmd localhost /CLIENT |
VPN Client>AccountStatusGet VPN_Server |
接続設定名 |VPN_Server セッション接続状態 |接続完了 (セッション確立済み) サーバー名 |xxx.xxx.xxx.xxx ポート番号 |TCP ポート 44444 |
VPN_Server>Quit |
ちゃんとサーバーと接続されていることも確認。
[root@localhost ~]# ping -c 3 10.8.0.111 |
PING 10.8.0.111 (10.8.0.111) 56(84) bytes of data. 64 bytes from 10.8.0.111: icmp_seq=1 ttl=64 time=2.42 ms 64 bytes from 10.8.0.111: icmp_seq=2 ttl=64 time=1.02 ms 64 bytes from 10.8.0.111: icmp_seq=3 ttl=64 time=1.01 ms --- 10.8.0.111 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 1.010/1.489/2.428/0.664 ms |
公式ドキュメントで解説されているように、上記と同様にVPN Clientを導入したPCを用意すると、あとはクライアント同士で通信が可能です。
IPアドレスの割り当てに問題がある場合は、更にrouteの設定などが必要かもしれません。