3

I am trying to connect 2 devices in different subnets.

Device 1:
IP address: 172.20.35.1
netmask: 255.255.0.0
gateway: 172.20.1.1

Device 2:
IP address: 172.20.100.100
netmask: 255.255.255.0
gateway: 172.20.100.1

The router has IP address 172.20.1.1.

When I send a UDP datagram from device 1 to device 2, device 2 receives it but cannot reply, since the gateway IP address (device 2) is wrong.

But shouldn't the router be able to connect these 2 networks together as shown here http://www.eventhelix.com/realtimemantra/networking/ip_routing.htm#.VMo5Sx3n5Qs? Must the routes be manually configured?

Also: What if I change the network config of device 2 as shown below?

Device 1:
IP address: 172.20.35.1
netmask: 255.255.0.0
gateway: 172.20.1.1

Device 2:
IP address: 192.168.170.100
netmask: 255.255.255.0
gateway: 192.168.170.1

With this network config, device 2 never receives the UDP datagram. Why is that?

EDIT:

Just to clarify. I'm actually not a newbie. The described issue is known to me since many of my clients tend to configure their devices the way I described above and then end up unable to reach them per TELNET. I managed to solve this issue by implementing a multicast tunnel allowing the user to change the network configuration on the remote device using a multicast UDP protocol, whenever they mess up the configuration as shown above. Anyway, I had an phone interview at a company and the manager said that traffic between such devices will always be possible, because that's what routers are for. I was invited to a personal interview and I know that this question will come up again. So I posted this question here in order to help me formulate a better answer.

migrated from networkengineering.stackexchange.com Jan 29 '15 at 19:47

This question came from our site for network engineers.

2

I'm trying to connect 2 devices in different subnets.

Device 1: IP address: 172.20.35.1 netmask: 255.255.0.0 gateway: 172.20.1.1

Device 2: IP address: 172.20.100.100 netmask: 255.255.255.0 gateway: 172.20.100.1

The router has IP address 172.20.1.1 !! When I send a UDP datagram from device 1 to device 2, device 2 receives it but cannot reply, since the gateway IP address (device 2) is wrong.

The real problem is overlapping subnets, combined with no proxy arp on your router interface with 172.20.1.1.

The host at 172.20.35.1 thinks 172.20.1.1 is on the same subnet, so 172.20.35.1 ARPs directly for 172.20.1.100. However, nothing is on the 172.20.0.0/16 subnet to reply.

There are a few choices to solve the problem:

  1. (Short Term hack) Enable proxy-arp on 172.20.1.1. As long as 172.20.1.1 has a route to 172.20.35.0/24, 172.20.1.1 will respond to ARPs for 172.20.1.100 with its own mac address and assuming no other problems, you will get bidirectional communication between those subnets.

  2. (Long Term) Reorganize your network without overlapping subnets. This requires readdressing hosts; potentially a lot of hosts.

  3. Perform NAT on 172.20.35.0/24 so it doesn't look like the same subnet as anything else. NAT solutions can be incrementally harder to support, but it avoids the need for proxy arp.

Also: what if I change the network config of device 2 as shown below.

With this network config, device 2 never receives the UDP datagram. Why is that?

It looks like you need a route to 192.168.170.0/24

  • Nice. Thank you for the answer. Please check the EDIT in my original post – H_squared Jan 30 '15 at 10:31
2

I think there are actually a few problems. The first one is this:

without access to router config

All Mike's suggested actions require changing the router configuration.

The second problem is this:

The router has IP address 172.20.1.1 !!

Forwarding traffic (i.e. routing) between subnets A and B is possible if and only if the router has IP interfaces in both subnets. Router's IP interface is the IP address, so if your router has only one IP address no routing is possible.

You're not clarifying what exactly do you mean with "router", but for example your average DSL router works this way. It has only one IP address which is used in your internal network, it gets the other IP address through the DSL line from the ISP. Thus it will end up with two IPs, and it will be able to route traffic between these two subnets. You don't usually even have the option to create new VLANs to have more subnets on the LAN side.

Here's a little curiosity. You've configured your client 1 with IP address with /16 subnet (mask 255.255.0.0). The IP address range of subnet 172.20.0.0/16 is 172.20.0.1-172.20.255.255, last one being the broadcast address. The router IP is usually the lowest or highest in the subnet, so I'd expect 172.20.0.1 or 172.20.255.254. This isn't a rule, it's just how it's usually done.

If your router's subnet is actually /16, you get over your first issue very easily: configure your second device with subnet mask 255.255.0.0 and use 172.20.1.1 as default gateway. This will put it in the same subnet with device 1, and traffic will flow. This isn't routing, this is L2 switching.

I send a UDP datagram from device 1 to device 2, device 2 receives it but cannot reply, since the gateway IP address (device 2) is wrong.

This doesn't necessarily have anything to do with your gateway address. UDP is a one-way protocol. The protocol itself does not contain any mechanism to send responses or acknowledgements. To have your device 2 respond to UDP datagram, you must run an application which will respond when a packet is received. If you're testing connectivity, use ping which is developed for this purpose. ICMP is a TCP protocol, so it's two-way. Your device 1 will send an ICMP echo request (i.e. ping packet) to device 2, which will respond with ICMP reply.

With this network config, device 2 never receives the UDP datagram. Why is that?

Here we get back to the IP interfaces. As Mike says, you need to have a route into this network, so your router must have IP address 192.168.170.1/24.

Returning to your question title. If you are not able to configure the router, the only thing you can do is configuring the device 2 subnet and gateway as I described above, and that'll work only if the router's subnet is /16. All other solutions presented so far require access to the router configuration.

  • 2
    Re: " All other solutions presented so far require access to the router configuration". I would add "or talking to the network administrator" (technically not forbidden by the question), which is the perhaps the most basic problem the OP has. It's kind of hard to expand networks without talking to the owner... Perhaps we should all be thankful for this :-) – Mike Pennington Jan 29 '15 at 19:44
  • Right on :D Kinda interesting... why did this get transferred to ServerFault? – Peregrino69 Jan 29 '15 at 19:51
  • He doesn't control the network – Mike Pennington Jan 29 '15 at 19:52
  • Well of course :) – Peregrino69 Jan 29 '15 at 19:58
  • FYI – Mike Pennington Jan 29 '15 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.