WireGuard on Kernel 5.6. Quick start

Автор | 07.04.2020
cd /tmp
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-headers-5.6.0-050600_5.6.0-050600.202003292333_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-headers-5.6.0-050600-generic_5.6.0-050600.202003292333_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-image-unsigned-5.6.0-050600-generic_5.6.0-050600.202003292333_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6/linux-modules-5.6.0-050600-generic_5.6.0-050600.202003292333_amd64.deb

Install all downloaded deb’s

dpkg -i *.deb

Reboot server/PC by command reboot

After startup check the kernel version^

uname -a
Linux test-srv 5.6.0-050600-generic #202003292333 SMP Sun Mar 29 23:35:58 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Test Wireguard on server

ip link add dev wg0 type wireguard
ip address add dev wg0
#get current state:
ip a s wg0
3: wg0: <POINTOPOINT,NOARP> mtu 1420 qdisc noop state DOWN group default qlen 1000
    inet scope global wg0
       valid_lft forever preferred_lft forever

Add repository for ubuntu 18.04

add-apt-repository ppa:wireguard/wireguard
apt-get update
apt-get install wireguard-tools resolvconf

Make some changes to Firewall on server

# to enable kernel relaying/forwarding ability on bounce servers
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.ipv4.conf.all.proxy_arp = 1" >> /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf

# to add iptables forwarding rules on bounce servers
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wg0 -o wg0 -m conntrack --ctstate NEW -j ACCEPT
iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

Simple script for generating key pairs and base cofigs for server and client



#create Server key
`wg genkey | tee wg-s-private.key | wg pubkey > wg-s-public.key`
#create Client key
`wg genkey | tee wg-c-private.key | wg pubkey > wg-c-public.key`

S_PRIV_KEY=`cat wg-s-private.key`
S_PUB_KEY=`cat wg-s-public.key`
C_PRIV_KEY=`cat wg-c-private.key`
C_PUB_KEY=`cat wg-c-public.key`

cat >wg0.server <<EOF
Address = ${S_IP}
ListenPort = ${PORT}
PrivateKey = ${S_PRIV_KEY}
DNS =,

# Name = notebook
PublicKey = ${C_PUB_KEY}
AllowedIPs = ${C_IP}

cat >wg0.client <<EOF
# Name = laptop
Address = ${C_IP}
PrivateKey = ${C_PRIV_KEY}
DNS =,
# If you have additional local networks, add static routes for it
#PostUp = ip route add via;
#PreDown = ip route delete

Endpoint = ${HOST}:${PORT}
PublicKey = ${S_PUB_KEY}
# routes traffic to itself and entire subnet of peers as bounce server
AllowedIPs = ${S_IP},,::/0
PersistentKeepalive = 25


Or download here:

Put wg0.server as /etc/wireguard/wg0.conf on Server side and wg0.client on Client side in the same place

Startup interface on machines

wg-quick up wg0

For Android clients you can use config file as QR code

qrencode -t ansiutf8 < wg0.client

Залишити відповідь