User Tools

Site Tools


wireguard

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wireguard [2026/08/02 10:10] baumiwireguard [2026/08/02 10:15] (current) baumi
Line 45: Line 45:
 PrivateKey = <contents of privateB> PrivateKey = <contents of privateB>
 ListenPort = 51820 ListenPort = 51820
 +#If something needs to happen after tunnel is up or before tunnel goes down
 #PostUp = /usr/local/sbin/wg0-PostUp.sh #PostUp = /usr/local/sbin/wg0-PostUp.sh
 #PreDown = /usr/local/sbin/wg0-PreDown.sh #PreDown = /usr/local/sbin/wg0-PreDown.sh
Line 93: Line 94:
   persistent keepalive: every 25 seconds   persistent keepalive: every 25 seconds
 </code> </code>
 +
 +===== Fallback systemd service to call PreDown script =====
 +<code>
 +root@hostb # cat << EOF > /etc/systemd/system/wg0-shutdown-fallback.service
 +[Unit]
 +Description=WireGuard wg0 shutdown fallback
 +DefaultDependencies=no
 +
 +Before=shutdown.target reboot.target halt.target
 +Before=wg-quick@wg0.service
 +
 +Conflicts=shutdown.target reboot.target halt.target
 +
 +After=local-fs.target
 +
 +[Service]
 +Type=oneshot
 +RemainAfterExit=yes
 +
 +ExecStart=/bin/true
 +ExecStop=/usr/local/sbin/wg0-PreDown.sh
 +
 +TimeoutStopSec=30
 +
 +[Install]
 +WantedBy=multi-user.target
 +EOF
 +root@hostb # systemctl daemon-reload
 +root@hostb # systemctl enable wg0-shutdown-fallback.service
 +root@hostb # systemctl start wg0-shutdown-fallback.service
 +</code>
 +
 +
 {{tag>kb linux}} {{tag>kb linux}}
wireguard.1785658234.txt.gz · Last modified: by baumi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki