Skip to content
English
  • There are no suggestions because the search field is empty.

Setting Up Port Forwarding for Modbus-TCP via OpenVPN

Make a Modbus-TCP device in the plant network reachable through the OpenVPN connection by forwarding a port on the Amperecloud Log router.

 

If you want to read or control a Modbus-TCP device in the plant network (for example an inverter or a power meter) remotely, you can reach it through the existing OpenVPN connection to the router supplied with the Amperecloud Log. To do this, set up a port forwarding on the router (Teltonika, RutOS) that forwards a port from the OpenVPN zone to the device in the local network (LAN).

Before you start

  • You can log in to the router's web interface. You will find the password on your setup sheet.
  • You have an active OpenVPN connection to the router.
  • You know the IP address of the Modbus device in the LAN and its Modbus-TCP port (default: 502).

Step 1: Allow forwarding from the OpenVPN zone to the LAN

  1. Log in to the router's web interface.
  2. Go to Network → Firewall → General Settings and scroll down to Zones.
  3. Click Edit next to the zone openvpn.
  4. Under Allow forward to destination zones, add lan (and wan if required). Input, Output and Forward stay at Accept.
  5. Click Save & Apply.

The zone table now shows the row openvpn ⇒ lan, wan:

Step 2: Create the port forwarding rule

  1. Go to Network → Firewall → Port Forwards and add a new rule.
  2. Enter the following values:
Field Value Example
Name Any name Modbus WR
Protocol TCP (Modbus-TCP needs TCP only) TCP
Source zone openvpn openvpn
External port Usually 502 or 502 + Modbus ID (see Notes) 5023
Internal zone lan lan
Internal IP IP address of the Modbus device 192.168.1.128
Internal port Modbus-TCP port of the device 502
Make sure the rule is switched on and click Save & Apply.

The finished rule looks like this:

 

Step 3: Test the connection

  1. Connect to the OpenVPN.
  2. In your Modbus client (for example modpoll or QModMaster), enter the router's IP address in the VPN and the external port (in the example 5023).
  3. The router forwards the requests to the device (in the example 192.168.1.128:502).

Notes

  • The external port is typically 502 as well. With several devices it makes sense to append the Modbus ID to 502 (for example 5023 for a device with Modbus ID 3). This makes the connections easy to tell apart and gives each device its own external port.
  • The Modbus device must use the router as its default gateway. Otherwise its replies do not find their way back into the VPN.
  • Many devices accept only a limited number of simultaneous Modbus-TCP connections. Make sure your access does not disturb the regular data collection by the Amperecloud Log.

Need More Help?

If you need further assistance, email our support team at support@amperecloud.com and describe your issue in as much detail as possible.