Explainer
How a VPN gateway on a controller routes you to the machine LAN
Short answer
A VPN client on the machine-side gateway becomes a router to the machine LAN only when IP forwarding is enabled on both the tunnel and LAN interfaces, the server advertises the machine subnet and binds it to that client with iroute, and replies find a way back through the device gateway or an SNAT rule on the gateway. A worked packet example shows both directions.
On this page
- Can a VPN client on the gateway reach the devices behind it?
- What must the OpenVPN server know about the machine subnet?
- Does a self-managed or a hosted OpenVPN server fit the machine build?
- Why does the tunnel connect while the device stays unreachable?
- Should the device get a gateway, or should the gateway SNAT?
- How do you reach many machines that all use the same subnet?
- What happens to the packet on the way in and back out?
- Questions asked
A VPN client on the machine-side gateway only routes you to other devices when four things line up: IP forwarding enabled on both the tunnel and LAN interfaces, the machine subnet advertised to the remote PC, that subnet bound to the gateway client in the server's client-config file, and a return path — either the device's gateway points at the controller or an SNAT rule rewrites the source. The worked example runs on a ctrlX CORE at release 21.11 with the Firewall and VPN apps at version 1.12.0, the LAN interface eth0 at 192.168.1.1, and a machine controller at 192.168.1.25 on the same subnet. Treat it as a proof of concept: adapt the addresses and validate it on the real machine network before production use.
Can a VPN client on the gateway reach the devices behind it? #
Yes, once the gateway acts as a router between its tunnel and its LAN port: the remote PC sends packets for the machine subnet into the VPN, the server hands them to the gateway client, and the gateway relays them onto the machine network. The packet path has three segments: the remote PC's connection to the VPN server, the tunnel from the server to the gateway client, and the gateway's own machine LAN.
Before touching routes, confirm the two local facts everything else rests on: the gateway and the target device sit on the same machine subnet, directly or through a switch, and the gateway has internet access so its VPN client can establish the tunnel at all. Record the real subnet and addresses before configuring anything, because every later step repeats them. The same end goal — reaching a machine's web page or programming tool from outside the plant — is what remote access through firewalls and proxies covers when the obstacle is a corporate firewall or proxy instead of the route.
What must the OpenVPN server know about the machine subnet? #
Three additions: a route so the server itself routes for the subnet, a pushed copy so every connecting client sends that subnet toward the VPN, and a client-config file that binds the subnet to the gateway client with iroute. On a self-managed server, the additions to the main configuration are:
client-to-client
route 192.168.1.0 255.255.255.0
push "route 192.168.1.0 255.255.255.0"
client-config-dir /etc/openvpn/ccd
client-to-client lets the server pass traffic between two connected clients, which is exactly what the remote PC and the gateway are. The route line tells the server it must be able to route for that subnet; without it, traffic for the machine LAN would follow the server's default gateway. The push line hands the same route to every client that connects, so a remote PC sends machine-subnet packets toward the VPN instead of its own LAN. client-config-dir names a folder holding one file per client, each file named after that client's certificate identity.
In the gateway client's file, two lines do the binding. An ifconfig-push line assigns the gateway its fixed tunnel address, 10.8.0.35 in the example, and iroute 192.168.1.0 255.255.255.0 declares this client as the server's route to the machine subnet. With the classic net30 topology, the two addresses in ifconfig-push must come from successive /30 subnets to stay compatible with the server's address pool; with topology subnet, a single address and netmask apply. Reboot the server to apply the changes. One security point sits here rather than at the end: the pushed route reaches every client that connects, so issue client certificates only to people who should see the machine network.
Does a self-managed or a hosted OpenVPN server fit the machine build? #
Pick one and do not mix them: run your own server when you manage certificates and configuration files, and use a hosted service's admin portal when you want a wizard-created network with a downloadable router profile instead. On the hosted path, sign in to the service URL chosen at account creation and open the Admin Portal.
Under Networks, the wizard's steps are: choose Remote Access, name the network and the connector (the gateway), select the location closest to the machine, enter the subnet or subnets reachable behind the gateway — both controller ports can be listed — and pick OpenVPN Compatible Router as the deployment target. Then download the OVPN profile for upload to the controller. The wizard's documented example uses 192.168.0.0/24 while the worked machine LAN here is 192.168.1.x, so enter the real subnet and keep one consistent value across the server, the client routes and the controller's firewall. If the remote endpoint is an industrial router rather than a software client, the VPN selection itself is covered in choosing a firewall VPN for an industrial remote access router.
Why does the tunnel connect while the device stays unreachable? #
Because the tunnel and the forwarding are two separate switches: a connected VPN app only proves the gateway reached the server, while packets still need IP forwarding enabled on both eth0 and tun0 and a firewall forward filter that lets them through. On the gateway, upload the .ovpn profile in the VPN app and enable Connect automatically when the machine must rejoin the VPN after every boot; on release 21.11 the page's location and layout vary with the system and app version.
Then enable IP forwarding for both interfaces — forwarding on the tunnel alone moves packets no further than the gateway itself. In the Firewall app, confirm packet forwarding between the interfaces is allowed: the example build allowed it by default, but inspect the actual configuration rather than trusting a default. Forwarding carries packets between interfaces; the forward filter can still drop them. So the diagnostic order for a connected tunnel with an unreachable device is: forwarding on both interfaces, then forward-filter rules, and only then the server's route and iroute.
Should the device get a gateway, or should the gateway SNAT? #
Set the device's gateway to the controller's machine-side address, 192.168.1.1 in the example, when you can touch the device's network settings; otherwise add an SNAT rule on the controller so the device sees the controller itself as the packet source. With no gateway configured on the device, its reply to a tunnel address has no route back to the PC, and the connection is dropped at the device. Setting the gateway is the direct fix and needs no extra rule.
SNAT is the alternative when machine devices must not be touched. The rule, placed in the Firewall app's NAT settings, rewrites the source of VPN-to-machine traffic to the controller's own LAN address, so the device answers locally and the controller's connection tracking translates the reply back to the VPN client. Select the VPN source and the machine-side destination or interface in the actual UI rather than copying an unverified rule, and restart the controller once the changes are in. When the VPN client is a virtual machine rather than a controller, the same reasoning appears in running a remote access VPN from your VM with NAT mode.
How do you reach many machines that all use the same subnet? #
Give every machine its own translated subnet on the VPN side and rewrite destinations on each machine's controller with DNAT; otherwise every machine needs a distinct real subnet, or its own VPN server, before one tunnel can reach them all. There are exactly those three ways, and the distinct-subnet route also changes how the machines talk to each other, which resolving PLC communication across 192.168.1.x and 192.168.2.x subnets covers.
For DNAT, create a second client certificate and replicate the server additions with a translated subnet, 192.168.5.0 in the example, in place of the machine subnet — including a different fixed tunnel address in the new client-config file — then reboot the server and reconnect everything. On the controller, add one DNAT rule per reachable device, translating the 192.168.5.x destination to the matching 192.168.1.x address, keep the Forward Filter clear of blocking rules, and leave the SNAT rule from the single-machine case in place.
What happens to the packet on the way in and back out? #
Each pass rewrites two fields in order: DNAT changes the destination to the device's real address before forwarding, SNAT changes the source to the controller's LAN address on the way out, and the controller reverses both on the reply. Worked example, multi-machine case: the remote PC points a browser at the translated address 192.168.5.25. The mask 255.255.255.0 is a /24: 2^8 = 256 addresses, of which 256 − 2 = 254 are usable once the network and broadcast addresses are set aside — so a fully reachable subnet needs at most 254 DNAT rules, one per device. DNAT keeps the host part and rewrites the network part: destination 192.168.5.25 becomes 192.168.1.25, third octet 5 replaced by 1, host octet 25 kept. SNAT then replaces the source with the controller's LAN address, 192.168.1.1, so the device replies locally and the controller reverses both translations on the return packet.
| Stage | Source field | Destination field |
|---|---|---|
| PC sends into the tunnel | the PC's tunnel address | the translated device address |
| Server delivers to the gateway client by iroute | unchanged | unchanged |
| DNAT on the controller | unchanged | the device's real address |
| SNAT onto the machine LAN | the controller's LAN address | the device's real address |
| Device replies on the LAN | the device's real address | the controller's LAN address |
| Controller reverses both translations | the translated device address | the PC's tunnel address |
The decisions, case by case: one machine with editable device settings — set the device gateway; one machine with locked devices — SNAT on the controller; many machines sharing one subnet — a translated subnet and DNAT per machine, with the SNAT rule kept; tunnel up but nothing reachable — check forwarding on both interfaces before blaming the server. Those four rules cover the whole path from certificate to device.
Questions asked
Does the remote PC need its own client certificate?
Yes. Create one certificate for the gateway and a separate one for each remote PC. The client-config file is named after the certificate identity, so a shared identity would bind the machine subnet to the wrong client and break the iroute design.
Why must every VPN client have a different tunnel address?
The server identifies clients by their tunnel address. Two clients configured with the same ifconfig-push address make return traffic ambiguous, and the second connection displaces the first. Give each machine's gateway a unique fixed address across all client-config files.
How many connections does the hosted service's free account allow?
The free hosted account used in the example allows up to three VPN connections, enough for one machine gateway and two remote PCs. A fleet with more gateways needs a paid tier or the self-managed server path.
What proves the path works end to end?
From the connected remote PC, load the device's web page by its address, then open the programming tool and go online with the controller. A successful ping proves only that ICMP returns; the web page and an online programming session prove application traffic in both directions.
Does client-to-client matter when only one PC uses the tunnel?
It does. The remote PC and the machine gateway are two clients of the same server, and client-to-client lets the server pass traffic between them internally. Without it, traffic between clients depends on kernel routing that the iroute configuration does not use.