Skip to content

Instantly share code, notes, and snippets.

@svet-b
Last active July 30, 2020 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save svet-b/29f384d7174ef3a734fa7c0948ac391f to your computer and use it in GitHub Desktop.
Save svet-b/29f384d7174ef3a734fa7c0948ac391f to your computer and use it in GitHub Desktop.
Install WireGuard userspace on Linux
sudo apt update && sudo apt upgrade
sudo apt install golang
sudo apt-get install libmnl-dev libelf-dev build-essential pkg-config
git clone https://git.zx2c4.com/wireguard-go
cd wireguard-go/
git checkout 0.0.20181001 # Get the desired release tag from `git tag`
make
sudo make install
cd ..
git clone https://git.zx2c4.com/WireGuard
cd WireGuard
git checkout 0.0.20181007 # Get the desired release tag from `git tag`
cd src
make tools
sudo make -C tools install
#make: Entering directory '/home/svetlio/git/WireGuard/src/tools'
#'wg' -> '/usr/bin/wg'
#'man/wg.8' -> '/usr/share/man/man8/wg.8'
#'completion/wg.bash-completion' -> '/usr/share/bash-completion/completions/wg'
#'wg-quick/linux.bash' -> '/usr/bin/wg-quick'
#install: creating directory '/etc/wireguard'
#'man/wg-quick.8' -> '/usr/share/man/man8/wg-quick.8'
#'completion/wg-quick.bash-completion' -> '/usr/share/bash-completion/completions/wg-quick'
#'systemd/wg-quick@.service' -> '/lib/systemd/system/wg-quick@.service'
#make: Leaving directory '/home/svetlio/git/WireGuard/src/tools'
## At this point both the wg and wireguard-go executables should be available
## Now create the setup
sudo su -
cd /etc/wireguard
umask 077
wg genkey | tee privatekey | wg pubkey > publickey
nano wg0.conf
### Start file
[Interface]
PrivateKey = <Output of privatekey file that contains your private key>
#Address = 192.168.2.5/24 ## for some reason address can't be set in here when doing it this way
[Peer]
PublicKey = <Server Public key>
Endpoint = <Server Public IP>:51820
AllowedIPs = 192.168.2.1/24
### End file
export WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1
wireguard-go wg0
# EITHER:
ip address add dev wg0 192.168.2.5/24
wg setconf wg0 /etc/wireguard/wg0.conf
ip link set up dev wg0
# OR (after uncommenting the "Address" line in the config file):
wg-quick up wg0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment