I have a WireGuard VPN server running. How do I set a timeout so that connected clients will get disconnected if they are idle for the given time (or maybe even disconnection irrespective of being idle or not)? Where do I specify this parameter, I see no mention of it in the Wire Guard Documentation.
There is no such parameter in WireGuard as, clients can go quiet at any time and expect to be able to talk to the server again at any time later.
Specifically, the protocol requires a client to handshake with the server to begin a session. To maintain the session a client must handshake at least once every 180 seconds. In practice, the handshake happens some time between 120 and 180 seconds.
If a client stops talking and at a later time wants to start talking again, providing the server is active then,if the time since last talking is:
- <120 seconds, carry on as normal
- >=120 seconds, <=180 seconds carry on and handshake within 60 seconds.
- > 180 seconds, handshake and carry on
The server and client maintain timers so that they always know what to do and when to do it.
Thus, WireGuard is a connectionless protocol and there is no need to worry about timeouts. A client is either talking (and handshaking as required) or silent.