Running Gateway on OPNsense firewall
OPNsense plugin
OPNsense® is an open source, feature rich firewall and routing platform, offering cutting-edge network protection.
To start Defguard Gateway as OPNsense plugin:
On the release page find and download OPNsense package which will be named:
defguard-gateway_VERSION_x86_64-unknown-opnsense.pkg– this package includes both Defguard Gateway and OPNsense plugin.Install the package:
pkg add defguard-gateway_VERSION_x86_64-unknown-opnsense.pkgRefresh your OPNsense UI by running command below:
opnsense-patchGo to your OPNsense UI and navigate to VPN → Defguard Gateway.

Fill out the form with appropriate values, click Save, and then click Start/Restart.
You can find detailed description of all fields here.
At this point the Gateway should be connected to Defguard Core. Before users can reach anything through it, OPNsense itself still needs an interface, a NAT rule and a firewall rule - continue with OPNsense network configuration.
OPNsense network configuration
The steps below are based on the WireGuard Road Warrior Setup from the OPNsense documentation.
Assign a network interface to Defguard
Go to Interfaces → Assignments
Under Assign a new interface, select the Defguard Gateway network interface (e.g. wg0)
Add a description, for example ParisOfficeVPN
Click Add

Select the newly create interface by clicking on its name (in this example [ParisOfficeVPN]).
Select Enable Interface
Select Prevent interface removal
Click Save, and then Apply changes
Create an outbound NAT rule
Go to Firewall → NAT → Outbound
Make sure the selected Mode is Hybrid outbound NAT rule generation; if it wasn't selected, click Save and then Apply changes
Under Manual rules, add a new rule by clicking +.
Select Interface – this should be either WAN or LAN, depending on the needs.
Select TCP/IP version – either IPv4 or IPv6.
Select Source address – this should be interface name assigned above plus net, e.g. ParisOfficeVPN net.
Click Save, and then Apply changes

Add firewall rules to allow WireGuard traffic in
Go to Firewall → Rules → WAN
Click + (plus) to add a new rule
The rule should Pass the traffic in with quick option enabled
Select WAN interface
Choose TCP/IP version of your desire
Select UDP protocol.
Set Destination to WAN address and port to the port number provided in Defguard Core: Location configuration → Gateway port
Click Save, and then Apply changes
Once this is done you can start adding new devices to your network.
Binary Install
Use this method if you are not running the OPNsense plugin.
Checkout Gateway releases here and download compatible binary from GitHub page.
Decompress and move to bin directory
Start the gateway:
The binary archive does not include a configuration file, and every Gateway option has a default, so the gateway starts without one. To change any of them - for example the WireGuard interface name or the statistics period - create a TOML file and pass it with --config, using the example in Defguard Gateway as a reference.
When you pass --config, the file becomes the only source of configuration - see Config file.
Adopt the gateway in Defguard Core, as described in Adopt the Gateway component. Core connects to the gateway's gRPC port (
50066by default) and issues its certificates during adoption, so no token or Core address needs to be configured on the gateway side.
Last updated
Was this helpful?