Quick guide Debian Setting up wireguard on a server (wireguard-go)

vs2-free-users

Active Member
Joined
Jun 8, 2023
Messages
195
Reaction score
94
Credits
1,310
Quick guide Debian Setting up wireguard on a server (wireguard-go)

Preface

Since you cannot currently use the standard wireguard on the vs2-free (not active in the kernel), I have taken a look at how you can still use wireguard. In my instructions I have used 2 vs2-free hosts. Of course you can also use the normal wireguard at home.

Structure

Host A vs2-free with booked and configured IPv4. OS Debian 12 (Bookworm) - 64Bit - minimal v4.
Host B vs2-cloud with booked and configured IPv4. OS Debian 12 (Bookworm) - 64Bit - minimal v4.

wireguard-go (Version 0.0.20220316, the current one did not work because Debian does not yet have golang 1.20)

Preparation

Update Debian packages and reboot if necessary.
Code:
apt update
apt upgrade
reboot


Set up host A (ends up with IP 10.0.0.1 via wireguard)

- install golang and wireguard-tools
Code:
apt install golang wireguard-tools

- Download wireguard-go and make it executable
Code:
wget -O /usr/bin/wireguard-go https://12-u.vs2-free-users.de/mirror/wireguard-go/debian12/wireguard-go
chmod +x /usr/bin/wireguard-go

- Create wireguard keys (private and public)
Code:
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey

- create wireguard config (wg0)
Code:
vim /etc/wireguard/wg0.conf

Content
Code:
[Interface]
PrivateKey = <Previously created private key>
ListenPort = 51820

[Peer]
PublicKey = <Public key from host B>
AllowedIPs = 10.0.0.2/32
Endpoint = <Official IP Host B>:51820

- Create start script
Code:
vim /etc/wireguard/wg0-up.bash

Content
Code:
#!/bin/bash

sleep 60
wireguard-go wg0
wg setconf wg0 /etc/wireguard/wg0.conf
ip address add 10.0.0.1/24 dev wg0
ip link set wg0 up

- Make script executable
Code:
chmod +x /etc/wireguard/wg0-up.bash

- Create autostart via cron
Code:
echo '@reboot root /etc/wireguard/wg0-up.bash' >> /etc/crontab

- Reboot (after which everything is configured)
Code:
reboot

Set up host B (ends up with IP 10.0.0.2 via wireguard)

- install golang and wireguard-tools
Code:
apt install golang wireguard-tools

- Download wireguard-go and make it executable
Code:
wget -O /usr/bin/wireguard-go https://12-u.vs2-free-users.de/mirror/wireguard-go/debian12/wireguard-go
chmod +x /usr/bin/wireguard-go

- Create wireguard keys (private and public)
Code:
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey

- create wireguard config (wg0)
Code:
vim /etc/wireguard/wg0.conf

Content
Code:
[Interface]
PrivateKey = <Previously created private key>
ListenPort = 51820

[Peer]
PublicKey = <Public key from host A>
AllowedIPs = 10.0.0.1/32
Endpoint = <Official IP Host A>:51820

- Create start script
Code:
vim /etc/wireguard/wg0-up.bash

Content
Code:
#!/bin/bash

sleep 60
wireguard-go wg0
wg setconf wg0 /etc/wireguard/wg0.conf
ip address add 10.0.0.2/24 dev wg0
ip link set wg0 up

- Make script executable
Code:
chmod +x /etc/wireguard/wg0-up.bash

- Autostart über cron erstellen
Code:
echo '@reboot root /etc/wireguard/wg0-up.bash' >> /etc/crontab

- Reboot (after which everything is configured)
Code:
reboot
 
Last edited:


Today i have tested the configuration on my salixos at home. It works out of the box. I can configure it on the network manager.
On the server side it require a little change.
The line
Code:
Endpoint = <Official IP Host>:51820

is not required for the client.
 

Members online


Top