LoginSignup
11
9

More than 3 years have passed since last update.

OpenVpnのsystemdユニットファイル

Posted at

OpenVpnをインストールするとsystemdファイルが、3つ配置される。

それぞれのファイルの内容ついて記載する。

openvpn@.service

/etc/openvpn/配下のconfファイルをロードして、実行する。

現在は非推奨となっている。

  ExecStart=/usr/sbin/openvpn --cd /etc/openvpn/ --config %i.conf
  • 実行形式
systemctl start openvpn@server.service

openvpn-server@.service

/etc/openvpn/server配下のconfファイルをロードして、実行する。

WorkingDirectory=/etc/openvpn/server
ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf
  • 実行形式
systemctl start openvpn-server@server.service

openvpn-client@.service

/etc/openvpn/clientにあるconfファイルをロードして、openvpnを起動する

WorkingDirectory=/etc/openvpn/client
ExecStart=/usr/sbin/openvpn --suppress-timestamps --nobind --config %i.conf
  • 実行形式
systemctl start openvpn-client@client.service

アットマークについて

各ユニットファイルに@がついてる。

@がついたユニットファイルはsystemctlの実行時に@の後ろに文字列を指定すると、ユニットファイルに定義した%iを@の後ろに設定した文字列で置換できる。

# 下記を実行すると
systemctl start openvpn-server@server.service

# %iがserverに設定される
ExecStart=/usr/sbin/openvpn --status %t/openvpn-server/status-%i.log --status-version 2 --suppress-timestamps --config %i.conf

参考

11
9
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
11
9