Let's say host A want to send a package to 10.3.3.3, 10.3.3.3 is host B in the same subnet with A. But A thinks B is in the other net, will A try to use arp to get the mac address of B?

Will A set MAC to the route's MAC and send the package to the router directly? What will the router do if it received the package, it will send it to B directly?

Contrarily, if A think B is in the same net and actually, B is not, will A find B finally? A might send an arp but no one would response. Will A try to send the package to router?

有帮助吗?

解决方案

The routing is entirely based on the destination address and the routing table (which will vary depending on the configuration of your subnet).

Lets suppose that,

Host A is 10.3.4.4 and is configured with netmask 255.255.255.0 and a router of 10.3.4.1

Host B is 10.3.3.3 and is configured with netmask 255.255.255.0.

In this case the routing table for host A will look something like,

Dest       Gateway   Mask
0.0.0.0    10.3.4.1  0.0.0.0
10.3.4.0   0.0.0.0   255.255.255.0

Starting at the bottom, host A will attempt to find which route to use. If host A tries to contact 10.3.4.x, it will match the first route, and instead of using a gateway it will send an ARP request "who has 10.3.4.x?" on the subnet broadcast address (10.3.4.255).

If host A tries to contact host B, it won't match the first routing rule, and will default to sending the packet to the gateway (10.3.4.1 in this example).

So no, A won't try to use ARP to get the MAC of host B if it isn't configured that host B is in the same subnet. If the router is configured with routing rules to route between subnets, it will deliver the packet, otherwise it will just get dropped.

Contrarily, if A think B is in the same net and actually, B is not, will A find B finally? A might send an arp but no one would response. Will A try to send the package to router?

No. The ARP request will get sent to the subnet broadcast address. If B isn't on that subnet and ignores the ARP request, A won't send the packet to the router, because where it sends the packet is just based on the destination IP address, there's no changing of where it's routed based on if the packet got delivered.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top