IMD SolutionComputing LibraryShop main store

How-to

Redirect TCP 502 to 8502 on a Linux edge controller firewall

Edge computing and IIoT Published 5 min read By IMD Solution engineering team

Short answer

groov EPIC and groov RIO firewalls accept rules for ports 1024 and above only, and an open port still needs an application listening on it. For a fixed-port Modbus TCP master, the device's internal rule redirects TCP 502 to TCP 8502; disable the built-in Modbus/TCP slave so your own server can own 8502.

On this page
  1. Why ports below 1024 are refused
  2. An open port is not a listener
  3. Read the effective rules from the shell
  4. Serve a fixed-port Modbus TCP master
  5. Worked example: bridge a fixed-port master to a fixed-port device
  6. Verify the whole chain
  7. Safety note
  8. Questions asked

An open port is permission, not a service. On groov EPIC and groov RIO the firewall accepts rules for ports 1024 and above, and a fixed-port Modbus TCP master that can only use TCP 502 is served by an internal redirect from TCP 502 to TCP 8502. This article shows how to verify the rules, free port 8502 from the built-in Modbus/TCP slave, and put your own server behind the redirect.

Why ports below 1024 are refused #

Both devices run Linux. Ports below 1024 are privileged ports that the kernel reserves for services running as root, and the management interface's user does not have root. That is why the firewall configuration refuses to open them, and a shell session should not be used to work around the restriction.

The consequence for Modbus TCP, whose well-known port is 502, is that no ordinary application can listen there directly. The device solves this with a documented internal rule that redirects incoming TCP 502 traffic to TCP 8502, which is above the privileged range.

An open port is not a listener #

Opening a port only permits matching packets through the firewall. It does not create a TCP or UDP listener. If you open TCP 2233 for a Node-RED application, nothing responds until the flow contains nodes that bind to port 2233, parse the incoming traffic and answer when the protocol requires a reply.

Conversely, outbound connections need no inbound rule at all. A device that pushes data, for example over MQTT, needs no firewall opening; the rule matters only for the poll-response model, where an external client connects in.

Read the effective rules from the shell #

The firewall is UFW (Uncomplicated Firewall), a command-line front end for iptables rules. To see the effective rules for a port, list the raw rules and filter for the port number. This needs sudo because it reads firewall configuration:

sudo ufw show raw | grep 22001

A documented result for the PAC Control engine looks like this, one line per rule:

ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpts:22001:22002
DROP tcp -- eth1 * 0.0.0.0/0 0.0.0.0/0 tcp dpts:22001:22002
ACCEPT tcp -- tun0 * 0.0.0.0/0 0.0.0.0/0 tcp dpts:22001:22002

Read each line as action, protocol, interface, source, destination and port range. In this example the engine accepts TCP on eth0 and tun0 and drops it on eth1, so a client on the wrong interface is blocked even though the port is nominally open. A TCP rule does not authorize UDP; a UDP rule appears as its own line.

Check the Modbus path the same way:

sudo ufw show raw | grep 8502

The documented output accepts TCP 8502 on the permitted interfaces and contains the redirect entry that sends incoming TCP 502 traffic to 8502. This raw listing is the verification source for both the interface policy and the redirect; trust it over any single summary screen. One vendor statement refers to a firewall rule on port 8052 where the raw rules and every listener instruction say 8502; treat that as an inconsistency and confirm against the raw rules before changing anything.

Serve a fixed-port Modbus TCP master #

Out of the box, the built-in Modbus/TCP slave answers polls on TCP 502 through the redirect to 8502 and returns register data. To use PAC Control, CODESYS or Node-RED as the Modbus server instead, only one process can own 8502, so release it first:

  1. In the management interface, open the I/O services configuration and turn off the built-in Modbus/TCP slave so it stops listening on 8502.
  2. Configure your replacement server to listen on TCP 8502.
  3. Re-run the raw-rules check for 8502 and confirm the redirect from 502 is still present.
  4. Poll port 502 from the master and verify that your server receives the request and returns register data.

Worked example: bridge a fixed-port master to a fixed-port device #

Suppose a Modbus TCP master on the IT-side network is hardcoded to port 502, and the real device on the OT-side network also only serves port 502. An EPIC with its two Ethernet interfaces can bridge the two, using the redirect plus a Node-RED flow; this depends on the two-interface hardware and does not apply to RIO, which has a single Ethernet side in this design.

The flow has three parts. A tcp in node listens on port 8502 in stream mode and treats the payload as a buffer, because the redirect delivers the master's request there. A tcp request node connects to the device address, for example 192.168.2.10, on port 502 through the OT-side interface. A tcp out node in reply mode returns the device's response over the master's open connection. Place the device on the same subnet as the OT-side interface configuration, change the destination address in the request node to the actual device IP, deploy, and poll end to end.

Verify the whole chain #

A green firewall rule alone proves nothing. Confirm each link: the intended interface shows ACCEPT for the right protocol and IP family, the redirect from 502 to 8502 is present, exactly one application owns the listening port, and a real client transaction returns valid data. If live values reach your server but never leave it, the causes described in article:why-mqtt-to-runs-without-errors-but-publishes-nothing are the next place to look. If your edge application polls other devices and CPU load is the problem, the polling design in article:polling-100-modbus-tcp-slave-ids-from-node-red-without-100-cpu applies. When the network interfaces themselves are confusing, the port roles on groov RIO's eth0 and eth1 are covered in https://industrialmonitordirect.com/blogs/knowledgebase/groov-rio-poe-on-eth0-vs-eth1-resolving-port-confusion.

Safety note #

Do not run shell workarounds to bind privileged ports or edit firewall rules outside the supported configuration. An undocumented change to a controller that runs a live process can drop the traffic your process depends on.

Questions asked

Why does the firewall refuse to open ports below 1024?

groov EPIC and groov RIO run Linux, and the management interface runs without root privileges. Linux reserves ports below 1024 for privileged services, so rules for those ports are refused. Use a port at 1024 or above, or rely on the built-in redirect from TCP 502 to TCP 8502 for Modbus TCP traffic.

How do I check that a port is really open in the firewall?

From a shell, run a UFW raw-rules listing filtered for the port number, for example piping the raw output through a text filter for 8502. The result shows the action, protocol, interface and IP family for each rule, so you can confirm which interfaces accept the traffic and which drop it.

Can my own application answer Modbus TCP polls on port 502?

Yes, indirectly. The internal firewall rule redirects incoming TCP 502 traffic to TCP 8502. Disable the built-in Modbus/TCP slave so it releases 8502, then configure PAC Control, CODESYS or Node-RED to listen on 8502. A master polling 502 reaches your application through the redirect.

Keep reading

  • Selection guide

    Choosing an on-premises edge device update platform

    Make offline intent storage mandatory: the platform must hold a deployment for a device that is offline or has never connected and apply it on reconnection. Then choose by update scope - a container platform such as the open-source Balena stack for application services, an image or partition updater such as Mender or SWUpdate when the kernel or base OS changes - and prove the choice with a disconnect-reconnect test.

    Edge computing and IIoT

  • Explainer

    Why Industrial Edge Management VM console says login incorrect

    The 'login incorrect' message at an Industrial Edge Management VM console is expected: the appliance OS is closed to users, so no credential will ever work there. Once the instance is activated and Online in the Hub, administer it through the Maintenance UI at its base HTTPS address and the Management App UI at the same address on port 9443, signing in with the credentials defined during activation.

    Edge computing and IIoT

  • How-to

    Configuring MQTT TLS certificates in Node-RED on an edge PC

    Configure the MQTT node's own TLS inputs: the broker's CA chain always, the client certificate and private key when the broker requires mutual TLS. A platform certificate store is invisible to Node-RED until the installed integration exposes it, so use persistent files unless store support is verified, and renew in a staged 30-day window.

    Edge computing and IIoT