User Tools

Site Tools


cheatsheet:wireguard

This is an old revision of the document!


wireguard command cheatsheet

create private & public key files

$ wg genkey | tee privatekey | wg pubkey > publickey
 
$ ls
total 16
drwx------  2 root root 4096 Nov 25 22:15 .
drwxr-xr-x 65 root root 4096 Nov 25 22:08 ..
-rw-r--r--  1 root root   45 Nov 25 22:15 privatekey
-rw-r--r--  1 root root   45 Nov 25 22:15 publickey
 
You should however limit access to these :
$ chmod 600 *key
 
$ ls -al
total 16
drwx------  2 root root 4096 Nov 25 22:15 .
drwxr-xr-x 65 root root 4096 Nov 25 22:08 ..
-rw-------  1 root root   45 Nov 25 22:15 privatekey
-rw-------  1 root root   45 Nov 25 22:15 publickey

enable wireguard as a service

$ sudo systemctl enable wg-quick@wg0

start / stop wireguard

$ sudo systemctl start wg-quick@wg0
 
$ sudo systemctl stop wg-quick@wg0

see wireguard status

$ sudo wg show
 
interface: wg0
  public key: GHI-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x=
  private key: (hidden)
  listening port: 1234
 
peer: DEF-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x=
  endpoint: 1.2.3.4:1234
  allowed ips: 10.1.248.10/32
  latest handshake: 43 seconds ago
  transfer: 12.98 KiB received, 28.82 KiB sent
 
peer: ABC-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x=
  endpoint: 1.2.3.4:1234
  allowed ips: 10.1.248.11/32
  latest handshake: 28 minutes, 46 seconds ago
  transfer: 13.39 KiB received, 21.38 KiB sent
 
TIP: use "$ watch sudo wg show" to create the effect of an constantly updating status window
cheatsheet/wireguard.1676370508.txt.gz · Last modified: 2023/02/14 10:28 by kamaradski