Martijn van Wely <[email protected]> writes: > There's probably ways to improve the script, like only updating things > when the peer's ip-address has actually changed, but this works for > now.
I think it is better to check for a change and only do update calls when there is a mismatch. I mean to check the current address in DNS vs the address that is currently configured (via a wgconfig show invocation), not the address you think you most recently configured. I have scripts for similar purposes (dealing with name->address changes), and the basic flow is a check script that tries to use the facility (ping across it), if works, then call it good uses host/dig/whatever to resolve the name if that succeeds (vs empty!), and if it's different from what's configured, fix the configuration and I invoke this from cron at a timescale that is short enough that problems will get fixed before I'm seriously inconvenienced long enough to not unreasonably consume resources > If anyone knows how to actually fix this without running this cronjob, > of course please share. You basically have to check periodically. You could have the client connect to someplace that gets a notification on dns change and sit there with an open tcp connection, but that's more complicated, and you still need periodic checking for reliability. To make things seem less ad hoc, the path is to write the scripts more generically to read a config file, to not try to make them one line, and to have comments and logging about the steps.
