1. Install the necessary packages
pkg_add wireguard-tools vim
  1. Enable IP Forwarding
sysctl net.inet.ip.forwarding=1
echo 'net.inet.ip.forwarding=1' >> /etc/sysctl.conf
  1. Make a directory to store your wg keys
mkdir ~/wg && cd wg
wg genkey | tee .private | wg pubkey > .public
  1. Create the wireguard interface
vim /etc/hostname.<INTERFACE_NAME>
  1. In the interface file setup the basics
# Server setup
inet <IP_ADDRESS> <SUBNET_MASK>
wgkey <SERVER_PRIVATE_KEY>
wgport <WG_PORT>

# Peer setup
wgpeer <CLIENT_PUBLIC_KEY> wgaip <ALLOWED_IP>/32