How to install and configure Wireguard on RHEL 8 - nomorespice/rhel8-howto GitHub Wiki

WireGuard is a free and open-source software application and communication protocol that implements virtual private network (VPN) techniques to create secure point-to-point connections in routed or bridged configurations. This procedure will guide you through the installation and configuration on a Red Hat Enterprise Linux 8 server.

This document assumes that:

  • you installed the RHEL 8 x64 Operating System according to How to install RHEL 8 via kickstart
  • you are performing these tasks as root
  • you are performing these tasks in order, as some tasks require others to be completed first

Install required software

subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms
yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
yum --enablerepo=epel install kmod-wireguard wireguard-tools
modprobe wireguard

Configure Wireguard

Be sure to replace KEY in /etc/wireguard/wg0.conf with the contents of /etc/wireguard/privatekey

wg genkey | tee /etc/wireguard/privatekey | wg pubkey | tee /etc/wireguard/publickey
wg genpsk > /etc/wireguard/client.psk

/bin/cat <<\EOT >/etc/wireguard/wg0.conf
[Interface]
Address = 192.168.99.1/24
SaveConfig = true
ListenPort = 31337
PrivateKey = KEY
EOT

chmod 600 /etc/wireguard/{privatekey,wg0.conf,client.psk}

systemctl --now enable wg-quick@wg0

Add Peer

Be sure to replace PEER_PUBLIC_KEY in with the peer node public key, also ensure IP address is correct.

wg set wg0 peer PEER_PUBLIC_KEY preshared-key /etc/wireguard/client.psk allowed-ips 192.168.99.2
⚠️ **GitHub.com Fallback** ⚠️