What is a MAC address and how does it differ from an IP address?
A MAC address, or physical address, is a unique identifier hardcoded by the manufacturer into the network card or controller of every device at the hardware level. It consists of forty-two bits, usually written as six groups of hexadecimal numbers separated by a colon. This address is immutable and is used to deliver data within a single local area network via the data link layer of the OSI model.
The main difference between a MAC address and an IP address lies in their working layer and static nature. An IP address operates at the network layer, is logical, and can change depending on which network the device is connected to and how the DHCP server is configured. While an IP address is responsible for global packet routing between different networks worldwide, a MAC address is responsible for delivering a specific frame from one node to another within the same Ethernet or Wi-Fi network segment.
When a device sends data over the internet, the source and destination IP addresses constantly change at each router, but the original and destination MAC addresses change at every hop along the path between neighboring network nodes. To map logical IP addresses to physical MAC addresses in local networks, a special protocol called ARP is used. Without linking these two addresses, correct data transmission in modern packet-switched communication networks is impossible.