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)
https://github.com/WireGuard/wireguard-goPreparation
Update Debian packages and reboot if necessary.
apt update
apt upgrade
reboot
Set up host A (ends up with IP 10.0.0.1 via wireguard)
- install golang and wireguard-tools
apt install golang wireguard-tools
- Download wireguard-go and make it executable
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)
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey
- create wireguard config (wg0)
vim /etc/wireguard/wg0.conf
Content
[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
vim /etc/wireguard/wg0-up.bash
Content
#!/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
chmod +x /etc/wireguard/wg0-up.bash
- Create autostart via cron
echo '@reboot root /etc/wireguard/wg0-up.bash' >> /etc/crontab
- Reboot (after which everything is configured)
reboot
Set up host B (ends up with IP 10.0.0.2 via wireguard)
- install golang and wireguard-tools
apt install golang wireguard-tools
- Download wireguard-go and make it executable
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)
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey
- create wireguard config (wg0)
vim /etc/wireguard/wg0.conf
Content
[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
vim /etc/wireguard/wg0-up.bash
Content
#!/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
chmod +x /etc/wireguard/wg0-up.bash
- Create autostart via cron
echo '@reboot root /etc/wireguard/wg0-up.bash' >> /etc/crontab
- Reboot (after which everything is configured)
reboot