Wireguard VPN is setup on OpenWrt and works perfectly.
However, when I run this command to change the endpoint:
wg set wg0 peer $publickey endpoint $ip:$port
All the variables are correct of course. But I don't see any change. It's still using the old endpoint. I wish to change the endpoint without interrupting the connection by restarting the interface.
problem isn't (re)connecting, if it happens below the timeout value for whatever application is using the tunnel, no one will (probably) notice, assuming you get the same IP back in the other end.
but if you change the end point, the IP of where the WG tunnel ends (internet ?), will change, right ?
Maybe not what you are looking for but I use a script with which I can toggle WG tunnels on/off via the command line.
Basically I use my phone with an SSH client to switch tunnels:
Can you show this Wireguard configuration in /etc/config/network
?
Redact the keys, and you can use example addresses for the endpoints.
I'm more versed in editing the file, but another user could provide the UCI commands for you to change the endpoint and reload the interface.
To be clear, in general, your streaming will stop if your TCP/IP connection parameters change (e.g. the IP of the VPN SRC traffic) - but usually that's seamless if there's a buffer on the player.
Wow, gotcha. You may have to script this yourself - and if you need OpenWrt's firewall, etc., add the interface to the config as unmanaged protocol 'none'.
It's not clear why you use the UCI to configure the interface, but then wish to use underlying commands to alter it (BTW, not supported in OpenWrt).
Just curious, is there a reason for that in your use case?
Also, would you need to revert to the configuration in the UCI after altering it via the wg command?
My intention is simply to change the endpoint of the VPN to another server whenever the previous server becomes too loaded and thus, slow.
Using wg set however doesn't seem to do anything. A reddit user has an idea why that may be (all VPN servers use the same public key):
Are both servers using the same public key? Otherwise you need to update allowed IPs as well. Are you aware of the fact that the endpoint address will be changed when you receive (authenticated) traffic from the endpoint (i.e. identified by the public key), which means it will be reverted back to the old address if the two servers use the same public key and you receive traffic from the old server. Something you can try is to drop the old connection with conntrack, and add a firewall rule which denies traffic from the old server (in case your firewall would allow it otherwise).
The reason I use uci to change the endpoint is because it works, at least after a restart of the vpn interface. So that works. The problem with that approach is that streaming services exit the player when doing so. The video is not just paused for a second.
So I wonder whether there is a more 'graceful' approach.
There would be no traffic from the old IP...unless this is another value being altered and wasn't mentioned.
Just to be clear of your use case. Are you merely switching e.g. geographical servers from the same VPN service, or something else?
Basically as the quote asked, do both endpoints have your public key and allowed IP listed, correct?
Edit:
Or are you saying you have some "out-of-band" knowledge that the remote endpoint changed its IP - and that that new IP can't simply update by sending new packets?
Are you merely switching e.g. geographical servers from the same VPN service, or something else?
This. It's a very simple thing really. The only parameter that changes from server to server is the endpoint. All other things stay the same (public key, private key, allowed IPs, etc.)