omv8:omv8_plugins:wireguard

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
omv8:omv8_plugins:wireguard [2025/12/31 07:45] – [Update DuckDNS IP, receive notifications only when it changes, and restart WireGuard automatically] chenteomv8:omv8_plugins:wireguard [2025/12/31 08:57] (current) – [Update DuckDNS IP, receive notifications only when it changes, and restart the tunnel if needed] chente
Line 555: Line 555:
  
  
-=== Update DuckDNS IP, receive notifications only when it changes, and restart WireGuard automatically ===+=== Update DuckDNS IP, receive notifications only when it changes, and restart the tunnel if needed ===
  
 This script can be added to an OMV scheduled task. It will: This script can be added to an OMV scheduled task. It will:
Line 563: Line 563:
  
 Useful for securing persistent connections between servers, e.g., for backups. Useful for securing persistent connections between servers, e.g., for backups.
 +
 +**WireGuard tunnel naming in OMV-extras plugin**
 +
 +  * Standard tunnels:
 +    * Tunnel number 1 → ''wgnet1''
 +    * Tunnel number 2 → ''wgnet2''
 +  * Custom tunnels:
 +    * The plugin automatically prefixes the name with ''wgnet_''.
 +      * Example: if you name your custom tunnel ''pp'', its internal name will be ''wgnet_pp''.
 +      * Example: if you name it ''backup'', its internal name will be ''wgnet_backup''.
 +
 +Summary:
 +  * Standard: ''wgnet1'', ''wgnet2''
 +  * Custom: ''wgnet_<your_custom_name>''
 +
 +Important: The TUNNELS variable in the scheduled task script must use these internal names to correctly check and reactivate the interfaces.
 +
 +**Script example:**
  
 <html><body><pre><code> <html><body><pre><code>
 DOMAIN="[MY_DOMAIN]" DOMAIN="[MY_DOMAIN]"
 TOKEN="[MY_TOKEN]" TOKEN="[MY_TOKEN]"
-TUNNELS="wgnet1 wgnet2 wgnet_custom"+TUNNELS="wgnet1 wgnet2 wgnet_backup"
 UPDATED=0 UPDATED=0
  
 +# Update IP address in DuckDNS
 curl -s -k "https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=&verbose=true" | grep -q UPDATED && { curl -s -k "https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=&verbose=true" | grep -q UPDATED && {
     echo "IP updated in DuckDNS"     echo "IP updated in DuckDNS"
Line 575: Line 594:
 } }
  
 +# Check tunnel status and reactivate if needed
 for TUNNEL in $TUNNELS; do for TUNNEL in $TUNNELS; do
     ip link show "$TUNNEL" >/dev/null 2>&1 || {     ip link show "$TUNNEL" >/dev/null 2>&1 || {
Line 586: Line 606:
 </code></pre></body></html> </code></pre></body></html>
  
-Replace the following placeholders: +**How to use:** 
-  * [MY_DOMAIN] = Your DuckDNS domain (without ''.duckdns.org''+  * Replace placeholders with your real values
-  * [MY_TOKEN] = Your DuckDNS token +    * [MY_DOMAIN] = Your DuckDNS domain (without .duckdns.org) 
-  * [MY_TUNNEL_NUMBER_1]=For standard tunnel number 1write: ''wgnet1'' +    * [MY_TOKEN] = Your DuckDNS token 
-  * [MY_TUNNEL_NUMBER_2]=For standard tunnel number 2, write: ''wgnet2'' +    * [MY_TUNNEL_NUMBER_1], [MY_TUNNEL_NUMBER_2], etc. Internal tunnel names as described above 
-  * [MY_CUSTOM_TUNNEL]=For custom tunnel abcd write: ''wgnet_abcd'' +  * Single-line version for OMV Scheduled Tasks: 
- +    * <html><body><pre><code>DOMAIN="[MY_DOMAIN]"; TOKEN="[MY_TOKEN]"; TUNNELS="wgnet1 wgnet_backup"; UPDATED=0; curl -s -k "https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=&verbose=true" | grep -q UPDATED && { echo "IP updated in DuckDNS"; UPDATED=1; }; for TUNNEL in $TUNNELS; do ip link show "$TUNNEL" >/dev/null 2>&1 || { echo "WireGuard $TUNNEL down, reactivating..."; systemctl start wg-quick@"$TUNNEL" || exit 1; UPDATED=1; }; done; [ "$UPDATED" -eq 1 ] && echo "CHANGES APPLIED" || true</code></pre></body></html> 
-Single-line example for OMV Scheduled Tasks: +  * Enable OMV notifications to receive alerts when the public IP changes or a tunnel is reactivated
- +  * Add a descriptive label to your scheduled task.
-  Example command: +
- +
-<html><body><pre><code> +
-DOMAIN="[MY_DOMAIN]"; TOKEN="[MY_TOKEN]"; TUNNELS="wgnet1 wgnet_abcd"; UPDATED=0; curl -s -k "https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=&verbose=true" | grep -q UPDATED && { echo "IP updated in DuckDNS"; UPDATED=1; }; for TUNNEL in $TUNNELS; do ip link show "$TUNNEL" >/dev/null 2>&1 || { echo "WireGuard $TUNNEL down, reactivating..."; systemctl start wg-quick@"$TUNNEL" || exit 1; UPDATED=1; }; done; [ "$UPDATED" -eq 1 ] && echo "CHANGES APPLIED" || true +
-</code></pre></body></html> +
- +
-Notes: +
-  * Enable OMV notifications to receive alerts when the public IP changes. +
-  * Give a descriptive label to the scheduled task.+
   * Make sure **curl** is installed before running the task.   * Make sure **curl** is installed before running the task.
  
  • omv8/omv8_plugins/wireguard.1767167141.txt.gz
  • Last modified: 2025/12/31 07:45
  • by chente