We have a 3rd party Router code for our networking product. I am a novice networking developer and do not have much idea on routing. However we are facing a scenario for which we seek solution.

The issue does not occur as long as we keep adding devices in network connected to router with different subnet. But when we define 2 or more IPs in same network / hosts - packets destined for one device lands to another and vice versa.

Initial debugging leads to find that routing of data packet is not correct from the router. It just routed based on network identifier - hence the host destination is wrong

Since I am not an network expert I understand things logically like below -

A remote router would send to next "hop" if not for same network or not configured for destination network

A router that has devices / network directly connected to itself should identify the destination based on IP (within same network / subnet)

Please confirm my understanding and then how the routing table needs to be setup such that internal network routing is facilitated? Is there any RFC related to same for setup?

  • 2
    Routers route packets between networks. Traffic on the same network is delivered directly from one host to another host by the layer-2 address on the frame, and it doesn't involve a router, routing table, or the layer-3 address. Your question is really too broad and unclear. Please edit your question to include a good network description or diagram, the network device models, and the network device configurations.
    – Ron Maupin
    Jan 16, 2019 at 7:41
  • Thanks for the details as provided - as I understand that then the Physical Layer(please confirm which protocol at this layer) should take care of internal routing to hosts directly connected?
    – Programmer
    Jan 16, 2019 at 7:45
  • I do not understand your comment. If you are asking about what happens inside a host, that is off-topic here. You may be able to ask about that on Server Fault for a business network.
    – Ron Maupin
    Jan 16, 2019 at 7:46
  • As you have stated "host to another host by the layer-2 address" - is there a protocol like ARP etc which should resolve this or implement this functionality?
    – Programmer
    Jan 16, 2019 at 7:49
  • That depends on which layer-2 and layer-3 protocols are used. ARP is only used for IEEE LAN protocols and IPv4. Other layer-2 protocols my use something else, or nothing at all, and IPv6 doesn't have broadcast, so it cannot use ARP.
    – Ron Maupin
    Jan 16, 2019 at 7:51

1 Answer 1


IP addresses are logical addresses - they need to be grouped into subnets and all members of a subnet share the same prefix, e.g. for all hosts through

Usually, your subnets are mapped 1:1 to your layer-2 segments. You can run multiple subnets within the same layer-2 segment, but you require a router. The router needs to be aware of the situation ("hairpinning") and requires an IP address from each subnet on its local interface. For instance, if you've got and in the same L2 segment, the router could use and

You cannot use the routing table to establish communication. Local subnets are added automatically to the router's table, so there's nothing to do.

You absolutely cannot use IP addresses from one subnet in multiple L2 segments - if you try, nodes in different segments cannot communicate (without serious and elaborate workarounds).

Since you're mixing up the layers a bit:

  • The physical layer (L1) takes care of moving bits from one port to another. It is a point-to-point protocol (unless it's ancient 10BASE2/5 or you use obsolete repeaters). Visualize a cable.
  • The data link layer (L2) transports frames based on their MAC addresses. All nodes need to share a common L2 segment (broadcast domain). L2 uses L1 for physical transport. Visualize a switch or a VLAN.
  • The network layer (L3) routes packets across the world based on their IP addresses. L3 uses L2 for local network transport. Visualize a router.
  • I am not sure if I make meaning - I need to implement "source routing" as a fix and not sure how to achieve it using existing code? I goggled around and it stated that in source routing we can specify the path packet has to travel - so how do we write / add path details in the network packet and how - I am not sure of how to achieve the same?
    – Programmer
    Jan 21, 2019 at 23:33
  • Source routing is mostly deprecated because of security issues. You need to configure your router correctly, either by static routes or by policy routes. If routers in between don't route as desired you need to tunnel.
    – Zac67
    Jan 22, 2019 at 7:26

Your Answer

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

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