Not receiving responses sent from a different subnet when my machine is on DHCP

0

I am building a utility to communicate with some hardware that comes with a default IP address of 10.0.0.1 and subnet mask 255.255.255.0. The hardware replies to UDP messages on the same IP and port they originated from (not the port received on). I have a socket setup to send a broadcast UDP message and then listen for replies from any IP.

The problem I am having is that when my Windows 7 machine is on an IP received from my router via DHCP (as most of our users will be), I only receive responses from devices previously configured to be on the same subnet (192.168.1.XXX), and get nothing from a new device on the default 10.0.0.1.

However, I discovered (by accident) that if I reconfigure Windows with a manually assigned IP (10.0.0.2) and no other changes, I am suddenly able to receive messages from ALL devices, from any subnet. This makes me think my code is ok but that I'm missing something in regards to how DHCP or Windows handles UDP responses. Is anyone able to shed some light on what I need to do to make this work?

Thank you in advance!

EDIT

Desktop PC is connected to the router via a wired NIC. All the other devices are connected to one switch which is also connected straight to the router. When PC is configured in Windows to get an IP automatically it receives 192.168.1.112. Two of the devices are manualy set to 192.168.1.XXX addresses, and the third is at its default of 10.0.0.1. The devices do not have a DHCP mode.

Another note: regardless of whether the PC is in DHCP or a static IP, I have confirmed that the broadcast messages DO reach the device on the other subnet (10.0.0.1). This is verified by the fact that the devices respond appropriately to the commands I send. The problem lies completely in the device's network response making it back to my application. I don't know if it's Windows or my application blocking the response, but I don't think it's the router because I can get responses when I give my PC a static IP without changing anything else on the network.

DrRocket

Posted 2012-12-17T17:52:14.493

Reputation:

How are your desktop PC and that "hardware" connected? Switches, routers, network cards? What are the addresses there? – Nikolai N Fetissov – 2012-12-17T18:16:38.903

Desktop PC is connected to the router via a wired NIC. All the other devices are connected to one switch which is also connected straight to the router. – None – 2012-12-17T18:34:41.227

Either the router or the switch probably drops the packet from the device back to 192.168.1/24. This has nothing to do with DHCP, just basic IP routing. – Nikolai N Fetissov – 2012-12-17T19:24:43.633

Answers

0

The problem lies in your hardware and is basic networking, the solution is to give (or set) the hardware an IP address of the same subnet you're connecting it to (192.168.x.x) and is caused because devices in the same sub-network can comunicate with each other (that's why changing to a 10.x.x.x address works), but they can't with other subnets (10.x.x.x and 192.168.x.x are different subnets) unless you set a default gateway. Don't take me wrong, but i advice you to take a look at some networking material (Cisco material is widely available in the internet), so you get some of the basics.

Rafael

Posted 2012-12-17T17:52:14.493

Reputation:

That was also my assumption at first, that they just couldn't communicate across subnets, but then I found that if I set a manual IP on my desktop in Windows I CAN communicate across subnets. If I set my desktop IP to 10.0.0.2 (no default gateway) I receive messages from both the 10.x.x.x and 192.168.x.x subnets with no problems. – None – 2012-12-17T21:10:18.287