Fully update OpnSense and install the os-Wireguard package. You'll find the packages in System->Firmware->Plugins
Reload the web interface and open VPN->WireGuard
In the General tab, enable wireguard
In the Local tab, add a server. Set a Listen Port - The port your incoming UDP connections, e.g. 51820. Also set a DNS Server e.g. 184.108.40.206.
The Tunnel Address is a network you select, e.g. 10.0.10.0/24
They public and private keys will be generated automatically once you save.
(return once you have configured the clients to add them to the Peers field).
Go to the Endpoints tab and add your first Endpoint/client.
Select a Name and configure the port you use as listen port - e.g. 51820.
Configure an allowed IP in the range you configured earlier, e.g. 10.0.10.2/32.
They public key is the one you generate on the client device.
Install the official WireGuard client.
Click the plus and Create from scratch
First, configure the interface section (this is the client info)
Set a Name and auto-generate a Public key (you need this on the server's client configuration)
Select the address you configured on the server's client config e.g. 10.0.10.2/32. Set a DNS like 220.127.116.11
Set the listen port - e.g. 51820.
Now add a peer (this is the server you are connecting to)
In Public Key you should enter the public key generated on the entry in the Local tab in OpnSense - your server's public key.
Allowed IPs can be set to 0.0.0.0/0, ::/0 if you don't want to restrict what IPs should be reachable via the connection.
The Endpoint is where you want to connect to - e.g. server.com:51820 or 18.104.22.168:51820
Go to Firewall->NAT->Port Forward and add a rule to allow traffic to your WireGuard server from the internet.
Go to Firewall->Rules->Wireguard->Add
Save and apply.
Go to Firewall->NAT->Outbound
Go to Interfaces->Assignments and select the wg0 in the New Interface dropdown and add it. Press Save.
Open the interface, rename it from OPT1 to WG, enable and tick Prevent interface removal. Save and apply changes.
Restart OpnSense if no traffic is flowing.