Wireguard server with dynamic ip - client route not updated

Hi. i have a wireguard server with dynamic ip. Client connects using ddns.
Client is travel-box. It routes all the traffic via wg interface.
Persistence turned on, 25 sec timeout.
wireguard_watchdog script runs every minute - In case server ip changes it picks up new ip address and updates wg0 configuration.
BUT... tunnel stops working when server IP has changed.... because there is old static route and no new route.
Routes before IP changes:
1) default via wg0
2) [server ip] via [local gateway ip]

so, after server gets new ip, tunnel config got updated automatically by watchdog, but static routes not.
If i manually add new static route
[new server ip] -> via [local gateway ip]
then tunnel starts working fine.

What am i doing wrong?
Is there better wireguard_watchdog version which takes care of new static route as well?

p.s. its openwrt 18.06

It's no longer supported.
wireguard_watchdog doesn't add/remove the routes. Have a look at its code:

  logger -t "wireguard_monitor" "${iface} endpoint ${endpoint_host}:${endpoint_port} is not responding for ${idle_seconds} seconds, trying to re-resolve hostname"
  wg set ${iface} peer ${public_key} endpoint "${endpoint_host}:${endpoint_port}"

It will update the endpoint_host with the new IP. An idea is to add a line under there to add the new static route.

1 Like