動かざることバグの如し

近づきたいよ 君の理想に

動的IPでWireGuardの接続が切れてしまう対策

環境

概要

ArchLinuxのWikiに詳しく載ってるのでUbuntuでも使えるように改修した

wiki.archlinux.jp

コマンド

# cat /etc/systemd/system/wireguard_reresolve-dns.service
[Unit]
Description=Reresolve DNS of all WireGuard endpoints
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/bin/sh -c '/usr/local/bin/reresolve-dns.sh wg0'

[Install]
WantedBy=multi-user.target
# cat /etc/systemd/system/wireguard_reresolve-dns.timer
[Unit]
Description=Periodically reresolve DNS of all WireGuard endpoints

[Timer]
OnUnitActiveSec=10s
Unit=wireguard_reresolve-dns.service

[Install]
WantedBy=timers.target
systemctl start wireguard_reresolve-dns.timer
systemctl enable wireguard_reresolve-dns.timer