LoginSignup
37
35

More than 5 years have passed since last update.

SoftEther VPN Serverをsystemd対応にする

Last updated at Posted at 2017-12-10

何番煎じか分かりませんが、自分用の備忘録として残しておきます。。。

SoftEther VPNとは

筑波大学 SoftEther VPN プロジェクトで開発されたフリーウェア。
独自のSE-VPNプロトコルの他、OpenVPN、MS-SSTP、L2TP over IPSec等 様々なプロトコルに対応する。
SoftEtherプロジェクト公式サイト

公式のインストール手順に則れば問題なく動作するものの、
サービス用の設定ファイルがinitシステム用なので、これをSystemdに乗っけて動かすことが出来ないか?
SoftEther VPN - 7.3 Linux へのインストールと初期設定

Systemdとは

Linuxのinitシステムを置き換える目的で開発されているシステム管理デーモン。

Wikipedia - systemd

最近のディストリで採用例が増えている?

早速実例

/etc/systemd/system/softether-vpn.service というファイルを作る。

※ファイル名、Descriptionは任意。
ファイル名はそのままサービス名になるので、他と被らない名前にする。

softether-vpn.service
[Unit]
Description=Softether VPN Server Service
After=network.target

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

[Install]
WantedBy=multi-user.target

以前まで ifcfg-eth0 等に PROMISC=yes と書けばプロミスキャスモードが有効になっていたが効かなくなったようなので
ExecStartPreを使用し、実プログラム起動前にipコマンドで都度プロミスキャスモードをONにする作戦。

ファイルを作った後は、設定ファイルの再読み込みを行う

$ sudo systemctl daemon-reload

起動できるか試す

$ sudo systemctl start softether-vpn.service
$ sudo systemctl status softether-vpn.service
● softether-vpn.service - Softether VPN Server Service
   Loaded: loaded (/etc/systemd/system/softether-vpn.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2017-12-10 14:17:17 JST; 3s ago
  Process: 2127 ExecStart=/usr/local/vpnserver/vpnserver start (code=exited, status=0/SUCCESS)
 Main PID: 2129 (vpnserver)
    Tasks: 24 (limit: 4915)
   CGroup: /system.slice/softether-vpn.service
           ├─2129 /usr/local/vpnserver/vpnserver execsvc
           └─2130 /usr/local/vpnserver/vpnserver execsvc

Dec 10 14:17:13 localhost.localdomain systemd[1]: Starting Softether VPN Server Service...
Dec 10 14:17:17 localhost.localdomain vpnserver[2127]: The SoftEther VPN Server service has been started.
Dec 10 14:17:17 localhost.localdomain systemd[1]: Started Softether VPN Server Service.

Active: active (running) と表示されているので、正常に起動している。

問題なさそうなら、自動起動設定を行う

$ sudo systemctl enable softether-vpn.service 
Created symlink /etc/systemd/system/multi-user.target.wants/softether-vpn.service → /etc/systemd/system/softether-vpn.service.
37
35
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
37
35