OPNsense Forum

Archive => 22.1 Legacy Series => Topic started by: emaba on February 09, 2022, 10:25:10 pm

Title: Wireguard not reconnecting when remote IP change
Post by: emaba on February 09, 2022, 10:25:10 pm
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,
Title: Re: Wireguard not reconnecting when remote IP change
Post by: z1p on January 02, 2023, 07:59:31 pm
Hello there! Hope your fine! Can ask you if you came with a solution for this? Thanks
Title: Re: Wireguard not reconnecting when remote IP change
Post by: 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
Title: Re: Wireguard not reconnecting when remote IP change
Post by: z1p on January 03, 2023, 12:54:25 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!