Difficulty: Beginner
What is the difference between a MAC address and an IP address? Why do we need both?
This looks like a warm-up question, but it hides a really good insight, so let's go beyond the textbook one-liner. The simplest analogy: your MAC address is like your Aadhaar number or your name, it identifies you as a person wherever you go. Your IP address is like your current postal address, it tells the postman where to find you right now, and it changes when you move to a different city. One identifies the device, the other locates it in the network.
A MAC address is a 48-bit hardware address burned into a network interface card by the manufacturer, written as six hexadecimal pairs like 3C:22:FB:9A:12:7E. The first three bytes are the OUI, which identifies the manufacturer, and the last three are assigned by that manufacturer. It works at the Data Link layer (layer 2) and is only meaningful inside a single local network segment, meaning within one broadcast domain.
An IP address is a logical address assigned to an interface, either statically or by DHCP. IPv4 is 32 bits, IPv6 is 128 bits. It works at the Network layer (layer 3) and is hierarchical: part of it is the network prefix and part is the host. That hierarchy is what lets routers summarise millions of destinations into small routing tables. A MAC address is flat and has no structure that helps routing, so you could never build a global internet on MAC addresses alone.
So why both? Because they solve different problems. IP handles the end-to-end journey across many networks, the routing decision at each router. MAC handles the last hop: once a packet is on a particular Ethernet segment, the switch needs to know which physical port leads to the next device. When you send data to a server in another city, the source and destination IP addresses stay the same the whole way (ignoring NAT), but the source and destination MAC addresses change at every hop. On your laptop, the destination MAC is your default gateway's MAC, not the server's.
Here is the follow-up you should be ready for: how does a host know the MAC for a given IP on the same subnet? That is ARP, the Address Resolution Protocol. The host broadcasts who has 192.168.1.1, and the owner replies with its MAC. For a destination outside the subnet, the host ARPs for the gateway's MAC instead.
Edge cases worth mentioning: MAC addresses can be changed in software, which is called MAC spoofing, so they should not be used as a security mechanism on their own, although MAC filtering is often used in Wi-Fi as a weak control. Modern phones also randomise MAC addresses per Wi-Fi network for privacy. And a single device can have many IPs (multiple interfaces, virtual IPs, aliases) but each physical NIC has exactly one burned-in MAC. Also, an IP address is not tied to hardware, which is why a laptop keeps its MAC but gets a new IP at home versus at a cafe.
$ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500
link/ether 3c:22:fb:9a:12:7e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.23/24 brd 192.168.1.255 scope global eth0
link/ether is the MAC (layer 2). inet is the IPv4 address with prefix length (layer 3).
MAC Address, IP Address, Data Link Layer, Network Layer, Addressing