0
Just a theoretical question (out of curiosity). If a host sent a packet to its default gateway and the packet has a destination address within the IP range of the subnet, what should the gateway do in such case? Is there a rule for it in any RFC?
0
Just a theoretical question (out of curiosity). If a host sent a packet to its default gateway and the packet has a destination address within the IP range of the subnet, what should the gateway do in such case? Is there a rule for it in any RFC?
1
The router should route it back to the correct interface.
0
The gateway should have the same kind of rules that a host has to determine a packet destination. So, usually a host will not send a packet to the gateway if it is in the same subnet. The term 'gateway' implies 'access to the outside'. You don't need to go through it if you can send directly to the target. So even if your host has bung rules and DOES send that packet to the gateway, the gateway will have correct rules that say "any packet with a destination on the subnet for this interface will go to that interface". In this case it simply forwards it on, provided it has been configured correctly.
0
Packets get to routers from hosts who have no idea what the router's IP address is all the time. They don't necessarily know there's a shorter path because they don't necessarily know the router and destination reside on a common subnet. This is one of the reasons we have ICMP redirect messages.
As just one way this can happen, consider if a host is temporarily reachable through a VPN. The router has to do proxy ARP for the host to get the packets to the router. If the host shortly later connects directly to the network (or through a VPN to a different host), the packet may get to the router and the router will have to put it back on the LAN to get to its destination.
Another common way is if two different IP ranges share the same physical network. A router may have two different IP addresses, on in each range. And a host may only know the router by one of its IP addresses. If it sends out a packet bound for a destination other than the router in the other IP range, this will happen.