13
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Pi に SoftEther_VPN Client をインストール

Last updated at Posted at 2018-03-16

Raspbian (4.19.66-v7+) に SoftEther_VPN Client をインストール方法です。

softether-vpnclient-v4.31-9727-beta-2019.11.18-linux-arm_eabi-32bit.tar.gz
をダウンロードします。

tar xvfz softether-vpnclient-v4.31-9727-beta-2019.11.18-linux-arm_eabi-32bit.tar.gz
cd vpnclient
make

次のコマンドが出来ます

vpnclient
vpncmd

クライアントサービスのスタート

sudo ./vpnclient start

バージョンの確認

$ ./vpncmd /client

VPN Client>VersionGet
VersionGet command - Get Version Information of VPN Client Service
Item               |Value
-------------------+----------------------------------------------------
Product Name       |SoftEther VPN Client
Version Information|Version 4.31 Build 9727   (English)
Build Information  |Compiled 2019/11/18 11:14:51 by buildsan at crosswin
Process ID         |0
OS Type            |Linux
The command completed successfully.

vpn_tun0 というデバイスを作ります。

コマンドを起動します。

Hostname of IP Address of Destination:
には、Enter を入れて下さい。

$ ./vpncmd /client
vpncmd command - SoftEther VPN Command Line Management Utility
SoftEther VPN Command Line Management Utility (vpncmd command)
Version 4.25 Build 9656   (English)
Compiled 2018/01/15 10:17:04 by yagi at pc33
Copyright (c) SoftEther VPN Project. All Rights Reserved.

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".

Nic の作成

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

アカウントの作成

vpn サーバーが、 153.10.25.41:5555 の時の例です。 サーバーにユーザー scott パスワード tiger で接続できるとします。

VPN Client>AccountCreate tun0 /SERVER:153.10.25.41:5555 /HUB:DEFAULT /USERNAME:scott /NICNAME:tun0
AccountCreate command - Create New VPN Connection Setting
The command completed successfully.

Nic を有効にします。

VPN Client>NicEnable tun0
NicEnable command - Enable Virtual Network Adapter
The command completed successfully.

サーバーのユーザー名をセットします。

VPN Client>AccountUsernameSet tun0 /USERNAME:scott
AccountUsernameSet command - Set User Name of User to Use Connection of VPN Connection Setting
The command completed successfully.

パスワードをセットします。

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

接続します。

VPN Client>AccountConnect tun0
AccountConnect command - Start Connection to VPN Server using VPN Connection Setting
The command completed successfully.

アドレスを取得します。

sudo dhclient vpn_tun0
ip addr show vpn_tun0

vpn_tun0 というデバイスを作る為の操作をまとめたスクリプトです。

Nic の作成
アカウントの作成
Nic を有効にします。
サーバーのユーザー名をセットします。
パスワードをセットします。
接続します。
アドレスを取得します。

vpn_create.sh
#
#       vpn_create.sh
#
#                                       Dec/13/2019
#
VPNCMD='/opt/vpnclient/vpncmd /client localhost'
#
$VPNCMD /cmd NicCreate tun0
$VPNCMD /cmd AccountCreate tun0 /SERVER:153.10.25.41:5555 /HUB:DEFAULT /USERNAME:scott /NICNAME:tun0
$VPNCMD /cmd NicEnable tun0
$VPNCMD /cmd AccountUsernameSet tun0 /USERNAME:scott
$VPNCMD /cmd AccountPasswordSet tun0 /PASSWORD:tiger /TYPE:standard
#
$VPNCMD /cmd AccountConnect tun0
#
#
sudo dhclient vpn_tun0
ip addr show vpn_tun0
#
#

設定が終わって、再起動後に接続する手順

1) クライアントサービスのスタート
2) アカウントの接続
3) アドレスを取得

cd vpnclient
sudo ./vpnclient start
./vpncmd /client localhost /cmd AccountConnect tun0
sudo dhclient vpn_tun0

自動起動の設定

1) vpnclient のフォルダーを /opt の下に移動

  1. 次のスクリプトを作成
/opt/vpnclient/dhclient_start.sh
#
#	dhclient_start.sh
#
#					Mar/22/2018
sleep 10
#
/opt/vpnclient/vpncmd /client localhost /cmd AccountConnect tun0
#
sleep 1
#
dhclient vpn_tun0
#

3) サービスのファイルを作成
Raspberry Pi 0 の時は、eth0 を wlan0 にして下さい。

/etc/systemd/system/vpnclient.service
[Unit]
Description=Softether VPN Client Service
After=network.target

[Service]
Type=forking
User=root
ExecStart=/opt/vpnclient/vpnclient start
ExecStop=/opt/vpnclient/vpnclient stop
Restart=on-abort
WorkingDirectory=/opt/vpnclient
ExecStartPre=/sbin/ip link set dev eth0 promisc on

[Install]
WantedBy=multi-user.target
/etc/systemd/system/dhclient.service
[Unit]
Description=Softether VPN Client DHCP
After=vpnclient.service

[Service]
Type=oneshot
User=root
ExecStart=/bin/bash /opt/vpnclient/dhclient_start.sh
WorkingDirectory=/opt/vpnclient
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
  1. Systemd を有効にする
sudo chmod 0755 /etc/systemd/system/vpnclient.service
sudo chmod 0755 /etc/systemd/system/dhclient.service
sudo systemctl daemon-reload
sudo systemctl start vpnclient
sudo systemctl enable vpnclient
sudo systemctl start dhclient
sudo systemctl enable dhclient

5) 再起動

sudo shutdown -r now
13
19
3

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
13
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?