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

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