omv7:omv7_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
omv7:omv7_plugins:wireguard [2025/08/31 08:28] – [Update IP in DuckDNS only when it changes and restart WireGuard if necessary] chenteomv7:omv7_plugins:wireguard [2025/09/02 18:20] (current) – [Update DuckDNS IP. Receive notifications only when it changes and restart WireGuard automatically] chente
Line 518: Line 518:
         * This will have installed the ''curl'' package on the system. Now select the task again and press the **Edit** button. Delete the ''apt install curl'' command you wrote earlier.         * This will have installed the ''curl'' package on the system. Now select the task again and press the **Edit** button. Delete the ''apt install curl'' command you wrote earlier.
   * Type the following command in the **Command** field of the dialog box.   * Type the following command in the **Command** field of the dialog box.
-<html><body><pre><code>echo url="https://www.duckdns.org/update?domains=MY_DOMAIN&token=MY_TOKEN&ip=" | curl -k -o /var/log/duck.log -K -</code></pre></body></html> +<html><body><pre><code>echo url="https://www.duckdns.org/update?domains=[MY_DOMAIN]&token=[MY_TOKEN]&ip=" | curl -k -o /var/log/duck.log -K -</code></pre></body></html> 
-  * Replace ''MY_DOMAIN'' with the subdomain you chose in "''MY_DOMAIN''.duckdns.org"+  * Replace ''[MY_DOMAIN]'' with the subdomain you chose in "''[MY_DOMAIN]''.duckdns.org"
-  * Replace ''MY_TOKEN'' with the token that has been assigned to your duckdns account.+  * Replace ''[MY_TOKEN]'' with the token that has been assigned to your duckdns account.
   * In the **Time of execution** field, choose the Hourly option.   * In the **Time of execution** field, choose the Hourly option.
     * This will run the command every hour. If your IP changes frequently you can change this to run for shorter periods of time. Every 5 minutes may be reasonable.     * This will run the command every hour. If your IP changes frequently you can change this to run for shorter periods of time. Every 5 minutes may be reasonable.
Line 537: Line 537:
 ---- ----
  
-=== Update IP in DuckDNS only when it changes and restart WireGuard if necessary ===+=== Update DuckDNS IP. Receive notifications only when it changes and restart WireGuard automatically ===
  
-You can add this script to a scheduled task so that your public IP is updated only if it changes.+You can add this script to a scheduled task so that your public IP is updated, and you receive a notification only if it changes.
  
-Additionally, if you are using a WireGuard tunnel between two servers and the public IP changes on one of them, the tunnel may drop (because it will still try to reach the old IP). By automatically restarting the servicethe peer will receive a new //handshake// and the IP in the tunnel will be updated.+Additionally, if you are using a WireGuard tunnel between two servers and the public IP changes on one of them, the tunnel may drop connections (because it will still try to reach the old IP). Restarting the service automatically allows the peer to establish a new //handshake//, updating the tunnel with the new IP.
  
 Example command: Example command:
  
-<html><body><pre><code>IP=$(curl -s https://api.ipify.org);+<html><body><pre><code>curl -s -k "https://www.duckdns.org/update?domains=[MY_DOMAIN]&token=[MY_TOKEN]&ip=&verbose=true| grep -q UPDATED && echo "UPDATED PUBLIC IP IN DUCKDNS" && systemctl restart wg-quick@wgnet_[MY_TUNNEL]</code></pre></body></html>
-[ "$IP" != "$(cat /root/last_ip 2>/dev/null)" ] && \ +
-curl -k "https://www.duckdns.org/update?domains=[MY_DOMAIN]&token=[MY_TOKEN]&ip=" && +
-echo "$IP" > /root/last_ip && +
-systemctl restart wg-quick@wgnet_[MY_TUNNEL]</code></pre></body></html>+
  
-  * Replace ''[MY_DOMAIN]'' with your DuckDNS domain and ''[MY_TOKEN]'' with your token.+  * Replace ''[MY_DOMAIN]'' with the subdomain you chose in "''[MY_DOMAIN]''.duckdns.org" and ''[MY_TOKEN]'' with your token.
   * Replace ''[MY_TUNNEL]'' with the name you assigned to your tunnel in the WireGuard plugin.   * Replace ''[MY_TUNNEL]'' with the name you assigned to your tunnel in the WireGuard plugin.
-  * Remember to enable notifications in OMV so you get an alert when this task runs.+  * Remember to enable notifications in OMV to receive an alert when the public IP changes.
   * Add a descriptive label to the scheduled task so you can easily identify it.   * Add a descriptive label to the scheduled task so you can easily identify it.
  
 Once created, simply copy the command into **Scheduled Tasks** and set the execution interval. Once created, simply copy the command into **Scheduled Tasks** and set the execution interval.
-Make sure to run it as **root** (default).+ 
 +Remember to install ''curl'' if it is not installed on your system (see previous point).
  
 ---- ----
  • omv7/omv7_plugins/wireguard.1756628886.txt.gz
  • Last modified: 2025/08/31 08:28
  • by chente