Troubleshooting
Why CODESYS tag integration fails across NAT to an M241
Short answer
Different IP ranges do not stop CODESYS tag integration. It reaches the M241 runtime through the CODESYS gateway service on TCP 1217, and working Modbus TCP and SoMachine sessions prove nothing about that service or its return path. Permit that one service from the SCADA host to the translated PLC address, then verify with a tag browse.
On this page
- Why does CODESYS tag integration fail when Modbus TCP works?
- Do different IP ranges across a NAT stop tag integration?
- What does a working SoMachine connection prove?
- Which port must the NAT rule carry for tag integration?
- What is the Runtime Address in the tag integration tool?
- How do you fix and verify tag integration across the NAT?
- What if tags still fail after the gateway port is open?
- Questions asked
Your two IP ranges are not the problem. CODESYS tag integration fails across the NAT because it does not travel on the service you already proved: Modbus TCP rides TCP 502, while the tag integration connects to the gateway service embedded in the M241 runtime, on TCP 1217. A working Modbus TCP read and a working SoMachine connection each prove their own path only; neither one exercises the gateway port or its return path through the translation. Permit that one service from the Machine SCADA Expert host to the translated PLC address, then prove the fix with a tag browse whose values move when the PLC values move.
Why does CODESYS tag integration fail when Modbus TCP works? #
Because the two connections are different services: your Modbus TCP reads ride TCP 502, while CODESYS tag integration opens its own session to the gateway service embedded in the M241 runtime, on TCP 1217 — a port and a session your Modbus test never touched.
Machine Expert, the tool the M241 is programmed in, is built on CODESYS, and a CODESYS runtime carries an embedded gateway service for exactly this kind of session: engineering tools and compatible clients connect to that service, which answers on its documented default port unless someone reconfigured it. Schneider documents the Tag Integration tool as the way to attach every variable from a Machine Expert project to a Machine SCADA Expert project, and attaching means opening that gateway session to the runtime.
The reads you already get in Machine SCADA Expert come from its Modbus TCP driver — a separate session, a separate port, and its own addressing quirks, covered in fixing Machine SCADA Expert Modbus TCP reads to a TM221. Hand-building the register map that driver reads is the chore tag integration removes; the upkeep involved is the subject of Modbus TCP tag maps and PLC-triggered logging for SCADA. Both of those live on the Modbus flow. The tag tool does not.
Do different IP ranges across a NAT stop tag integration? #
No. NAT exists to join different ranges: the PLC side at 192.168.16.x and the SCADA side at 192.168.41.x can talk if the translation and the routes carry the specific service. The ranges fail nothing; the unproven gateway session fails.
Routing between different ranges is a NAT's normal job, so the addressing eliminates nothing. Three things have to be true instead:
- a route from the SCADA host to the boundary device, and from the boundary device to the M241;
- a translation entry that maps an address the SCADA host can reach to the M241 and to the specific service the tag tool opens;
- a return path the M241 can actually use, so its reply reaches the boundary and is un-translated back to the host.
"Full open" between the networks is a claim about intent; the entries on the boundary device are the fact, and reading them is the first diagnostic step. If the tag session instead cycles between connecting and disconnected, suspect addresses and routes at the boundary before the application — that symptom is the same class of fault as the subnet fix for a SCADA gateway cycling Connecting and Disconnected.
What does a working SoMachine connection prove? #
Only its own session: SoMachine proves the path it used, from the PC it runs on, and the answer depends on where that PC sits. The sessions you already have working split exactly as the table below shows.
| Session that works | What it proves | What it does not prove |
|---|---|---|
| SoMachine connects | The path SoMachine used, from the PC it runs on, reaches the runtime | The SCADA host's route, the translation, or the gateway service itself |
| Modbus TCP reads | The boundary carries the Modbus flow and its return path | Any session to the gateway service |
| "Full open" between the networks | The policy intent at the boundary | That each service is actually mapped and translated |
If the SoMachine PC sits on the PLC-side 192.168.16.x network, none of its traffic crossed the NAT, so it tests nothing you need proven. If it sits on the SCADA side, its success proves the gateway service crosses the boundary, and the remaining fault lives in the tag tool's configuration, not the network. One question — where does the engineering PC sit — splits the case before any rule changes.
Which port must the NAT rule carry for tag integration? #
One mapping carries it: the gateway service, TCP 1217, from the SCADA host to the translated M241 address, with the session's own return traffic. Keep the Modbus TCP 502 mapping as it is — the two services are independent, and one proven mapping has never carried the other.
The gateway is an engineering service with deep access to the controller, so pinning the source address is part of the fix, not polish.
Worked example — the addresses are examples, so put yours in their places:
- SCADA host: 192.168.41.20
- M241 on the PLC side: 192.168.16.27
- NAT outside address mapped to the M241: 10.10.4.31
- Flows the machine needs: Modbus TCP on TCP 502, already proven, and the gateway service on TCP 1217, not yet proven
- From 192.168.41.20, open a TCP connection to 10.10.4.31 on the Modbus port. It succeeds, so the boundary maps that flow.
- From 192.168.41.20, open a TCP connection to 10.10.4.31 on the gateway port. It times out. Count the mappings on the boundary: one exists, two flows are needed, and the missing one is your whole fault.
- Add exactly that mapping: outside 10.10.4.31 plus the gateway port, translated to 192.168.16.27 on the same port, source pinned to 192.168.41.20, replies carried by the stateful entry the session itself creates.
- Run both tests again from the SCADA host. Both succeed, and the count is right.
What is the Runtime Address in the tag integration tool? #
It is the runtime endpoint the integration connects to. Schneider's description of the Tag Integration tool says it attaches the variables from a Machine Expert project to a Machine SCADA Expert project; the Runtime Address is where that attachment connects — the NAT-translated M241 address, never a Modbus register map.
The field needs an endpoint this particular host can open a session to. With the M241 behind the NAT, that is the outside address of the mapping, not the raw 192.168.16.x PLC address, unless routing makes the PLC side directly reachable from the SCADA host. Reachability belongs to a host and a path, never to an address alone: the same value works from the SoMachine PC because that PC has a route the SCADA host lacks. The tool's session is the gateway service, so the field takes an address, not a register convention.
How do you fix and verify tag integration across the NAT? #
Add one narrowly scoped rule and prove it with moving values: permit the gateway service from the SCADA host to the translated M241 address, then browse a few tags and confirm each changes when the PLC forces it — anything broader than that address pair and service is excess.
- Read the boundary device's actual NAT and firewall entries and write down which services the existing mapping carries; treat the "full open" summary as a claim until this shows it.
- Add the single mapping for the gateway service from the SCADA host to the M241, source pinned to that host, return traffic left to the stateful session.
- Retry tag integration in Machine SCADA Expert with the Runtime Address set to the translated address, and watch the boundary log show one flow to the gateway port and its return.
- Browse a handful of known tags — for example a running bit and a counter value — force each from Machine Expert, and confirm the Machine SCADA Expert value follows within one poll.
- Leave the policy as narrow as the fault: keep the Modbus mapping for the reads you keep, keep the new mapping for tag integration, and retire any broader permit those two named flows make unnecessary.
The browse with moving values is the only end-to-end proof; everything before it is preparation, and everything after it is keeping the policy as tight as it tested.
What if tags still fail after the gateway port is open? #
Then the transport is proven and the fault sits in the integration itself: check the device selection the tool expects against the M241 target, the Machine Expert project's symbol support, and the tool's diagnostics — a session that connects but returns no variables is a configuration answer, not a network one.
- No session at all: the endpoint or the translation is still wrong — rerun the two connection tests from the SCADA host and read the boundary log for that attempt.
- A session that connects but returns no variables: confirm the Machine Expert project exposes its variables to the tool, that the tool's device selection matches the M241 target, and what the tool's diagnostics report; Schneider's FAQ on the Tag Integration tool is the reference for that field-level requirement.
- Values that appear but never change: polling or subscription state in the Machine SCADA Expert diagnostics, not the network.
The network has passed its test at this point, so widening the NAT rule now would only hide the real fault.
Questions asked
Can a PLC and SCADA on different subnets communicate through a NAT?
Yes. A NAT exists to join different ranges, and your Modbus TCP traffic already crosses the same boundary between them. The failure is narrower than the ranges: the CODESYS gateway service on TCP 1217 had no proven path through the translation, so the fix is the missing service mapping, not new addressing.
How do I test the gateway port from the SCADA host before touching any rules?
Run a TCP port check from the SCADA host to the translated M241 address, once against the Modbus port and once against the gateway port. Before the rule change the first should succeed and the second should time out; after it, both should succeed. The test takes seconds and proves the mapping instead of assuming it.
Does opening the gateway port expose the PLC to the plant network?
It can, if the rule is broad. Pin the mapping to one source address, the SCADA host, and one service, the gateway port, so nothing else crosses. The runtime gateway is an engineering service with deep access to the controller, so a wide permit between the networks is what creates exposure; the pinned pair keeps the path small.
Can I keep using Modbus TCP reads alongside tag integration?
Yes, and you probably should for anything that only reads a few registers. The two run as independent sessions on separate ports, so one mapping never replaces the other. Keep the Modbus mapping for the reads that stay, add the gateway mapping for tag integration, and hand-built register maps become optional rather than mandatory.