The MAC address is assigned to the data link layer (layer 2) of the OSI model. In the OSI model extended by the IEEE, it is assigned to the Media Access Control sub-layer (layer 2a). In order to connect the data link layer with the network layer, the Address Resolution Protocol is used in Ethernet, for example, as part of IPv4. In IPv6, there is a new protocol, Neighbour Discovery Protocol (NDP), which takes over this function.
Network devices need a MAC address if they are to be explicitly addressed on layer 2, to offer services on higher layers. If the device only forwards the network packets, such as a repeater or hub, it is not visible on the data link layer and therefore does not need a MAC address. Bridges and switches analyse the packets of the data link layer in order to physically divide the network into several collision domains, but do not actively participate in the communication themselves and therefore do not need a MAC address for these basic functions either.
A switch requires a MAC address when it is itself administered via the computer network or offers monitoring services (for example via Telnet, SNMP or HTTP). A MAC address is also required if bridges or switches use the spanning tree algorithm to avoid loops in redundant networks. spanning tree algorithm to avoid loops in redundant computer networks.