MergenHub Envest
Home/Docs/User Manual (in-app, complete)

MergenHub VPN (field modems)

What it does, how to set it up

3.13 · Phase 1

MergenHub VPN is a WireGuard-compatible VPN server that runs inside the MergenHub service. Field modems (Teltonika, MikroTik, OpenWrt…) connect to the hub over a single UDP port, each with its own key pair; the PLCs behind a modem are read by MergenHub drivers at their tunnel address. No separate VPN program, extra Windows service or open port at the site is needed: the modem connects outwards.

Page: Add-ons › VPN in the left menu. It has three tabs: Overview (status, connected sites, traffic, external address, hub public key), Field devices (table + the Add site wizard) and Settings (external address, UDP port, MTU, tunnel address). Seeing the page needs the Server settings permission; changing it also needs the VPN management (vpn.admin) action.

First setup: step by step

  1. Port forwarding. On the organisation's firewall / modem forward UDP 51820 (or the port you chose in the settings) to the MergenHub server. This is the only port open to the internet; the web interface and OPC UA stay closed. You do not have to open the Windows Firewall rule by hand (step 3).
  2. External address. On the Settings tab write the server's public IPv4 address or DNS name, optionally with a port, into External address (e.g. vpn.customer.gov.tr, vpn.customer.gov.tr:51820 or 203.0.113.10). Anything else (spaces, commands, paths) is refused. If the DNS is on Cloudflare the record must be DNS only (grey cloud): the Cloudflare proxy does not carry UDP. Save.
  3. Turn on. On Overview turn on the VPN on switch. On the first start the hub key pair is generated, a network adapter named MergenHub VPN is created (the WireGuardNT engine shipped with the installer installs its Windows-signed driver), the address 10.66.0.1/16 is assigned and the status becomes Running. At the same time MergenHub adds an inbound UDP rule named "MergenHub VPN" (the port in the settings) to the Windows Firewall by itself; it updates the rule when the port changes and removes it when the VPN is turned off.
  4. Add a site. Define the first modem with Field devices › Add site (see Adding a field modem).
Status: OffThe VPN was turned off on purpose.
Status: UnavailableThe tunnel engine cannot run: the engine file (wireguard.dll; the installer puts it in C:\Program Files\MergenHub\) was deleted or is damaged, the operating system is not suitable, or the native layer is off on a development server. The service keeps running; the "VPN service down" alarm is raised.
Status: ErrorThe adapter could not be created or the configuration could not be applied; details are on the row and in the audit log (vpn.apply.fail, Win32 error code). The service retries every minute.
Keys The private keys of the hub and the modems and the pre-shared keys (PSK) are encrypted on disk with the stored passwords vault (keys\ folder); they are masked in API responses and never written to the audit log. The key travels with the backup: when the backup is opened on another server the VPN keys open too, and if the external address was given as a DNS name the modems need no change.
Uninstalling When MergenHub is uninstalled (Programs and Features) the "MergenHub VPN" firewall rule and the WireGuard driver are removed too.

Adding a field modem (wizard)

Field Devices › Add site opens a four-step wizard. The external address must have been entered under Settings first.

  1. Site: the site name (e.g. Free Zone Well 1192; unique, at most 64 characters), the modem model: Teltonika RUT / RUTX / TRB, MikroTik RouterOS 7, OpenWrt or Other; and, optionally, Devices using this modem. On a GSM site each device usually has its own modem: select that device, and which .conf belongs to which device is shown in the table (Devices column) and in the device's ••• › VPN modem menu. A device can be linked to only one modem; one modem can have several devices behind it.
  2. LAN: the access mode. Routed: when the site's LAN is unique (e.g. 192.168.21.0/24); devices are read at their real IPs and the hub routes this range into the tunnel. Modem only: when the PLC is reachable through the modem's port forwarding; in the driver the device address is the modem's tunnel IP (e.g. 10.66.0.11:502). The Check button compares the range with the tunnel network (10.66.0.0/16), the mapping block (10.100.0.0/16), the other sites' LANs and the server's own networks. If there is a conflict the wizard does not go on. Mapped (1:1 NAT) mode comes in Phase 3.
  3. Summary: Create generates the modem key pair and the PSK, gives the next free address in the site block (10.66.0.0/22; first address 10.66.0.10), adds the peer live without restarting the service and writes the routing. If it cannot be applied to the adapter, nothing is saved.
  4. Setup: one-time links: WireGuard .conf, QR code and, for MikroTik / OpenWrt, a script; below them, model-specific step-by-step setup. The window waits for the modem to connect; on the first handshake it says Modem connected.
One-time link Each link works once and for 24 hours; it needs no sign-in (it can be sent to the technician on site). Because the configuration carries the modem's private key, it is downloaded from outside the local network only over HTTPS: a link opened from the internet with http:// is refused (the link is not used up); turn on HTTPS in Settings and open it with https://. A used or expired link says "link already used / expired" and is written to the audit log as vpn.config.link_reuse. For a new one use New download link in the row's ••• menu. The QR code also uses up the link: it loads only when you press Show QR code.

Row menu (•••)

Details and setup stepsTunnel IP, allowed addresses on the hub, last handshake, external endpoint, speed, public key, tag path and the setup steps.
Devices using this modemAdds / removes the project devices linked to the modem. A device linked to another modem does not appear in the list.
Change device addresses to the tunnel IPOnly on a "Modem only" site. Changes the address of the devices linked to the modem (Modbus <IP>.unit, S7, FINS…: in the device ID; BACnet: in the device IP field; DNP3, IEC 104: on the channel) to the modem's tunnel IP. A list of old → new is shown first; Apply saves it (device / channel edit permission is needed). It is also offered automatically when a device is linked to the modem.
Add a new device at this siteOpens the channel wizard in Connections and tells you what to enter as the device address.
Disable / EnableThe peer is temporarily removed from / put back on the hub. A reason is required (written to the audit log).
Revoke (delete)The peer is removed at once; packets with that key are silently dropped. It cannot be undone; adding it again generates a new key.

From the device: VPN modem

In Connections, the device's ••• menu › VPN modem: if the device is linked to a modem, the modem's name, status and tunnel IP, what to enter as the device address and the last handshake are shown (Unlink this device from the modem and Open in VPN page). If it is not linked, Add a modem for this device opens the wizard with the name and the device already filled in; or pick a modem with Link to an existing modem.

Status colours: Connected (last handshake < 3 min), Delayed (3–10 min), Lost (> 10 min), Waiting (never connected).

Monitoring: tags, alarms, audit log

The VPN status is read every 5 seconds and published as tags under _System.VPN: SCADA screens, data logging, alarms and OPC UA clients use them without extra code.

_System.VPN.Enabled1 = adapter up (UP).
_System.VPN.ConnectedPeersNumber of peers with a handshake in the last 3 minutes.
_System.VPN.Peers.<name>.Online1 = last handshake < 180 s.
….LastHandshakeLast handshake (text; the numeric value is Unix seconds).
….EndpointThe modem's external IP:port (to follow operator / line changes).
….RxBytes, ….TxBytesTotal traffic (bytes).
….RxRate, ….TxRateCurrent speed (kbit/s; to follow cellular quotas).

A dot in the site name becomes an underscore in the tag path (Well.7 → Well_7).

Alarms (defined automatically)

VPN service down (critical)_System.VPN.Enabled = 0 while the VPN is meant to be on (30 s). The definition is removed when the VPN is turned off on purpose.
Site VPN connection lost: <name> (high)On a site that has connected at least once, Online = 0 for 5 minutes. A site that never connected ("Waiting") raises no alarm. The definition is removed when the site is deleted.

Notification channels and priority can be changed by editing the definition on the Alarms page.

Audit log

All VPN operations are written to Settings › Audit log in the VPN category with an event code: vpn.interface.enable/disable/update, vpn.peer.create/update/disable/enable/revoke, vpn.config.issue/download/link_reuse, vpn.session.up/down, vpn.endpoint.change, vpn.apply.fail. Keys are referred to only by fingerprint (the first 8 characters of the public key); private keys, PSKs and download tokens are never written to any record.

Troubleshooting

Unavailable: wireguard.dll not foundThe installer puts the engine at C:\Program Files\MergenHub\wireguard.dll. If the file was deleted or quarantined by security software, run the installer of the same version again to repair the installation, then restart the service.
Modem stays "Waiting"Are the external address and port correct (handshake attempts in the modem's log)? Is the UDP port forwarded to the server on the organisation's firewall / modem? Is there a "MergenHub VPN" rule in the Windows Firewall (added automatically while the VPN is on; if another firewall product is used, open the port there)? Is the DNS "DNS only" on Cloudflare? Is the modem's clock right?
Download link says "HTTPS only"The link was opened from outside the local network over plain HTTP. Turn on HTTPS in Settings and open the link with https://; the link was not used up by this attempt.
Connected but the PLC cannot be readIn Routed mode the PLC's gateway must be the modem and forwarding from the tunnel to the LAN must be on in the modem (the script does this). In Modem only mode the PLC port must be forwarded on the modem.
Site keeps dropping (connects and disconnects)On cellular lines MTU 1380 is recommended; the 25 s keepalive must stay on.
LAN range conflictsMost sites use 192.168.1.0/24; the same range cannot be given to two sites. Mapped (1:1 NAT) mode comes in Phase 3; for now change the site's LAN or choose Modem only mode.