How to restart automatically interface of wireguard when connection lost?

how to restart automatically interface of wireguard when connection lost?

The most common approach is with watchcat.


hero, thanks

1 Like

I use a small script for failover/restart WireGuard interfaces.
You can create two or more WG interfaces and when one fails (maintenance overcrowded etc) the next tunnel will start


I'm curious - under what conditions or use case did restart of your WG interface become necessary?

I'm wondering if this is a better solution to a problem I've observed in the past.

Sometimes a VPN server is not responding, overcrowded, hardware failure etc.
It does not happen often , I use Mullvad as VPN provider but once in a while maybe once a week it happens, usually the VPN server is not long off line, when I checked it is usually solved in 30 minutes.
But it is easy to make more tunnels and run the script so that it will use the next tunnel when one VPN server is down.

I use/administer a lot of Broadcom routers which use DDWRT and DDWRT has it standard built-in and users are happy with that ( I actually added this to DDWRT).


is there a tutorial to use watchcat for two wireguard interfaces?

You mean you have two tunnels which are active simultaneously and you want to watch/restart both tunnels?

i need to start a tunnel on boot, if it fails, switch to wg2 interface

I do not know about watchcat as I am not using that.
But my script could be useful for the situation you outlined.

where can i find your script

thanks, does it works?

how should i use it? i have a problem

wireguard on device boot wireguard interface is starting but is not making handshake, i have to restart it manually, what can i do?

The script works for me, instructions are in the read. me and also in the script

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.