How to check if WireGuard client/peer is connected?

You can useĀ wg show to check if a client is connected:

interface: Computer
  public key: X6NJW+IznvItD3B5TseUasRPjPzF0PkM5+GaLIjdBG4=
  private key: (hidden)
  listening port: 19628

peer: H3KaL/X94984cLDNWFsM4Hx6Rs/Ku0bW2ECkDUn7wFw=
  endpoint: 10.9.1.108:19628
  allowed ips: 10.217.59.2/32
  latest handshake: 27 seconds ago
  transfer: 13.19 MiB received, 12.70 MiB sent
  persistent keepalive: every 1 minute

Look for this line:

latest handshake: 27 seconds ago

If it’s less than two minutes old, the client is connected.

If theĀ latest handshake line is missing entirely, the peer has never connected successfully!

If in doubt, you can often ping the client to verify. It depends on the client configuration and possibly firewall settings if it will answer the ping but it never hurts to try.