1

The settings are:

manually set my host IP: 10.0.1.6/24, gateway: 10.0.0.138/24

they both know each other's MAC (arp -a shows the list) and there is a direct physical connection between them.

From the trace, I can see the host sends data to the gateway by adding the gateway's MAC in the frame.

But receive nothing from the gateway, also ping is no response.

However, when I change the gateway's subnet mask to 255.255.254.0, everything is fine, data flows in both ways.

This is confusing me:

  1. Does the host IP must be contained in Router's subnet so that they can communicate? even they know each other's IP and MAC?

  2. To my knowledge, the router doesn't have to be in the same subnet with the next hop, as long as it knows the next hop's IP and MAC, so why my host cannot get responses through my router?

  3. Under my scenario, what's the right thing to do to set up communication in both ways? Adding a static routing entry? please advice, thanks!

5
  • Gateway router doesn't know where to send the response since 10.0.1.0/24 is not in it's routing table. However, 10.0.0.0/24 is (It's a connected route of 10.0.0.138 interface). So you can do all sorts of tricks to make this work, but why not just place them on the same subnet /23?
    – manish ma
    Aug 23, 2021 at 11:09
  • Because I just want to know, if the host subnet does not belong to the router, how can they communicate?
    – Snow
    Aug 23, 2021 at 11:52
  • I guess this is because if the destination IP address (in your case the destination is default gateway IP address itself) is not on the same subnet of local host, local host will send the traffic to default gateway. This would also happen if you would attempt to send traffic to any other IP address outside of your subnet..e.g. 8.8.8.8. Return traffic is to be analyzed separately. In this case default gateway doesn't know how to return to host since there is no route
    – manish ma
    Aug 23, 2021 at 12:18
  • 1
    A gateway is a host on the same network that knows how to reach other networks, so both a host and its configured gateway must be addressed in the same network.
    – Ron Maupin
    Aug 23, 2021 at 14:05
  • Did any answer help you? if so, you should accept the answer so that the question does not keep popping up forever, looking for an answer. Alternatively, you could post and accept your own answer.
    – Ron Maupin
    Dec 23, 2021 at 21:28

1 Answer 1

1

But receive nothing from the gateway, also ping is no response.

That is to be expected. 10.0.1.6 is not part of 10.0.0.138/24's subnet, 10.0.0.0/24. Packets are sent 'elsewhere', possibly using the router's default route (which usually points to WAN).

when I change the gateway's subnet mask to 255.255.254.0, everything is fine, data flows in both ways. Yes - now 10.0.1.6 does belong to 10.0.0.138/23's subnet, 10.0.0.0/23 (ranging from 10.0.0.0 to 10.0.0.1.255).

Generally, only nodes within the same subnet (from each other's perspective) can talk to each other directly. Direct communication is required in order to use a gateway.

You need to move both nodes into the same subnet, either by changing one of the addresses or by enlarging the subnet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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