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

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Quick guide Debian Setting up wireguard on a server (wireguard-go)  (Read 9965 times)

0 Members and 1 Guest are viewing this topic.

vs2-free-users

  • Newbie
  • *
  • Offline Offline
  • Posts: 2

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-go

Preparation

Update Debian packages and reboot if necessary.
Code: [Select]
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: [Select]
apt install golang wireguard-tools

- Download wireguard-go and make it executable
Code: [Select]
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: [Select]
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey

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

Content
Code: [Select]
[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: [Select]
vim /etc/wireguard/wg0-up.bash

Content
Code: [Select]
#!/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: [Select]
chmod +x /etc/wireguard/wg0-up.bash

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

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

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

- install golang and wireguard-tools
Code: [Select]
apt install golang wireguard-tools

- Download wireguard-go and make it executable
Code: [Select]
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: [Select]
mkdir -p /etc/wireguard/
cd /etc/wireguard/
wg genkey | tee privatekey | wg pubkey > publickey

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

Content
Code: [Select]
[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: [Select]
vim /etc/wireguard/wg0-up.bash

Content
Code: [Select]
#!/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: [Select]
chmod +x /etc/wireguard/wg0-up.bash

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

- Reboot (after which everything is configured)
Code: [Select]
reboot
« Last Edit: March 13, 2024, 10:06:52 AM by vs2-free-users »
Logged


kurtisthebard

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
Re: Quick guide Debian Setting up wireguard on a server (wireguard-go)
« Reply #1 on: November 11, 2024, 06:59:04 PM »

For setting up WireGuard with wireguard-go on Debian without kernel support you’re on the right path:DSmall tweak suggestion: in your script /etc/wireguard/wg0-up.bash, try adjusting sleep duration if issues arise with interface activation timing. Also, be sure firewall rules (iptables/nftables) allow traffic on port 51820 for both hosts :)
Logged

razor1986

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
Re: Quick guide Debian Setting up wireguard on a server (wireguard-go)
« Reply #2 on: November 15, 2024, 10:12:32 AM »

For setting up WireGuard with wireguard-go on Debian without kernel support you’re on the right path:DSmall tweak suggestion: in your script /etc/wireguard/wg0-up.bash, try adjusting sleep duration if issues arise with interface activation timing. Also, be sure firewall rules (iptables/nftables) allow traffic on port 51820 for both hosts :)

Thanks for the tips. :D
Logged
Pages: [1]   Go Up
 

Page created in 0.081 seconds with 23 queries.