This project provides a Modbus TCP Proxy service that enables the management of Modbus communication over TCP. It supports dynamic configuration, robust logging, and is compatible with Debian 12 and Ubuntu 24. The setup is fully managed using a Makefile, which simplifies building, installing, running, updating, and packaging.
- Supports Modbus-TCP communication
- Dynamic YAML-based configuration
- Persistent connection to the Modbus server
- Automatic reconnection and robust error handling
- Systemd service integration
- Flexible logging (console and file)
- Easy install/update via
make - Package support:
.deband Docker
- Operating System: Debian 12 or Ubuntu 24
- Python: 3.7 or newer
All project operations are handled through a Makefile.
make install # First-time setup
make update # Pull latest version + update dependencies
make restart # Restart the systemd service
make logs # Show live logs
make backup-config # Backup the config file
make uninstall # Remove everything except configCreate your configuration at:
/etc/Modbus-Tcp-Proxy/config.yamlProxy:
ServerHost: "0.0.0.0"
ServerPort: 502
ModbusServer:
ModbusServerHost: "192.168.1.100"
ModbusServerPort: 502
ConnectionTimeout: 10
DelayAfterConnection: 0.5
Logging:
Enable: true
LogFile: "/var/log/modbus_proxy.log"
LogLevel: "INFO"
Server:
MaxQueueSize: 100
MaxWorkers: 8- Proxy: Listen address and port for incoming clients
- ModbusServer: Target Modbus server connection parameters
- Logging: Logging control and log level
- Server: Thread pool and request queue configuration
The make install command sets up a systemd service named modbus_proxy.service. You can manage it using:
sudo systemctl start modbus_proxy.service
sudo systemctl stop modbus_proxy.service
sudo systemctl restart modbus_proxy.service
sudo systemctl enable modbus_proxy.service
sudo systemctl status modbus_proxy.servicesudo tail -f /var/log/modbus_proxy.logA Dockerfile is provided to run the proxy in a container.
docker build -t modbus-proxy .docker run -d \
--name modbus-proxy \
-p 502:502 \
-v /your/config/path/config.yaml:/etc/Modbus-Tcp-Proxy/config.yaml \
modbus-proxyThis project includes support for packaging into a .deb file.
debian/
βββ DEBIAN/control
βββ opt/Modbus-Tcp-Proxy/...
βββ etc/Modbus-Tcp-Proxy/config.yaml
dpkg-deb --build debian build/modbus-tcp-proxy.debsudo dpkg -i build/modbus-tcp-proxy.deb- The proxy uses a persistent socket to the Modbus server and handles multiple client connections.
- Automatic reconnection ensures high availability.
- Thread-safe queue and thread pool handle incoming requests efficiently.
pymodbusβ Modbus TCP communicationPyYAMLβ YAML config loadercerberusβ Configuration schema validation- Built-in:
logging,queue,socket,threading
Install manually with:
pip install -r requirements.txtIf you'd like to support this integration or show your appreciation, you can:
MIT License β see LICENSE file.
For questions or issues, open a GitHub Issue.
