Modbus/TCP Proxy for dynamic public IP addresses?

ryangriggs

Lifetime Supporting Member
Join Date
Jun 2016
Location
USA
Posts
198
Hello, does anyone know of some Linux-based software that provides a Modbus/TCP proxy?


Here's the backstory:

I am attempting to set up failover for a telemetry system. All remote units are connecting to a central PLC where they 1) read updated settings and 2) write process values. All Modbus/TCP requests originate from the remote units (the central PLC never attempts to read from or write to the remotes).



The central PLC is connected to two internet providers via two Ethernet cards. While the primary connection has a static IP address, the secondary internet connection does not, and this feature is not available from that service provider.


The remote PLCs are programmed to first try the primary connection's IP address, and if an error is generated, they retry with the secondary IP address.


The problem is that every time the public IP address of the failover connection changes, we have to modify the code on all the remote PLCs, since they don't support the use of hostnames. (They are AutomationDirect CLICK units.)



I can easily and cheaply spin up a Linux-based cloud server with a static IP address, so all I really need is a Modbus/TCP proxy software that will accept Modbus connections and pass them on to an IP address we specify. Then I can run a dynamic update utility on the local network and keep the public IP address updated on the proxy server, ensuring the failover connection is always available.





I may be able to accomplish this with Squid, but haven't had time to read the full docs yet.


Thanks for any ideas!
 
Last edited:
SOLVED! Just wanted to show how it's done easily:


1. Set up a linux-based cloud server with static IPv4 address (i.e. DigitalOcean, linode, etc).


2. Install HAProxy (www.haproxy.org, most distros have a package)



3. Create a configuration file with the following parameters:


global
daemon

maxconn 256

defaults
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms

listen modbus :502
mode tcp
server failover xx.xx.xx.xx:502 check



(where xx.xx.xx.xx is your destination Mobdus/TCP server or dynamic DNS hostname)



Start haproxy with the -f option and specify your config filename.


Voila, it runs as a daemon and listens for incoming connections on port 502, forwarding them to the destination.


You can also get fancy and do internal round-robin etc (see HAProxy docs) if you want to list multiple servers.





Thanks to HBrujin for pointing me in the right direction.

HAProxy docs: https://cbonte.github.io/haproxy-dconv/
Thanks to https://www.linickx.com/load-balance-anything-with-haproxy
 

Similar Topics

Hello gentlemen, Im working on a small project on TIA Portal, about establishing a Modbus TCP connection between my ET200SP plc and a socomec...
Replies
11
Views
242
If a device has Modbus RTU over serial and Modbus RTO over TCP and Modbus TCP then there is a difference between Modbus RTU over TCP vs Modbus TCP...
Replies
7
Views
438
Hi There. I have PC to get few tags from PLC into C# windows forms application. What is the best and fastest way? I could not find Omron in...
Replies
3
Views
232
I contacted Hach and bought a kit they recommended for a customer to add Modbus TCP capability to his Chlorine Analyzer with a SC4500 controller...
Replies
8
Views
214
I’m trying to read values from a device that can either send registers as 32 bit or a pair of 16 bit but if I understand right, the micro can only...
Replies
26
Views
792
Back
Top Bottom