-
Jul 19th, 2024, 06:30 PM
#1
Thread Starter
New Member
TCP connect to addresses on different subnets
Hello.
I currently have a vb.net application that communicates via modbusTCP.
I am able to communicate with devices on my local network, but I am unable to communicate with devices on a different subnet.
For example, if I configure my computer’s network interface with IP address 192.168.1.2, gateway 192.168.1.1, subnet 255.255.255.0, I am able to establish TCP connections to all devices on the 192.168.1.x subnet.
How would I establish connections on a different subset? For example, a device with IP address 192.168.2.1.
Does this require another piece of hardware like a router, or can this be accomplished purely with code using VB.net?
Any insight would be appreciated
-
Jul 19th, 2024, 06:41 PM
#2
Re: TCP connect to addresses on different subnets
As described, this is outside of a VB.NET question.
That being said, it completely depends on the network setup. It could be as simple as "widening" your subnet mask to something like 255.255.0.0, which means it will treat any address of 192.168.x.x as a local address not needing to route through your default gateway.
-
Jul 19th, 2024, 06:49 PM
#3
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
Thanks for the reply and I apologize if this isn’t entirely a vb.net question.
-
Jul 20th, 2024, 03:59 AM
#4
Re: TCP connect to addresses on different subnets
You can add to your PC network adaptor another address on the 192.168.2.x (with a subnet mask of 255.255.255.0). Then your PC will be able to access 192.168.1.x and 192.168.2.x networks.
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jul 20th, 2024, 05:43 AM
#5
Re: TCP connect to addresses on different subnets
Originally Posted by RadioscoutNews
Hello.
I currently have a vb.net application that communicates via modbusTCP.
I am able to communicate with devices on my local network, but I am unable to communicate with devices on a different subnet.
For example, if I configure my computer’s network interface with IP address 192.168.1.2, gateway 192.168.1.1, subnet 255.255.255.0, I am able to establish TCP connections to all devices on the 192.168.1.x subnet.
How would I establish connections on a different subset? For example, a device with IP address 192.168.2.1.
Does this require another piece of hardware like a router, or can this be accomplished purely with code using VB.net?
Any insight would be appreciated
Might be easier to understand what your ultimate aim is on this one...
Are you currently on a network with multiple subnets? If so the router etc. might already be in place and things might just work.
Are you looking at taking an existing network and subnetting it into two (or more)? If so is there a reason for doing this?
-
Jul 20th, 2024, 09:50 AM
#6
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
Thanks for the reply.
I apologize for my limited knowledge on networking. I have someone telling me they are unable to connect to controllers that are on a different subnet than the one their PC is on. They are asking me for a software solution to this issue. In my understanding, the PC will only be able to connect to devices it has a path or “rout” to. Aside from editing the network parameters of their PC’s network interface card, I don’t see anyway for the computer to be visible to controllers on a different subnet.
I am unaware of their current network topology, so maybe we can speak in general terms. If a computer on one subnet wants to be visible to controllers on a different subnet, will this always require a router between to two subnets to join them? Assuming we do not know what ip address and subnet configuration they will be using, because it could be anything
Last edited by RadioscoutNews; Jul 20th, 2024 at 09:54 AM.
-
Jul 20th, 2024, 09:51 AM
#7
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
Are you saying I can assign two IP addresses to one network interface card?
-
Jul 20th, 2024, 10:01 AM
#8
Re: TCP connect to addresses on different subnets
Originally Posted by RadioscoutNews
Thanks for the reply.
I apologize for my limited knowledge on networking. I have someone telling me they are unable to connect to controllers that are on a different subnet than the one their PC is on. They are asking me for a software solution to this issue. In my understanding, the PC will only be able to connect to devices it has a path or “rout” to. Aside from editing the network parameters of their PC’s network interface card, I don’t see anyway for the computer to be visible to controllers on a different subnet.
I am unaware of their current network topology, so maybe we can speak in general terms. If a computer on one subnet wants to be visible to controllers on a different subnet, will this always require a router between to two subnets to join them? Assuming we do not know what ip address and subnet configuration they will be using, because it could be anything
There's no software solution to resolve a lack of proper network connectivity or configuration.
There's also really no generic suggestions that can be given for a completely unknown network configuration to make this work.
Your original post made it sound like this was all happening on *your* local LAN. Now it sounds like you are simply providing software for clients, and this is all happening on *their* LAN. Big difference there.
Bottom line - the client would need to have their network properly configured (both from a hardware standpoint and a PC configuration standpoint) for this to work. You're already removed from the situation, and we're obviously further removed, so we know nothing about any specific details. So, good luck.
-
Jul 20th, 2024, 10:20 AM
#9
Re: TCP connect to addresses on different subnets
> If a computer on one subnet wants to be visible to controllers on a different subnet, will this always require a router between to two subnets to join them?
Yes. The "router" can be a multi-homed machine though i.e. just a PC with two network cards.
Also at this exact access point you might get NAT/firewall involved i.e. network A can address network B freely while network B cannot see anything inside network A (i.e. network A is protected).
cheers,
</wqw>
-
Jul 20th, 2024, 10:37 AM
#10
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
Understood.
I will check back when I have a more detailed explication of the problem. I appreciate you taking the time to reply.
-
Jul 20th, 2024, 10:40 AM
#11
Re: TCP connect to addresses on different subnets
Originally Posted by RadioscoutNews
Are you saying I can assign two IP addresses to one network interface card?
Yes. But note that you can only have 1 gateway address.
Code:
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 192.168.1.20
Subnet Mask . . . . . . . . . . . : 255.255.255.0
IPv4 Address. . . . . . . . . . . : 192.168.7.20
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.7.1
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jul 20th, 2024, 10:53 AM
#12
Re: TCP connect to addresses on different subnets
Originally Posted by wqweto
> If a computer on one subnet wants to be visible to controllers on a different subnet, will this always require a router between to two subnets to join them?
Yes. The "router" can be a multi-homed machine though i.e. just a PC with two network cards.
I would just add the caveat that having one device with an IP address of 192.168.1.10 and another device with an IP address of 192.168.2.10 doesn't guarantee that they are on a different subnet. There could be one "large" subnet that encompasses the entire 192.168.x.x range. In that case, the correct subnet mask would be 255.255.0.0. From a 192.168.1.x device, having an incorrect subnet mask of 255.255.255.0 would presumably prevent proper access to anything in the 192.168.Not1.x range, even though the configuration of the network gear itself would allow it if the mask were correct.
-
Jul 20th, 2024, 10:57 AM
#13
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
Okay. Thank you.
After everyone’s replies and my own investigation over the last day or two, it appears that this is a networking solution and not a programming one.
I’m thinking the best solution is to widen the subnet of the computer’s network interface card to include all possible IP addresses of the controllers (devices) on the network.
Alternative, another piece of hardware like a router will be needed.
When it comes down to it, the PC will not be able to communicate with anything on the network not visible to it.
Thanks again for your reply
-
Jul 20th, 2024, 10:59 AM
#14
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
Yes, I’m thinking expanding the subnet mask will remedy the issue. Thank you
-
Jul 20th, 2024, 11:08 AM
#15
Re: TCP connect to addresses on different subnets
This isn't a guarantee, but if these are all devices that are located in a single physical location, then they could be on the same subnet. If they are in different physical locations, then they are almost certainly on different subnets and would need some sort of routing device in place to allow communication.
-
Jul 20th, 2024, 11:15 AM
#16
Thread Starter
New Member
Re: TCP connect to addresses on different subnets
They are in the same physical location (per se), but they are spread over many acres. I believe the subnetting in this situation is being done to separate controllers into different groups, or possibly there are more than 255 devices that require use of a second octet in the IP address range to begin adding more devices.
-
Jul 20th, 2024, 11:37 AM
#17
Re: TCP connect to addresses on different subnets
Local segments of ethernet LAN have some length limitation -- ~100 m for the Cat. 5 cables so most probably the topology you are dealing with involves multiple segments connected over SFP (fiber).
A single physical segment can be further subnetted using IP/mask settings but this can be easily circumvented by anyone on the physical segment widening the mask or just adding additional IP addresses on the machine (on the same network adapter) so this cannot be any security feature.
When I have to connect external devices (printers, etc.) over ethernet these usually come preset with 192.168.0.x addresses while our LAN uses 172.x.y.z so I just add an additional IP address in 192.168.0.x/24 on my machine so that I can simultaneously stay on local LAN and connect to the device from my machine only. No one else (not having 192.168.0.x/24) can access the device which is convenient.
cheers,
</wqw>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|