When a router receives a packet from host A that is to be delivered via gateway B, and it determines that host A and gateway B are in fact in the same IP network, it will inform the sender by means of an
ICMP Redirect message that the packet could/should be sent via an alternate path.
The same happens if the recipient is in the same network as the incoming interface of the gateway, which is the case in your scenario. The ICMP Redirect message will tell the sender that the packet can be delivered directly to the recipient.
The standard does not dictate that an IP host
has to process incoming ICMP Redirect messages, and likewise it's not mandatory for IP routers to generate them. These are the relevant files in
/proc that control this behaviour:
Code:
/proc/sys/net/ipv4/conf/all/accept_redirects
/proc/sys/net/ipv4/conf/default/accept_redirects
/proc/sys/net/ipv4/conf/<interface name>/accept_redirects
/proc/sys/net/ipv4/conf/all/send_redirects
/proc/sys/net/ipv4/conf/default/send_redirects
/proc/sys/net/ipv4/conf/<interface name>/send_redirects