arp requesting to another subnet, how?

It's "method A". ARP requests for addresses outside the subnet won't be sent at all. The only ARP request will be for the gateway's IP address.

If you just set up 192.168.123.1/24 for computer A and do not do anything else, it will have a routing table like this:

  • 192.168.123.0/24 to device eth0
  • 0.0.0.0/0 to gateway 192.168.123.254 device eth0

In such a routing table, the first entry declares that the 192.168.123.0/24 is local – accessible over eth0 without a gateway – so attempting to contact 192.168.123.42 would indeed send an ARP request for 192.168.123.42.

However, the second entry has a gateway defined, so it is assumed to be non-local, and the OS does not bother sending ARP requests for these other IP addresses, because it already knows it cannot reach them. It will therefore directly send an ARP request for the gateway's address and nothing else.

(You can verify this by just looking at the ARP cache; ip neigh or arp -a depending on operating system; or by using a packet capture tool like tcpdump or Wireshark.)

In most operating systems, you can, of course, add routes explicitly telling the OS that certain subnets are local (e.g. ip route add 192.168.124.0/24 dev eth0).

Tags:

Networking

Arp