17.03.2022: Changed the Gateway-Address from local WG-Address to the remote WG-Address (Local WG-Gateway), as described in the official manual. Fixed some typos an formatting
dnf install epel-release -y
dnf install kmod-wireguard wireguard-tools -y
mkdir /etc/wireguard
umask 077
wg genkey | tee /etc/wireguard/wireguard.key | wg pubkey > /etc/wireguard/wireguard.pub.key
cat /etc/wireguard/wireguard.key
vi /etc/wireguard/wg0.conf
[Interface]ListenPort = 55555PrivateKey = [PrivateKey from the Endpoint/this Machine]Address = 10.0.8.1/32PreUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEPreUp = iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtuPostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADEPostDown = iptables -D FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu[Peer]PublicKey = [PublicKey from OPNsense-Wireguard]AllowedIPs = 10.0.8.2/32
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
cat /etc/wireguard/wireguard.pub.key
wg-quick up wg0
wg-quick down wg0
wg
systemctl start wg-quick@wg0
systemctl enable wg-quick@wg0