Comparison
Can a Modbus TCP server answer on multiple IP addresses
Short answer
No. A Modbus TCP server instance replies from the one IP assigned to the interface the client dialed, and a controller cannot put two interfaces in the same subnet. Serve both register ranges from one address with a flat register map, add server instances on separate TCP ports for extra simultaneous clients, or mount a second interface only in its own different subnet.
On this page
- Can one Modbus TCP server answer from two IP addresses?
- Why does the reply always carry the address the client dialed?
- Do a controller's two Ethernet ports provide two addresses?
- Can two interfaces share one subnet to give both addresses?
- Which setups actually deliver a second Modbus TCP reply address?
- How many clients can one Modbus TCP server instance take?
- Which setup should you choose for the two-address requirement?
- Questions asked
No — one Modbus TCP server instance answers under exactly one IP address: the address the client dialed. TCP builds the whole conversation between one client address and one server address, so a reply cannot carry a different source. A controller also cannot put two interfaces in the same subnet, which rules out holding 192.168.1.1 and 192.168.1.18 on one machine. What you can build instead is one address with both register ranges in a flat map, extra server instances on separate TCP ports for extra clients, or a second interface in its own subnet. The sections below give the TCP rule, the subnet arithmetic, and the decision for each case.
Can one Modbus TCP server answer from two IP addresses? #
No. A Modbus TCP server instance replies from the single IP assigned to the interface the client dialed, and nothing in TCP lets one interface answer under a second address. Two reply addresses need a second independent interface on the controller or separate hardware.
Split the requirement into its two halves. Where the register data lives is decided by the server function block instance: the map of holding registers belongs to that instance, and the starting address in each Modbus request selects which part of the map you get. Where the reply address comes from is decided by the interface and its subnet, and that is the half your requirement cannot get around. Serving 6 registers under one address and 11 under another does not need two addresses at all; it needs one map that holds both.
Why does the reply always carry the address the client dialed? #
Because the Modbus exchange is a TCP session, and every frame of it must match the address pair that opened the session. The client dials a destination address and port — port 502 is the registered Modbus TCP default — and the controller's TCP stack accepts the session on the interface that owns that address.
The source of every response frame is then fixed by the session itself, not by any server setting: the frames belong to the same connection, so they carry the dialed address as their source. A TCP endpoint cannot change its address mid-connection, and packets arriving from any other address fail the connection check and get dropped. The practical consequence for you: the reply address is an interface-and-subnet decision, never a parameter in the server function block.
Do a controller's two Ethernet ports provide two addresses? #
Usually not. Many CPUs wire their two RJ45 sockets as a built-in switch behind one TCP stack, so both sockets share the single IP configured for the controller and cannot host a second Modbus TCP address.
Check your controller's hardware manual for the distinction that matters: whether the sockets are described as a switched port pair with one assigned address, or as independent interfaces with their own network settings. A genuinely independent second interface — often added as a slot-in Ethernet extension module — carries its own IP and answers its own clients, and it is the only way to get a second reply address on the controller itself. For the settings side of that second network, the walkthrough on configuring a controller port for a second Modbus TCP network shows the port configuration end to end.
Can two interfaces share one subnet to give both addresses? #
No, and the arithmetic decides it. With subnet mask 255.255.255.0, both required addresses reduce to network 192.168.1.0, so a second interface would add a second connected route to a network the first interface already owns — a conflict no controller stack accepts.
Worked example, taking the two required addresses and a /24 mask:
- 192.168.1.1 AND 255.255.255.0 = 192.168.1.0
- 192.168.1.18 AND 255.255.255.0 = 192.168.1.0
Both addresses land in the same network, so one interface can hold at most one of them and no second interface can hold the other. The extension route opens up the moment the second client's network can be re-addressed: put the second interface at, for example, 192.168.2.10 — 192.168.2.10 AND 255.255.255.0 = 192.168.2.0, a different network — and both interfaces route cleanly, each replying from its own address.
Which setups actually deliver a second Modbus TCP reply address? #
Four builds exist, and only one of them puts a second reply address on the same controller: an independent second interface in its own subnet. The table compares what each needs, whether it changes the source address, and where each one stops.
| Setup | What it needs | Second source address? | Hard limit |
|---|---|---|---|
| A: one address, flat register map | One server instance whose map covers the full span, with data at both required ranges | No | One simultaneous client per instance on single-client server libraries |
| B: two instances, two TCP ports | A second server instance with its own port number, and clients configured for it | No — both instances reply from the same interface address | Each client must dial the port you assigned; nothing discovers it |
| C: second interface in its own subnet | An independent port or Ethernet extension with its own network settings | Yes — the extension's address | The second client network must live on that different subnet |
| D: one device per address | A gateway or small host running its own Modbus server beside the controller | Yes — that device's address | An extra node to build, address, and maintain |
Approach A is smaller than it looks: registers 0-5 are 6 registers and 1000-1010 are 11, so the map needs 17 populated points across a span of 1011 addresses, with 6 through 999 left unmapped. Have the client issue two reads rather than one: a read of holding registers is capped at 125 registers per request under the Modbus protocol, and a read that runs across the unmapped gap anyway comes back as the failure covered in why a Modbus read that crosses a register map gap returns exception 02.
Approach D is the route when each address must exist as its own device, for example when a second data source has to be turned into Modbus on its own node. An industrial mini PC that runs the second server or gateway beside the controller is the cabinet build for that job.
How many clients can one Modbus TCP server instance take? #
Read the limit from your library's help, because libraries differ by more than an order of magnitude. One documented ModbusServer function block is specified for up to 16 parallel client connections, while several controller server libraries take exactly one client per instance.
The one-client rule is the common case on PLC server blocks: the instance accepts one TCP session and refuses or stalls further dials until that session closes. Sizing is then plain arithmetic — two simultaneous clients need two instances, and the second instance cannot also listen on the default Modbus port of the same interface, so you give it another TCP port and configure each client with the port it must dial. The everyday version is two SCADA servers writing to one PLC over Modbus TCP, which works once each server gets its own instance or connection slot.
Which setup should you choose for the two-address requirement? #
Choose one address with a flat register map. Both required addresses sit in one /24 subnet, so no arrangement of interfaces can produce them both; registers 0-5 and 1000-1010 belong in one server map that every client reads from the single controller address.
Then adjust for the client count and the network layout:
- More than one simultaneous client: add server instances (approach B) and give each a distinct TCP port. That changes the port plan, never the address plan.
- Second client on a physically separate network that you can re-address: mount the independent second interface or extension (approach C) and give it the different subnet from the worked example, then point that client at the extension's address.
- Both addresses fixed as requirements on separate devices: no controller setting produces them, so build approach D, one device per address.
For the addresses exactly as posed, the decision is approach A on day one, plus a second instance when the second client arrives. Approach C cannot produce two addresses inside one /24, and no parameter in any server block changes the reply source.
Questions asked
Does the Modbus unit identifier give a controller extra server identities?
No. With Modbus TCP the device is selected by IP address and TCP port, so the unit identifier byte carries almost no meaning; many clients send 255 and many server stacks ignore it. Changing that byte cannot create a second reply address, because only register ranges, TCP ports, or interfaces can.
What does a client see when it dials a busy single-client server instance?
The extra TCP connection is refused or left waiting until the first client closes, and the symptom usually shows as intermittent connect timeouts rather than a Modbus exception, because no request ever reaches the server. One instance per simultaneous client, or a server block documented for several connections, removes the problem.
How do you verify which address a reply came from?
Capture packets on the client machine while it polls. The connection setup goes out to the dialed address, and every response frame shows that same address as its source. A different source address means the frames are not from your controller, so look for another device answering on that address or a router rewriting the path.
What breaks if two interfaces are forced into the same subnet?
Two connected routes to the same subnet make the stack answer address-resolution requests on both interfaces and choose the outgoing port unpredictably, so replies can leave the wrong socket. Keep one subnet per interface and reach the second network by giving the second interface its own subnet, then routing between the two.