I've been searching for an answer to this question for a while now but somehow I couldn't find a satisfying answer.
Assume a host H is connected to a router R via a switch S. Now assume the router receives an IP datagram addressed to H. It consults its routing table and determines the interface upon which to forward the packet.
Now it must encapsulate the IP datagram in a link-layer frame and send it on its way. The next hop is obviously the switch, so the router must put the switch's MAC address in the destination MAC field.
But how does the router know the switch's MAC address? It can't use ARP to resolve the switch's MAC address since the switch doesn't necessarily have an IP address (e.g. if the switch is an unmanaged switch). And if it has the switch's MAC address stored in its forwarding table somehow, then how did it get it in the first place? Or does it just put H's MAC address in the destination field and the switch ignores that the MAC address doesn't match its MAC address?
Thank you for your help :)