Two host of different subnets, let it be A - and B - be connect to the same switch S. Can they communicate?

So as far I understand:

  • A sends a packets with IP of B
  • S receives it and compare it with values in Stored Address Table else broadcasts it.
  • B receives the packets, check the IP and accepts it.

Am I right?

4 Answers 4


Unfortunately, no, you are incorrect.

Ron makes a good point, you didn't provide a subnet mask, so if we were to assume the classful mask, the 10.x.x.x address would have a mask, which would actually put the two hosts on the same network. If that is the case, they would have no problem communicating.

However, given the nature of your question, I imagine you intended for each of these hosts to use a smaller mask -- we'll go ahead and use, which puts both hosts in two different subnets.

That being said, the heart of what you are missing lies in forgetting about ARP (Address Resolution Protocol). Specifically, in whom HostA decides to ARP for. Let me explain...

Before any host puts any packet on the wire, the first thing it does is determine whether the destination IP is on its own network, or on a foreign network. Let's run through it from the perspective of Host A.

Host A know its IP (, and its Subnet Mask (/24, or With a little subnetting, HostA determines that its network spans all the IP addresses in the range of through (We'll leave out details of the NetID and BroadcastIP, since for the moment they aren't relevant)

Host A also knows its destination IP is, which falls outside of the range of IP addresses within Host A's own network. As such, Host A would would come to the conclusion that the destination IP is on a foreign network, and Host A could only reach a foreign network by speaking through a Router. Or more specifically, through HostA's default gateway.

If HostA isn't configured with a Default Gateway at this point, then the process ends here with a general failure. HostA can not speak to HostB.

If HostA is configured with a Default Gateway, it would send out an ARP Request (which is itself a Broadcast frame), asking for the MAC address of its default gateway -- NOT the MAC address of the final destination IP.

The switch, having received the broadcast frame would flood the packet out all interfaces, to include the one HostB is connected to. HostB would indeed receive the packet, but since the ARP is looking for the Default Gateway's MAC address (and not the MAC address of HostB), HostB would simply drop and ignore the ARP Request, without ever sending any sort of response.

HostA, then, would never receive a MAC address for its default gateway, and would therefore be unable to encapsulate the Layer 3 Packet with a Layer 2 header. The packet would fail there.

You can see the ARP process illustrated in this video.

That said, although somewhat unrelated to your question, I did want to speak to something you said. This may be terminology nuance, but I just want to make sure it is communicated. A switch only does two things: forwards frame for which it know the destination MAC address, or flood frames for which it doesn't know the destination MAC address. A switch never broadcasts.

A broadcast is a frame who's destination MAC address is ffff.ffff.ffff. This is a specially reserved MAC address, specifically designed for broadcast frames. When a switch encounters a frame destined to ffff.ffff.ffff, its behavior is to always flood that frame.

You could look at it like this, since ffff.ffff.ffff is a reserved MAC address, it is un-learn-able by the switch. Therefore, whenever a switch receives something destined to ffff.ffff.ffff, it is forced to flood it out all ports in the VLAN that the frame was originally received in.

  • There are edge cases to this answer... hosts can have either no gateway, or their own address configured as their gateway address. This causes the host to ARP for all addresses and proxy-arp enabled routers with a route (even default route) to the destination will reply with their own mac-address.
    – cpt_fink
    Nov 8, 2014 at 1:39
  • 3
    There are edge cases for just about any answer/situation. I didn't think going into some of them here would be relevant to the question.
    – Eddie
    Nov 16, 2014 at 15:46

Yes. If they are under /16 Subnet. For /24 subnet, you need router.

  • 1
    You could improve your answer by explaining it more. For instance, explain why it works with /16, but `/24 needs a router.
    – Ron Maupin
    Jul 1, 2016 at 14:40

If host A and B are on different networks or subnets and connected to the same switch I believe that they can communicate through the default gateway.

  • A gateway address must be in the same network as the address configured on a host. Since the gateway address is the address used to send traffic off the network, it must be in the same network as the sending host, otherwise the host would need a gateway to get to the gateway.
    – Ron Maupin
    Feb 10, 2017 at 17:22

Only if the switch is connected to a router that knows how to route between these 2 subnets.

  • Layer 3 switch does not required separate router
    – infra
    Apr 24, 2019 at 18:18

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.