Configuring WireGuard on CentOS, Debian, Ubuntu, and FreeBSD in four different ways

7/August/2026 wireguardcentosdebianubuntufreebsd

WireGuard 1600x896 wireguard.png
WireGuard

Below is a set of snippets for configuring WireGuard for three different Linux distributions and FreeBSD.
The setup assumes a Debian server with a 10.9.21.0/24 network.

Server, Debian

apt install wireguard-tools
nano /etc/network/interfaces.d/wg0

1
2
3
4
5
6
7
8
auto wg0
iface wg0 inet static
    address 10.9.21.1/32
    pre-up ip link add wg0 type wireguard
    pre-up wg setconf wg0 /etc/wireguard/wg0.conf
    up ip -4 route add 10.9.21.0/24 dev wg0
    # up /bin/systemctl restart sshd.service
    post-down ip link del wg0

umask 077
cd /etc/wireguard/
wg genkey > server-private.key
wg pubkey < server-private.key > server-public.key

nano /etc/wireguard/wg0.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[Interface]
ListenPort = 1234
PrivateKey = <server-private.key>

[Peer]
# Debian client
PublicKey = <public.key>
AllowedIPs = 10.9.21.3/32

[Peer]
# CentOS client
PublicKey = <public.key>
AllowedIPs = 10.9.21.4/32

[Peer]
# Ubuntu client
PublicKey = <public.key>
AllowedIPs = 10.9.21.5/32

[Peer]
# FreeBSD client
PublicKey = <public.key>
AllowedIPs = 10.9.21.6/32
Configuring WireGuard on...

How to make an OpenVPN 90% as fast as a WireGuard

27/January/2023 openvpnkernelwireguard

There are a lot of articles on the Internet about improving OpenVPN speed, and often they are all focused on the settings of the server-client itself, packet sizes, encryption algorithms or disabling them. Everyone compares OpenVPN to a WireGuard. WireGuard works in kernel space and that’s what determines everything. Compared to userspace for openvpn. But that’s not quite true.

Here I must immediately clarify, that the given method of solving the problem is specific for virtual machines with small memory size, from 1Gb to 8Gb, in other cases you need to compare memory, link bandwidth and speed.

Here is a list of dynamically set values ​​relative to the system memory size:

  • sysctl net.core.rmem_default
  • sysctl net.core.rmem_max
  • sysctl net.core.wmem_default
  • sysctl net.core.wmem_max
  • sysctl net.core.somaxconn
  • sysctl net.core.netdev_max_backlog
  • sysctl net.core.optmem_max
  • sysctl net.ipv4.udp_mem
  • sysctl net.ipv4.udp_rmem_min
  • sysctl net.ipv4.udp_wmem_min
  • sysctl net.ipv4.tcp_mem
  • sysctl net.ipv4.tcp_rmem
  • sysctl net.ipv4.tcp_wmem
  • sysctl net.ipv4.tcp_synack_retries
  • sysctl net.ipv4.tcp_keepalive_time
  • sysctl net.ipv4.tcp_max_tw_buckets
How to make...

KVM over LVM

20/December/2019 kvmlvmpartedvirsh

Without further explanation

1
2
3
4
5
6
7
8
9
10
parted -a optimal /dev/sda
unit MiB
print free

#    Number  Start     End        Size       Type     File system     Flags
#            0,03MiB   1,00MiB    0,97MiB             Free Space
#     1      1,00MiB   1025MiB    1024MiB    primary  ext4            boot
#     2      1025MiB   5121MiB    4096MiB    primary  linux-swap(v1)
#     3      5121MiB   70657MiB   65536MiB   primary  ext4
#            70657MiB  476940MiB  406283MiB           Free Space
KVM over LVM...

Missing mime-types in nginx

5/December/2019 nginxmime-typeswoff

To display Content-Type correctly, you need to add the following values ​​to mime.types
otherwise the default_type application/octet-stream; directive will be used.

Missing mime-types in...

Snippets mdadm

24/January/2019 mdadmraid

Setting minimum and maximum speeds for devices

1
2
3
# 70000 kilobytes/s ~ 68 Mb/s
echo "70000" > /proc/sys/dev/raid/speed_limit_min
echo "100000" > /proc/sys/dev/raid/speed_limit_max

sysctl analogue

1
2
dev.raid.speed_limit_min=70000
dev.raid.speed_limit_max=100000
Snippets mdadm
Page 1 from 2