LoginSignup
0
0

WireguardがLogを吐かない問題の対処

Posted at

WireguardはLogを吐かない

Wireguardはログを吐かない。これに対する対応は公式ページArch Wikiで対応方法が載っている通り。

# modprobe wireguard
# echo module wireguard +p > /sys/kernel/debug/dynamic_debug/control

で対応できる。

起動時に実行したい

rc.localにでも書いとけ。

systemdでやりたい

UNITファイルを書く

wireguard-logging-start.service
[Unit]
Description=Setup WireGuard Logging
After=network.target

[Service]
ExecStart=/usr/local/bin/wireguard-logging-start.sh
Type=oneshot
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

もちろん/usr/local/bin/wireguard-logging-start.shには上のコマンド二行が入る。

ちょっとだけ効率化

通常wg-quick@wg01のようなスクリプトでmodprobeは実行されているはずなので、順序制御を入れれば少し簡略化できる。

wireguard-logging-start.sh
echo module wireguard +p > /sys/kernel/debug/dynamic_debug/control
wireguard-logging-start.service
[Unit]
Description=Start WireGuard Logging
After=wg-quick@wg01.service
Requires=wg-quick@wg01.service

[Service]
ExecStart=/usr/local/bin/wireguard-logging-start.sh
Type=oneshot
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

ドロップインで対応

上の方法では名前がwg01に限定されてしまうので、以下の方法の方が柔軟。
上の方が構造は単純なのでどちらでも。

/etc/systemd/system/wg-quick@.service.d/logging-start.conf
[Unit]
Description=Start WireGuard Logging
PartOf=wg-quick@.service

[Service]
ExecStartPost=/usr/local/bin/wireguard-logging-start.sh
0
0
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
0
0