I am new to networking, so please excuse me if I am saying stupid stuff.

From my understanding, PCs are sending packets to switches, which then decide which physical port to forward that packet to.

But how does my computer know where to send that packet so it goes to the switch? do switches have IP addresses or MAC addresses?
If they do, does that mean that my Default Gateway is the switch? How can I find the switch's IP/MAC address?


  • For transient traffic (traffic going through a switch) a switch doesn't have an IP address or MAC address. It is conceptually serving simply as a multi-point cable (sort of). For traffic meant to go to a switch, then a switch is acting as host -- which has an IP address and a MAC address and follows all the typical rules a host follows for how packets move through a network.
    – Eddie
    Commented Mar 31, 2020 at 15:10

2 Answers 2


Hosts send frames out interfaces that are connected to switches. The packets are the payload of the frames. The frames have the MAC addresses of both the source and destination hosts in the frame header, and the switch will switch the frames based on the destination header. The switch learns where hosts are connected to it by looking at the source addresses on the frames and building a MAC address table.

A host will use ARP for IPv4 or NDP for IPv6 to determine the MAC address related to the IP address, and it uses that to address the frames its sends. The switch looks at everyu frame that enters the switch to build its MAC address table.

The default gateway is just another host connected to the switch. The source host will look at the destination IP address to see if it is on the same network. If it is, it will address the frame with the destination host MAC address. If the IP destination is on a different network, the host will address the frame with the gateway MAC address.

The switch is a transparent device, and it does not need a MAC or IP address. Managed switches have MAC and IP addresses in order to connect to the management interface, but that has nothing to do with the switching of frames.

  • Say I have PC A and PC B who are both connected to the same switch. If PC A wants to PC B data, what is the source MAC and destination MAC of that frame? is it source=PC A's MAC and destination=PC B's MAC?
    – ori6151
    Commented Mar 31, 2020 at 14:56
  • As I wrote in my answer, "The frames have the MAC addresses of both the source and destination hosts in the frame header." A frame from PCA to PCB will have the source MAC address of the source host (PCA) and the destination MAC address of the destination host (PCB).
    – Ron Maupin
    Commented Mar 31, 2020 at 14:59
  • Ok, so how does the frame end up at the switch? because it's physically connected?
    – ori6151
    Commented Mar 31, 2020 at 15:01
  • The host has a routing table to tell it to which interface it should send the packet. The packet gets its frame at the interface, and the interface sends the frame out the wire. The device on the other end of the link (the switch, in this case) will get the frames.
    – Ron Maupin
    Commented Mar 31, 2020 at 15:07

Intially when PC wants to send packet to destination . PC runs ANDing process and decided whether destination is on same networks or different networks .

If same networks means

Packet is send to connected layer2 switch . L2 switch won't understand destination ip address . Instead of ip address switch understand mac -address . With reference to destination mac -address by verifying mac -address table frame is forwarded to respective switch port .

If on different networks means

From PC, packet is forwarded to gateway of layer3 device from layer3 devices packet is forwarded to destination with the reference to routing table in layer3 devices ,As per routing table packet is destined to destination.

  • You're correct but that wasn't the question.
    – Zac67
    Commented Jan 11, 2021 at 16:08

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.