Wireguard not reconnecting when remote IP change

Started by emaba, February 09, 2022, 10:25:10 PM

Previous topic - Next topic
Hi all,
I have an issue with a Wireguard site-to-site VPN.

Here is the situation:
- I have two OPNsense boxes (A and B).
- I set up box A a dynamic DNS service.
- Box B is behind a provider NAT, and I can't reach from outside.
- I set up Wireguard in both machines to have box B connect to box A.
- Everything works perfectly but:
when the IP of box A changes, the Dynamic DNS is updated, but the connection between the two boxes is not restored until I reboot box B (I haven't tested rebooting only Wierguard service at the moment).

Where is the problem?
How can I solve that?
May I add a script to reboot Wireguard when the remote IP changes or try to force it to reconnect when it loses the connection?

Thank you.
best,

Hello there! Hope your fine! Can ask you if you came with a solution for this? Thanks

A script has been added to OPNsense that you can run with a cron job. Go to the cron settings and you can see the script in the dropdown

It basically tests for a stale WG connection on whatever interval you set and restarts WG if one is detected

January 03, 2023, 12:54:25 AM #3 Last Edit: January 03, 2023, 12:56:00 AM by z1p
Quote from: Greelan on January 03, 2023, 12:13:06 AM
A script has been added to OPNsense that you can run with a cron job. Go to the cron settings and you can see the script in the dropdown

It basically tests for a stale WG connection on whatever interval you set and restarts WG if one is detected

Found the script you mentioned. I'll check it.

Thanks so much and happy new year Greelan!