WAN Failover with Wireguard VPN not working (RUTX50)

Hello,

I am experiencing more or less the same issue as described here: WAN Failover with VPN not working (RUTX50)

We are using a RUTX50 with an established WireGuard VPN connection to a server hosted on a Ubiquiti Dream Machine.

When the RUTX leaves the Wi-Fi coverage, the failover switches to mobile data, but the VPN seems to remain bound to the Wi-Fi connection, which is no longer available. As a result, there is no internet connectivity and no access to the remote network.

Interestingly, if I manually disable the Wi-Fi interface on the RUTX or turn off the Wi-Fi itself, the failover works correctly and the VPN reconnects over mobile data.

I have updated to the latest firmware (RUTX_R_00.07.18.3), but the issue persists.

My best guess, is that it sounds like implementing the native Wireguard Watchdog, is worth giving a go.

As of firmware version 07.17.1, the wireguard_watchdog script was no longer in the firmware package (bummer) but the good news is …. as of firmware version 07.19, they re-instated it.

For it to work, your RUTX50 should ideally be the VPN initiator but MUST have a ā€˜perisistant keep alive’ set, in its ā€˜Peers’ settings - normal value for this is 25.

In essence, the script checks the tunnel(s) to your ā€˜server’ that have a ā€˜keep alive’ set, and if it doesn’t get a response, it toggles the wireguard interface(s) off and on.

Try upgrading to 07.19.2. In previous firmware versions prior to 07.17.1, you had to ammend cron to call the script but in the latest fw, it now starts automatically as soon as you activate a wireguard tunnel.

If you really want to stay on 07.18.3 then it is possible by uploading the watchdog script (slightly modified) to the device into say /etc/opt/ and create a line in crontabs to run the script every minute.

In fw 07.19.2, you can set the interval that the watchdog checks the tunnel(s). If left blank, then the check runs every 1 minute.

As an aside, if the tunnnel seems a little fragile over a mobile connection, then set your MTU to 1280.

In addition, not sure if it is having any influence in a ā€˜wireguard’ scenario but in the failover settings at NETWORK > FAILOVER > MULTIWAN > INTERFACE ….. for each interface that can be potentially used in failover (e.g. wan, mob1s1a1, etc.), try setting the ā€˜flush connections’ as per below, if the previous suggestion doesn’t bear fruit.

Hello,

thank you for your response.

I changed now to Version RUTX_R_00.07.19.2.

And actually in my Wifi Interface there was no flush connections defined. I changed this as well. Now I need to check it this evening.

Will See.

Let me know how you get on, because if your setup is using WiFi as WAN, either as a client or Multi AP, then it might be as simple as not using Failover but reordering the wan interface priority but still utilising the watchdog. A little bit of speculation on my part, but worth a try if all else fails.

Good Morning,

unfortunately the modifications I did, doesn’t changed the situation. I still have the issue. No Internet after Failover when switching from Wifi to mob or mob to wifi when WireGuard VPN is engaged. Can you explain what you mean with ā€œ not using failoverā€ ?

Due to a variable in the the watchdog script, it can take up to 2 and a half minutes to restart the tunnel. I’m assuming you waited that long, so …..

I’ll expand on the ā€˜not using failover’ later on this afternoon, as I’m busy at the moment.

OK using a test bed it worked, maintained the wireguard tunnel and a constant video stream. This does NOT use failover functionality. WAN sources: phone wifi hotspot and mob1s1a1.

  1. remove any failover switches that are set to ā€˜enabled’ by going to NETWORK > WAN > WAN INTERFACES - Save & Apply.

  2. start with a blank canvas and delete your existing WiFi Client by going to NETWORK > WIRELESS > SSIDs. This will also delete the WAN Interface associated with the WiFi Client (named wifi1 as default) - Save & Apply.

  3. on the same page NETWORK > WIRELESS > SSIDs, scan for the wifi SSID you want to setup as a Client. Join the network and on the next dialogue box for the wifi1 settings click on Save & Apply. You should now see the the Client SSID, in this example named El VENCEJO, is now connected

  1. now we prioritise the WAN Interfaces, so that your wifi1 interface has priority over your mobile interface. Go to NETWORK > WAN > WAN INTERFACES, grab the handle beside wifi1 and drag it to be above you mobile interface - Save & Apply

And it’s ready for testing with your wireguard tunnel. Should the WiFi uplink go out of range, it will switch to mobile and once WiFi is back in range, it should reconnect as it has a higher priority.

I have the same issue, and although your solution works -without failover- it is counter intuitive: why disable failover if it is precisely the functionality you need?

Let’s opt for a decent fix…

Not strictly true because in @Thorsten_S scenario, when on mobile, there’s nothing to failover to, as there is no connected WiFi uplink.

I agree though, it does seem a bit counter-intuitive - you’d think that the tunnel would persist, with a change of WAN interface combined with watchdog, with a Failover.

Alas, I’ve never played with your particular scenario (wireguard + failover) and I don’t have the experience to instantly recognise where the problem is. My first experiment would be to ensure the interfaces have visibilty of DNS when failover and switchback occur.

Actually, it is working now.
I checked the WireGuard settings again. With the reintegration of the watchdog in firmware 7.19.2, there was no default interval set in the advanced settings and you mentioned it would be then standard 60 sec. After adding the interval, it started working for me. Obviously if it is blank it doesn’t work.

Thanks for your help!

1 Like

Thank Mike, I have replicated your suggestions (wireguard watchdog at 60s, keep alive at 25, flush connections on active interfaces: in my case MOB1S1A1 and WIFI0). Wireguard was rock solid before and still is after these changes (perhaps unnoticeably more solid). The problem I experience is that as soon as I enable those interfaces as load-balanced or failover in MultiWan, the wifi clients connected to the RUTX lose connectivity to the internet. They can still access the rutx and anything over the wireguard tunnel, but nothing outside the local and wireguard network (i.e internet).

I’ve compared the routing table and the firewall settings (uci show firewall) before and after changing the failover/loadbalancing settings and they have remained the same.

So: WG + no load balancing, no failover: wg tunnel and RUTX function as expected. WG + loadbalancing/failover: no internet route for RUTX clients. No WG + failover/loadbalancing: RUTX functions as a proper router.

To replicate:
Have a working WG connection up.
MOB1SA1 disconnected via flight mode=on
WIFI0 active via a MultiAP connection to a wifi hotspot
Nothing enabled in Multiwan: clients have internet connectivity via mobile (flight mode off) or the wifi hotspot when mobile loses connection (set flight mode to on).
Anything enabled in multiwan: clients lose connection to the internet.
WG disabled: multiwan works as expected.

Thanks for the help!

Hi, I’m just about to go onboard and will be at sea until Friday, so will not have an opportunity to follow this up.

I wasn’t able to replicate your issue and on my configuration, wifi clients are able to authenticate to the RUTX, with internet access over wireguard, that persists through failover and switchback.

I suggest you add the detail of your post above to the seperate thread you started, and hope for someone to step in.

Hello @Thorsten_S,

Please let me know if you still require any assistance.

Best regards,