A switch uses a routing table to associate the switch’s port number with the MAC address connected at the other end of the wire. The following steps will show how the switch’s routing table is populated.
1 PC Sends a Frame to the Switch
The MAC address used to broadcast a frame to all hosts is all ones.
2 Switch Receives Frame
When the switch receives this frame it uses its routing table to associate the host's MAC address with the interface that received the frame.
Remember the frame sent to the Dynamic Host Configuration Protocol (DHCP) server in the router contains the source MAC address.
3 Switch Broadcasts Frame to all Nodes
The MAC in the switch sees this is a broadcast frame, so the switch forwards the frame to all hosts connected to it.
4 Router Sends Reply to PC
When the switch receives the reply from the router it associates the router’s MAC address with the interface that received the frame.
5 Switch Forwards Frame to PC
The switch looks at this frame to find the destination MAC address and sees that it is already in its routing table. The frame is then forwarded to the appropriate port. No other port will see this frame.